[nginx] new upstream module // sticky cookies
Jérôme Loyet
jerome at loyet.net
Sat Jun 5 20:58:02 MSD 2010
Hi nginx dev,
for internal need, I wrote an upstream module which use a sticky
cookie to ensure a client is always sent to the same backend server.
All the loadbalancing intelligence stays in the
ngx_http_upstream_round_robin.c part of nginx core.
You can see the simple general algorithm in the following diagramm
http://nginx-sticky-module.googlecode.com/svn/trunk/docs/sticky.pdf
If you have time, can you review the code and see if I'm not doing
some stuff senselessly ?
Usage
upstream {
sticky;
server 127.0.0.1:9000;
server 127.0.0.1:9001;
server 127.0.0.1:9002;
}
sticky [name=route] [domain=.foo.bar] [path=/] [expires=1h];
- name: the name of the cookies used to track the persistant
upstream server
Default: route
- domain: the domain in which the cookie will be valid
Default: nothing. Let the browser handle this.
- path: the path in which the cookie will be valid
Default: nothing. Let the browser handle this.
- expires: the validity duration of the cookie
Default: nothing. It's a session cookie.
Restriction: must be a duration greater than one second
You can try it by downloading the version 1.0-rc1 at
http://code.google.com/p/nginx-sticky-module/downloads/detail?name=nginx-sticky-module-1.0-rc1.tar.gz&can=2&q=
The project page is: http://code.google.com/p/nginx-sticky-module/
Thx
++ Jerome
More information about the nginx-devel
mailing list