Feature #804
closedSticky option for FastCGI load balancing
Description
Many web applications achieve a significant boost in speed by caching data, such as user session info. To take maximum advantage of caching on the backend, many commercial load balancers have an optional 'sticky' flag which causes connections coming from the same outside ip to forward to the same backend server. By going to the same backend server, there is an improved chance that the backend server will have cached data capable of greatly improving response time.
Applying that same concept to FastCGI, significant speed gains could be made in situations when the backend process is written to cache user data. Sending the same browser to the same backend FastCGI process, as opposed to just the 'least busy' one at the top of the list may actually give better much performance in the (common) case where the backend process is slow on new connections but fast on repeat connections because of internal caching. It would be nice if Lighty's FastCGI load balancing feature had a sticky flag that could be used to implement this.
Determining which backend process to send to could be done simply by client ip at first, but would be best if augmented with a session cookie or some other session/auth tracking system at the web server level, think along the lines of Apache's mod_usertrack. (Actually this would probably be just the tip of the iceberg of what could be done by combining mod_auth with mod_usertrack.)
-- mdepot
Updated by Anonymous over 17 years ago
hi,
are you planning to implement this feature? i'm very interested in using lighty, but i need sticky sessions.
if not, is there a patch or workaround out there?
thanks,
francisco
-- francisco.treacy
Updated by Anonymous about 17 years ago
I need to cache sessions in memory, so it's essential for me. Guys from fastcgi mention something called "session affinity" but I haven't seen it implemented. Even mod_fastcgi for Apache doesn't have it :-(
If I'm right code for selecting the responder it in mod_fastcgi_handle_subrequest function (somewhere near source:tags/lighttpd-1.4.18/src/mod_fastcgi.c, line 3049), so I guess I'm gonna try to add some kind of cookie hashing there...
-- khornik
Updated by stbuehler over 16 years ago
- Status changed from New to Fixed
- Resolution set to wontfix
I don't think we will implement this in 1.4 (perhaps in 1.5); but your application should never rely on this. Use memcached or some other db...
Updated by Anonymous over 16 years ago
The whole point is to avoid any object serialization (which is difficult in C++) and keep everything in memory.
Right now I'm using
http://wiki.codemongers.com/NginxHttpUpstreamRequestHashModule
http://hg.mperillo.ath.cx/nginx/mod_parsed_vars
And it works like a charm. Unfortunately both need patching nginx.
-- khornik
Updated by gstrauss over 1 year ago
- Description updated (diff)
- Status changed from Wontfix to Fixed
- ASK QUESTIONS IN Forums set to No
fastcgi.balance
was added in lighttpd 1.4.46
load-balancing algorithm for backends ("fair", "least-connection", "round-robin", "hash", or "sticky")
Also available in: Atom