Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Sliding Window Limiter Laravel Package

beyondcode/laravel-sliding-window-limiter

A drop-in extension for Laravel's RateLimiter that adds sliding window rate limiting. Instead of fixed intervals that reset abruptly, throttling rolls continuously, giving smoother, more accurate limits for APIs, queued jobs, and other rate-limited actions.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. The package addresses a genuine gap: Laravel's stock fixed-window throttling permits roughly a 2× burst straddling a window boundary, while a sliding window paces traffic smoothly across a rolling interval. Its placement — inside Laravel's cache/RateLimiter abstraction, driven by route middleware, backed by shared Redis — is the architecturally correct shape for a single-region Laravel monolith or a small fleet behind one Redis primary. It is the wrong shape for a multi-region or multi-service estate (that is a gateway policy concern) and does not fit any application where Redis is not already tier-0 and well operated. The dominant architectural fact is lifecycle, not design: archived, last released September 2019, 42 stars, zero dependents, dating it to the Laravel 5.8/6.x and PHP 7.x era. As a production dependency on a current Laravel 10/11/12 stack, it is a poor fit regardless of the algorithm's merits.

Integration feasibility. Low for a modern stack, moderate for a legacy one. A Laravel 6-era app on PHP 7.x with an existing Redis connection could plausibly install, register the provider, and apply the limiter; the 1.1.1 release is a one-line Redis hdel fix, suggesting a small, contained codebase. A current app will likely fail dependency resolution against modern illuminate/* constraints and PHP 8.x, and even on a clean install there is no evidence of validation against PHP 8.1+, Redis 6/7, Redis Cluster, or newer rate-limiting contracts. The MIT license is the saving grace: the approach is freely adoptable even where the artifact is not. Feasibility here is less "can we install it" and more "can we own it" — and the second question gates the decision.

Technical risk. High. (1) Abandonment — no security response path and no maintainer to escalate a limiter-bypass report to; a rate limiter is a security control on the hot path of every request, so sourcing it archived is a category error. (2) Concurrency correctness — a sliding-window log must be atomic (check-and-record in one Redis round trip, typically Lua); nothing in the docs confirms the atomicity model, clock assumptions, or TTL behavior, and zero dependents means zero field corroboration. (3) Memory profile — a precise log stores one entry per request in a sorted set, O(limit) per key; at high limits and high key cardinality (per-tenant-per-route-per-IP) that is a material Redis memory and hot-shard risk requiring sizing before commitment. (4) Availability coupling — the limiter inherits Redis availability, and fail-open vs. fail-closed is a product decision with outage consequences either way. (5) Signal staleness — no issue trackers, no community trail, no shortcut to debugging.

Key questions.

  • Which Laravel and PHP versions must we support over the next 12–24 months?
  • What is the limiter for — abuse prevention, cost control, contractual SLA, or tenant fairness? That determines fail-open vs. fail-closed and the acceptable risk posture.
  • Is Redis already tier-0, and what is its topology — single primary, Sentinel, Cluster, managed?
  • Do we need distributed enforcement across regions, or only within one Redis primary?
  • What key cardinality and retention do we require, against what Redis memory budget?
  • Are Retry-After and X-RateLimit-* headers a customer-visible contract or internal hygiene?
  • Can we own a fork and its release process, with a named maintainer?
  • Has anyone reviewed the Lua/Redis logic for atomicity, clock skew, and TTL behavior?
  • Does Laravel's native Redis::throttle() — itself sorted-set based and effectively sliding — already clear the bar unaided?

Integration Approach

Stack fit. Adopt the package only in the narrow case of a legacy Laravel 5.8/6.x app on PHP 7.x with existing Redis and a bounded remaining lifespan, where a fork is cheaper than a rewrite. For anything modern the recommendation is borrow, don't buy: use the repository as a reference implementation and build a small internal limiter over Redis sorted sets, exposed through Laravel's own RateLimiter and middleware conventions. That preserves the behavioral benefit — smooth, burst-free throttling — while removing an unmaintained component from the request path.

Migration path. Do not install into production on faith.

  1. Spike first — a time-boxed install attempt in an isolated branch or container pinned to the exact Laravel, PHP, and Redis versions in use.
  2. Fork or vendor only if Composer resolves cleanly and integration tests pass; take explicit internal ownership with a named maintainer and a documented release process.
  3. Wrap behind an interface — an internal SlidingWindowLimiter contract — so middleware and route definitions never import the package directly and the implementation stays swappable.
  4. Shadow-mode on a low-traffic route, diffing decisions against current behavior before any enforcement change.
  5. Roll out behind a feature flag, route by route, with a documented rollback.

Compatibility. Three compatibility surfaces must be cleared explicitly, not assumed: framework/PHP version constraints against illuminate/* and 8.x runtime; Redis version and topology, including whether any Lua script's keys stay within a single hash slot under Cluster; and behavioral compatibility with the headers, reset semantics, and 429 body our SDKs and docs already promise. The 1.1.1 hdel fix is a reminder that this code was written against an older Redis client surface and carries latent assumptions.

Sequencing. Contract before code. (1) Decide rolling-window semantics for all published quotas and update API docs, SDK retry/backoff, and tier copy accordingly. (2) Decide fail-open vs. fail-closed and get an explicit product owner signature. (3) Run the spike comparing this algorithm against Redis::throttle() and a sliding-window-counter or token-bucket alternative on memory and latency. (4) Ship the internal middleware behind a flag. (5) Shadow, diff, then widen. Only revisit forking the package if the spike shows genuinely non-obvious value in the original code — the expected outcome is that it informs a ~one-day implementation rather than becoming a dependency.

Operational Impact

Maintenance. As a dependency: effectively unbounded, unpaid maintenance risk with no upstream. No patches for PHP 8.x deprecations, no Laravel 12 compat, no Redis 7 behavior changes, no security fixes — and a rate limiter is exactly the class of component where a bypass defect requires a same-week patch. As a borrowed algorithm: a small, owned middleware with normal code review and a test suite. Price the fork explicitly (named owner, release process, CVE intake path) if anyone argues for the dependency; the honest number usually kills the argument.

Support. Zero upstream support, zero community corpus, zero dependents to consult. Internal support load is dominated not by the code but by the experience of throttling: boundary behavior, Retry-After accuracy, and reset semantics drive "why am I being throttled?" tickets. Sliding-window smoothing tends to reduce these relative to fixed windows, but only if the documented contract matches the enforced behavior — fuzzy reset semantics manufacture retry storms, and retry storms look like an outage to customers and to downstream vendors.

Scaling. Two axes. Key space: O(limit) storage per key means memory scales with limit × cardinality; per-tenant-per-route-per-IP keys multiply fast, so define granularity, TTLs, and eviction (ZREMRANGEBYSCORE) deliberately and watch hot shards. Topology: single Redis primary is fine until cross-region enforcement or multi-service sharing is required — at which point this moves to a gateway (Envoy, Kong, Cloudflare, or a policy service) and this package has nothing to offer. Plan the graduation point before traffic forces it.

Failure modes. (1) Redis unavailable — fail-open turns the limiter into a no-op during a cache blip (cost and abuse exposure); fail-closed turns a cache blip into a full outage. Pick one, document it, and state it in the customer-facing contract. (2) Non-atomic check-and-record — race conditions under concurrency admit over-limit traffic, a silent control failure with no error signal. (3) Clock skew across app nodes — inconsistent window boundaries and wrong reset times. (4) Memory exhaustion / hot shard — latency spikes or eviction of unrelated cache keys. Each needs a metric and a dashboard before rollout: limiter p50/p99 latency, 429 rate by tenant, and Redis memory by key prefix.

Ramp-up. Low for the code, moderate for the decision surface. An engineer can read the algorithm in an hour; the organization needs alignment on window semantics, header contract, key granularity, and failure policy — and those are the items that actually take calendar time. Recommended resourcing: a one-day spike plus a modest middleware with concurrency and Redis-outage tests, owned by one named engineer, gated on product signing off on the contract and the failure-mode policy. Net TPM position: use this repository as a design input and a stakeholder-education artifact, not as a dependency — it makes the sliding-window trade-off concrete and cheap to adopt correctly, while the archived status, zero dependents, and 2019 vintage make taking it as a dependency indefensible on a modern stack.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core