PHPackages                             tinywan/load-balancing - 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. tinywan/load-balancing

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

tinywan/load-balancing
======================

This nginx load balancing for build composer packagist

v1.0.0(7y ago)4927113MITPHPPHP &gt;=7.0.0

Since Jan 23Pushed 5y ago2 watchersCompare

[ Source](https://github.com/Tinywan/load-balancing)[ Packagist](https://packagist.org/packages/tinywan/load-balancing)[ Docs](https://www.tinywan.com/)[ RSS](/packages/tinywan-load-balancing/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

### Introduction（介绍）

[](#introduction介绍)

用 PHP 实现几种负载均衡调度算法，详细见 [负载均衡算法](https://www.fanhaobai.com/2018/11/load-balance-round-robin.html) 系列。[fork](https://github.com/fan-haobai/load-balance)

### Scheduling Algorithm （调度算法）

[](#scheduling-algorithm-调度算法)

- [普通轮询（general Round Robin）](https://github.com/Tinywan/load-polling/blob/master/src/Robin.php)
- [加权轮询（Weighted Round Robin）](https://github.com/Tinywan/load-polling/blob/master/src/WeightedRobin.php)
- [平滑加权轮询（Smooth Weighted Round Robin）](https://github.com/Tinywan/load-polling/blob/master/src/SmoothWeightedRobin.php)

### Install

[](#install)

```
composer require tinywan/load-balancing

```

### Basic Usage

[](#basic-usage)

```
// 服务器数
$services = [
    '192.168.10.1' => 5,
    '192.168.10.2' => 1,
    '192.168.10.3' => 1,
];

// 使用平滑加权算法 (Smooth Weighted Round Robin)
$robin = new \Robin\SmoothWeightedRobin();
$robin->init($services);

$nodes = [];
$sumWeight = $robin->getSumWeight();
for ($i = 1; $i next();
    $nodes[$i] = $node;
}
var_export($nodes);

// 会生成如下均匀序列
array (
  1 => '192.168.10.1',
  2 => '192.168.10.1',
  3 => '192.168.10.2',
  4 => '192.168.10.1',
  5 => '192.168.10.3',
  6 => '192.168.10.1',
  7 => '192.168.10.1',
)
```

### Help

[](#help)

- [负载均衡算法](https://github.com/fan-haobai/load-balance)
- [负载均衡算法 — 轮询](https://www.fanhaobai.com/2018/11/load-balance-round-robin.html)
- [负载均衡算法 — 平滑加权轮询](https://www.fanhaobai.com/2018/11/load-balance-smooth-weighted-round-robin.html)
- [Nginx的负载均衡 - 加权轮询 (Weighted Round Robin) 上篇](https://blog.csdn.net/zhangskd/article/details/50194069)
- [Nginx的负载均衡 - 加权轮询 (Weighted Round Robin) 下篇](https://blog.csdn.net/zhangskd/article/details/50197929)
- [Composer/Packagist包](https://www.chenjie.info/1880)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2718d ago

### Community

Maintainers

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

---

Top Contributors

[![Tinywan](https://avatars.githubusercontent.com/u/14959876?v=4)](https://github.com/Tinywan "Tinywan (15 commits)")

---

Tags

nginx-load-balancenginx-upstreamphp7pollingrobinrobin-panel

### Embed Badge

![Health badge](/badges/tinywan-load-balancing/health.svg)

```
[![Health](https://phpackages.com/badges/tinywan-load-balancing/health.svg)](https://phpackages.com/packages/tinywan-load-balancing)
```

###  Alternatives

[metadrop/drupal-updater

Update drupal project dependencies

2682.2k1](/packages/metadrop-drupal-updater)

PHPackages © 2026

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