]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6269
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 15 Sep 2023 08:33:23 +0000 (10:33 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 15 Sep 2023 08:33:23 +0000 (10:33 +0200)
app/Fluidbook/HostingLoadBalancer.php

index 71bc3f7c7f10c837b3e10708517c6f53795e63dc..ed7afc551887717f79fb45b650f9141de1403476 100644 (file)
@@ -7,8 +7,9 @@ use Cubist\Util\Files\Files;
 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()
@@ -61,7 +62,9 @@ class HostingLoadBalancer
 
             $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));