PHPackages                             otzy/intensity-throttle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. otzy/intensity-throttle

ActiveLibrary

otzy/intensity-throttle
=======================

limits the rate of event of any kind using leaky bucket algorithm

v1.0.0(9y ago)0251MITPHPPHP &gt;=5.6.0

Since Jul 19Pushed 9y ago1 watchersCompare

[ Source](https://github.com/otzy/IntensityThrottle)[ Packagist](https://packagist.org/packages/otzy/intensity-throttle)[ RSS](/packages/otzy-intensity-throttle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (1)

\#IntensityThrottle

With IntensityThrottle package you can easily limit the rate of events of any kind. For example you can keep an eye on the rate of requests to your servers or the rate of errors in cron jobs.

IntensityThrottle implements [Leaky Bucket](https://en.wikipedia.org/wiki/Leaky_bucket) algorithm, which means that you are able to set not only bandwidth, but burstiness as well. That is to say, short spikes in the event rate are possible.

Due to the nature of php, the leakage happens not on regular basis (not continuously), but at the moment when an event is being handled. This changes the behavior of buckets a bit, but in the end they do their job.

\##Usage

Package comes with InProcessStorage, which can be used when you need to limit events in the single process, for example in a long running cron job:

```
use Otzy\Intensity\InProcessStorage;
use Otzy\Intensity\IntensityThrottle;

//Create throttle
$throttle = new IntensityThrottle('test', new InProcessStorage());

//add leaky bucket to the throttle. You can add so many buckets as you wish
$max_drops = 3; //this is a backet volume
$time_span = 1; //how long it takes to get bucket empty

//add a bucket
$throttle->addLimit($max_drops, $time_span)

//simulate events
$start = microtime(true);
for ($i = 0; $i < 100; $i++) {

    //Register event. If buckets get overflowed, the method drip() returns false. If there is still space in them, it returns true
    $drip_result = $throttle->drip();

    if ($drip_result === false) {
        printf("Throttle Test: Drops limit exceeded after %.3f seconds.", (microtime(true) - $start));
        return;
    }

    usleep(250000);
}

```

If you want to throttle web requests or any other events across different requests and/or servers, you should use memcached server. You can use Memcached class directly as a storage:

```
$memcached = new \Memcached();
$memcached->addServer('localhost', 11211);
$throttle = new IntensityThrottle('test', $memcached);

```

\##Bucket volume

`$throttle->addLimit($max_drops, $time_span)` adds a bucket with volume=$max\_drops.

At first glance, `$throttle->addLimit(3, 1)` and `$throttle->addLimit(6, 2)` are the same. The second bucket has twice bigger volume and twice higher leakage rate. So if the average rate of incoming events will be 3 events/second, both buckets will not overflow.

The difference is that second bucket is capable to support a higher burstiness rate, i.e. temporary unevenness in the event flow.

The example above (with bucket volume = 3) will stop after 2.255 seconds. If you replace `$throttle->addLimit(3, 1)` with `$throttle->addLimit(6, 2)`, the script will stop after 5.26 seconds.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3582d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0c099a6f8226ab9a048ee4d768ddc4645115c796cf1680c00992a3a8ddb387cf?d=identicon)[otzy](/maintainers/otzy)

---

Tags

throttleintensityleaky bucket

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/otzy-intensity-throttle/health.svg)

```
[![Health](https://phpackages.com/badges/otzy-intensity-throttle/health.svg)](https://phpackages.com/packages/otzy-intensity-throttle)
```

###  Alternatives

[graham-campbell/throttle

Throttle Is A Rate Limiter For Laravel

7102.3M11](/packages/graham-campbell-throttle)[davedevelopment/stiphle

Simple rate limiting/throttling for php

2567.7M9](/packages/davedevelopment-stiphle)[bandwidth-throttle/token-bucket

Implementation of the Token Bucket algorithm.

5121.9M10](/packages/bandwidth-throttle-token-bucket)[maba/gentle-force-bundle

Symfony bundle that integrates gentle-force library for limiting both brute-force attempts and ordinary requests, using leaky/token bucket algorithm, based on Redis

53517.6k1](/packages/maba-gentle-force-bundle)[maba/gentle-force

Library for limiting both brute-force attempts and ordinary requests, using leaky/token bucket algorithm, based on Redis

45591.0k2](/packages/maba-gentle-force)[clue/mq-react

Mini Queue, the lightweight in-memory message queue to concurrently do many (but not too many) things at once, built on top of ReactPHP

144691.7k4](/packages/clue-mq-react)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
