class HostingLoadBalancer
{
protected static $_servers = [
- ['name' => 's1', 'host' => 's1.lb.fluidbook.com'],
- ['name' => 's2', 'host' => 's2.lb.fluidbook.com'],
+ ['name' => 's1', 'host' => 's1.lb.fluidbook.com', 'weight' => 2],
+ ['name' => 's2', 'host' => 's2.lb.fluidbook.com', 'weight' => 1],
+ ['name' => 's3', 'host' => 's3.lb.fluidbook.com', 'weight' => 1],
];
protected static function _pingCache()
$pings[$id] = $ok;
if ($ok) {
- $available[] = $server['host'];
+ for ($i = 0; $i < $server['weight']; $i++) {
+ $available[] = $server['host'];
+ }
}
}
file_put_contents($cache, json_encode($pings));