PHPackages                             ltxiong/flowlimiter - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ltxiong/flowlimiter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ltxiong/flowlimiter
===================

自定义的接口限流类

131PHP

Since Jul 26Pushed 5y agoCompare

[ Source](https://github.com/ltxiong/flowlimiter)[ Packagist](https://packagist.org/packages/ltxiong/flowlimiter)[ RSS](/packages/ltxiong-flowlimiter/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

接口限流器实现
=======

[](#接口限流器实现)

参考：[https://blog.csdn.net/zzti\_erlie/article/details/105438501](https://blog.csdn.net/zzti_erlie/article/details/105438501)

实现全部依赖redis，并且依赖redis单实例 优化：可以引入锁方案对操作进行加锁处理避免并发造成数据不一致，由于接口限流器并不需要严格的数据准确，加锁不加锁影响不大，所以暂时没加

基于Redis实现的计数器算法 业务限流器 实现原理：将时间片切分成足够细的粒度，通过时间窗口流动的方式来动态实现最近的N时间段内可容纳的流量

漏桶算法实现的接口限流器(控制粒度到秒级别，也就是控制每秒流量) 数据被填充到桶中,并以固定速率注入网络中,而不管数据流的突发性，如桶是空的,不做任何事情 主机在每一个时间片向网络注入一个数据包,因此产生一致的数据流

令牌桶算法实现的接口限流器(需要定时任务定时调用令牌桶添加函数添加令牌) 实现原理：定时往令牌桶当中添加固定数量的数据，业务从令牌桶获取数据，取到数据就进行业务处理，获取不到数据业务就不处理 可以通过redis incrBy decr 来实现，也可以通过redis队列来实现 1、如通过redis incrBy decr来实现，每次添加时通过 incrBy往令牌桶添加数据，获取数据时，每次通过decr减少数据，直到decr减少到0为止 2、通过redis队列来实现，每次往队列添加固定个数的数据，获取数据时，每次通过pop减少队列数据，直到pop不出数据为止

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/cae23c579f0cf281de5fb6c4211e35276706a020721e6863a6bc52d275e55ddc?d=identicon)[ltxiong2020](/maintainers/ltxiong2020)

---

Top Contributors

[![ltxiong](https://avatars.githubusercontent.com/u/7168001?v=4)](https://github.com/ltxiong "ltxiong (10 commits)")

### Embed Badge

![Health badge](/badges/ltxiong-flowlimiter/health.svg)

```
[![Health](https://phpackages.com/badges/ltxiong-flowlimiter/health.svg)](https://phpackages.com/packages/ltxiong-flowlimiter)
```

###  Alternatives

[jordanmiguel/laravel-popular

A Laravel package to track popularity of entries(by Models) in a website at a certain time.

659.6k1](/packages/jordanmiguel-laravel-popular)[jaaulde/php-ipv4

PHP classes for working with IPV4 addresses and networks.

1034.6k](/packages/jaaulde-php-ipv4)[ip2location/ip2location-cakephp

Lookup for visitor's IP information, such as country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation and usage type.

224.6k](/packages/ip2location-ip2location-cakephp)

PHPackages © 2026

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