28 Jan 12:12
Static load balancer
From: Uwe Voelker <uwe.voelker <at> gmx.de>
Subject: Static load balancer
Newsgroups: gmane.comp.web.lighttpd
Date: 2007-01-28 11:16:14 GMT
Subject: Static load balancer
Newsgroups: gmane.comp.web.lighttpd
Date: 2007-01-28 11:16:14 GMT
Hello,
please consider the following situation:
I have a dynamic web application (served by lighty over fast_cgi or
reverse proxy) which is distributed over 2 hosts (IP A and B). The
selection between them is done by round robin dns. It is done for
reliability reasons (not performance problems).
When deploying a new version I need to reastart the fast_cgi process (or
application web server). In this time there would be an error (502 bad
gateway in case of the proxy). So I would like to set up this:
Host A:
$HTTP["url"] =~ "^/" {
proxy-core.protocol = "http"
proxy-core.balancer = "static"
proxy-core.backends = (
"A:3000",
"B:3000",
)
proxy-core.max-pool-size = 16
}
Host B:
$HTTP["url"] =~ "^/" {
proxy-core.protocol = "http"
proxy-core.balancer = "static"
proxy-core.backends = (
"B:3000",
"A:3000",
)
proxy-core.max-pool-size = 16
}
So it sould only jump to the "other" (remote) host, when the local host
is not available (due to a restart or whatever).
Can this behaviour achieved with the existing load balancers? I thought
not, and wrote a very simple static load balancer (feel free to rename
it). It works as expected.
Does this make sense? Can this (or some other solution) please be
included in lighty?
Thanks, a lot.
Bye, Uwe
Index: src/mod_proxy_core_backend.h
===================================================================
--- src/mod_proxy_core_backend.h (Revision 1537)
+++ src/mod_proxy_core_backend.h (Arbeitskopie)
@@ -28,7 +28,8 @@
PROXY_BALANCE_UNSET,
PROXY_BALANCE_SQF,
PROXY_BALANCE_CARP,
- PROXY_BALANCE_RR
+ PROXY_BALANCE_RR,
+ PROXY_BALANCE_STATIC
} proxy_balance_t;
typedef struct {
Index: src/mod_proxy_core.c
===================================================================
--- src/mod_proxy_core.c (Revision 1537)
+++ src/mod_proxy_core.c (Arbeitskopie)
@@ -73,6 +73,7 @@
array_insert_int(p->possible_balancers, "sqf", PROXY_BALANCE_SQF);
array_insert_int(p->possible_balancers, "carp", PROXY_BALANCE_CARP);
array_insert_int(p->possible_balancers, "round-robin", PROXY_BALANCE_RR);
+ array_insert_int(p->possible_balancers, "static", PROXY_BALANCE_STATIC);
p->proxy_register_protocol = mod_proxy_core_register_protocol;
@@ -1483,6 +1484,19 @@
}
break;
+ case PROXY_BALANCE_STATIC:
+ /* static (only fail-over) */
+
+ for (i = 0; i < address_pool->used; i++) {
+ cur_address = address_pool->ptr[i];
+
+ if (cur_address->state != PROXY_ADDRESS_STATE_ACTIVE) continue;
+
+ address = cur_address;
+ break;
+ }
+
+ break;
case PROXY_BALANCE_SQF:
/* shortest-queue-first balancing */
RSS Feed