(Translated by https://www.hiragana.jp/)
GitHub - Tinywan/load-balancing: Implementing several load balancing scheduling algorithms with PHP - 用 PHP 实现几种负载均衡调度算法
Skip to content

Implementing several load balancing scheduling algorithms with PHP - よう PHP 实现几种负载均衡きんこう调度算法さんぽう

Notifications You must be signed in to change notification settings

Tinywan/load-balancing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction(かい绍)

よう PHP 实现几种负载均衡きんこう调度算法さんぽう,详细见 负载均衡きんこう算法さんぽう 系列けいれつfork

Scheduling Algorithm (调度算法さんぽう

Install

composer require tinywan/load-balancing

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 <= $sumWeight; $i++) {
    $node = $robin->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

About

Implementing several load balancing scheduling algorithms with PHP - よう PHP 实现几种负载均衡きんこう调度算法さんぽう

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages