iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
To keep Laravel jobs within an external API’s quota, define a named limiter with RateLimiter::for and attach Laravel’s RateLimited queue middleware to each job that uses it. The limiter key must match the quota the provider actually enforces: use one shared key when jobs share a credential-wide cap, or separate keys when quotas are genuinely independent. The middleware delays work that reaches the limit, but it does not guarantee fair scheduling across queues or worker pools.
How Laravel rate limiting works for queued jobs
Laravel lets you register a named rate limiter and apply it to a queued job through middleware. The limiter controls how many jobs can proceed under a given key during a defined period. When the limit is reached, RateLimited releases the job back to the queue so it can run later.
The framework’s official Laravel 13.x queue documentation notes an important consequence: “Releasing a rate limited job back onto the queue will still increment the job’s total number of attempts.” A job may therefore run out of attempts while waiting for its quota window to reopen.
Define the limiter around the provider’s actual quota
Register the limiter in a service provider. The key passed to by() determines which jobs share a bucket. Laravel’s documentation demonstrates per-customer keys; for an upstream limit shared by every request made with one API credential, use a shared credential or account key instead.
#1 Best Overall
use IlluminateCacheRateLimitingLimit;
use IlluminateSupportFacadesRateLimiter;
RateLimiter::for('partner-api', function (object $job) {
return Limit::perMinute(50)->by($job->account->id);
});
The 50-per-minute value above is an illustrative framework example, not a recommended limit for any particular API. Set the window and allowance to match the provider’s documented quota. If several job classes use the same provider quota, have them use the same limiter key; otherwise, separately keyed jobs could collectively exceed a cap that the provider applies to their shared credential.
Attach the limiter to the relevant job
Return the middleware from the job’s middleware() method. Only jobs that should consume this quota need this limiter.
use IlluminateQueueMiddlewareRateLimited;
public function middleware(): array
{
return [new RateLimited('partner-api')];
}
Set a release delay and a retry budget
When a job hits the limit, Laravel releases it instead of allowing it to proceed. By default, the middleware uses a delay based on the limiter duration; you can set a fixed delay with releaseAfter(seconds). Laravel also offers dontRelease() for cases where a job that hits the limit should not be retried. Choose that only when dropping that work is intentional.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Because each release increments the attempt count, configure the job’s retry policy for the longest realistic time it may have to wait. Laravel documents the use of tries, MaxExceptions, and retryUntil for managing job retries. A time-based cutoff with retryUntil can be a better fit when waiting through a provider’s throttling window matters more than limiting the number of releases.
Rank #3
A fixed delay is not automatically the same as the API’s reset time. Check the provider’s quota and response behavior; Laravel’s middleware documentation describes its delay options but does not prescribe how to interpret a particular provider’s Retry-After response.
Choose the middleware that matches the problem
| Option | Use it for | Consider |
|---|---|---|
RateLimited |
Enforcing a named rate limit with Laravel’s general middleware. | Cache configuration, quota-sharing key, release delay, and retry budget. |
RateLimitedWithRedis |
Rate-limited jobs in a Redis-based deployment. | Confirm the Redis setup and intended connection. Laravel describes this middleware as more efficient than the basic option. |
WithoutOverlapping |
Preventing concurrent jobs from acting on the same keyed resource. | Set the lock key and expiration deliberately; overlapping jobs that are released also consume attempts. This middleware does not enforce a requests-per-window quota. |
Rate limiting and overlap prevention address different risks. Use RateLimited to control the rate at which jobs consume a quota; use WithoutOverlapping when only one job should operate on a resource at a time. They can be combined when both constraints apply.
Rank #4
Prevent one delayed workload from holding up others
A delay controls when a rate-limited job becomes eligible to run again; it is not a fairness guarantee. Laravel documents rate-limit enforcement, releases, and attempt behavior, but does not promise that unrelated jobs, queues, or worker pools will be scheduled fairly.
If your deployment needs isolation between a heavily throttled integration and other work, address that in queue topology and worker allocation. For example, route that integration’s jobs to a dedicated queue and assign workers according to your operational needs. That separation can prevent its backlog from competing in the same queue, but it is a deployment choice—not a guarantee supplied by the rate-limit middleware.
Quick Recap
Best Value
Diagnose common configuration mistakes
- Jobs exceed the provider’s shared cap: Check whether each job class or job instance has its own limiter key. If the provider applies one cap to a shared credential, those jobs need a shared key.
- Jobs fail while waiting: Review the attempt limit and release frequency. Repeated releases consume attempts, so increase or otherwise adjust the retry budget, or use a suitable
retryUntilboundary. - Jobs retry sooner or later than expected: Check the limiter duration and any custom
releaseAfterdelay against the provider’s quota window. Do not assume Laravel automatically honors a provider-specificRetry-Aftervalue. - Exceptions are being treated as quota limits:
RateLimitedenforces a defined rate limit.ThrottlesExceptionshandles repeated exceptions. They respond to different conditions, though an application may need both. - One job must not overlap another: Add
WithoutOverlappingwith a key for the protected resource, and account for its lock expiration and the attempts consumed when jobs are released.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

