---
title: "Jitter — HTTP Client Rate Limits for Laravel | Roundly"
description: "Add random extra wait so a fleet of workers doesn’t wake up in lockstep — never less than the real wait; inject the randomness for tests."
url: https://roundly-consulting.com/open-source/docs/http-client-rate-limits-for-laravel/jitter
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[HTTP Client Rate Limits for Laravel](https://roundly-consulting.com/open-source/docs/http-client-rate-limits-for-laravel.md)

# Jitter

Add randomised jitter to defers so many workers don’t all wake at the same instant:

```php
Http::rateLimit(RateLimits::perMinute(30)->jitter(50)) // waits 0–50ms longer than needed
    ->get('https://api.example.com/orders');
```

Jitter only applies when a request actually has to wait, and it only ever adds: a random 0 to jitter milliseconds lands on top of the real delay, so a request never goes out before its window has room. On a compound limit the widest jitter of any window applies. In a named profile, use the jitter key (milliseconds).

## Deterministic tests

The randomness source is the injectable Randomizer contract (the default RandomRandomizer uses random\_int). Swap it on the Limiter for deterministic tests:

```php
use RoundlyConsulting\HttpClientRateLimits\Facades\RateLimits;
use RoundlyConsulting\HttpClientRateLimits\Jitter\Randomizer;

$limit = RateLimits::perSecond(1)->jitter(50);

// Always add the full +50ms so waits are deterministic in a test.
$limit->getLimiter()->setRandomizer(new class implements Randomizer {
    public function between(int $min, int $max): int
    {
        return $max;
    }
});
```

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/http-client-rate-limits-for-laravel.md)
