nginx load balance
am 28.06.2008 15:48:45 von peng.kyo
Hello,
We have some modperl application servers.
Follow the suggestion on this list, I will use a nginx in front of
them to do the load balance.
But I have a question, does nginx support for session-keeping?
A user's request, should go always to the same original backend server.
Otherwise the user's session will get lost.
Thanks!
--
Regards,
Jeff. - Peng.Kyo@gmail.com
Re: nginx load balance
am 28.06.2008 16:14:10 von bharanee rathna
http://wiki.codemongers.com/NginxHttpUpstreamModule
IP hash based distribution is probably what you want
On 6/28/08, Jeff Peng wrote:
> Hello,
>
> We have some modperl application servers.
> Follow the suggestion on this list, I will use a nginx in front of
> them to do the load balance.
> But I have a question, does nginx support for session-keeping?
> A user's request, should go always to the same original backend server.
> Otherwise the user's session will get lost.
>
> Thanks!
>
> --
> Regards,
> Jeff. - Peng.Kyo@gmail.com
>
Re: nginx load balance
am 28.06.2008 16:20:38 von peng.kyo
On Sat, Jun 28, 2008 at 10:14 PM, wrote:
> http://wiki.codemongers.com/NginxHttpUpstreamModule
>
> IP hash based distribution is probably what you want
Thanks.Source IP hash sounds a possible way.
But, if user's gateway (for local network) has a IP pool, it means the
first time user's request was outgoing with IP 11.11.11.11, but next
time the request maybe will go out with IP 22.22.22.22.
How about this case?
--
Regards,
Jeff. - Peng.Kyo@gmail.com
Re: nginx load balance
am 29.06.2008 04:03:20 von bharanee rathna
If you're looking for cookie based session affinity, i suggest you
also look at apache+mod_proxy.
You can specify 'stickysession' which is the name of the cookie or
request param used for session.
Cheers,
Bharanee
Re: nginx load balance
am 29.06.2008 09:06:04 von Yuri Pats
nginx as a light http\smtp server. It does not do any specific request
logic - it specially designed to minimize request cycle times.
On Sun, Jun 29, 2008 at 5:03 AM, wrote:
> You can specify 'stickysession' which is the name of the cookie or
> request param used for session.
>
That's right!
--
WBR, Yuri Pac
Re: nginx load balance
am 29.06.2008 22:50:58 von Perrin Harkins
On Sat, Jun 28, 2008 at 9:48 AM, Jeff Peng wrote:
> But I have a question, does nginx support for session-keeping?
> A user's request, should go always to the same original backend server.
> Otherwise the user's session will get lost.
I would advise you not to do this. It's a non-scalable design. If
you need to keep session data beyond what will fit in an encrypted
cookie, you'd be better off storing it in a shared database. That
way, if you lose one of your web servers, the session won't get lost.
- Perrin
Re: nginx load balance
am 30.06.2008 09:18:15 von James Smith
On Sun, 29 Jun 2008, Perrin Harkins wrote:
> On Sat, Jun 28, 2008 at 9:48 AM, Jeff Peng wrote:
>> But I have a question, does nginx support for session-keeping?
>> A user's request, should go always to the same original backend server.
>> Otherwise the user's session will get lost.
>
> I would advise you not to do this. It's a non-scalable design. If
> you need to keep session data beyond what will fit in an encrypted
> cookie, you'd be better off storing it in a shared database. That
> way, if you lose one of your web servers, the session won't get lost.
I would consider using a shared memory solution to save traffic too
from the database server (consider a solution based on memcached??)...
I would be very careful about going back to a single machine for each
request - due to traffic profiles (when a user makes a request there
is a "spike" of requests from the session - all these then get handled
by one machine and not load balanced)...
--
The Wellcome Trust Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.
Re: nginx load balance
am 30.06.2008 14:43:37 von Perrin Harkins
On Mon, Jun 30, 2008 at 3:18 AM, James Smith wrote:
> I would consider using a shared memory solution to save traffic too
> from the database server (consider a solution based on memcached??)...
No, don't use memcached for sessions. It's a cache, not a database.
It trades reliability for speed.
- Perrin
Re: nginx load balance
am 30.06.2008 17:00:46 von peng.kyo
Thanks for all.
what's the standard module for storing sessions in a database?
On Mon, Jun 30, 2008 at 8:43 PM, Perrin Harkins wrote:
> On Mon, Jun 30, 2008 at 3:18 AM, James Smith wrote:
>> I would consider using a shared memory solution to save traffic too
>> from the database server (consider a solution based on memcached??)...
>
> No, don't use memcached for sessions. It's a cache, not a database.
> It trades reliability for speed.
--
Regards,
Jeff. - Peng.Kyo@gmail.com
Re: nginx load balance
am 30.06.2008 17:07:09 von Perrin Harkins
On Mon, Jun 30, 2008 at 11:00 AM, Jeff Peng wrote:
> what's the standard module for storing sessions in a database?
I recommend CGI::Session.
- Perrin
Re: nginx load balance
am 30.06.2008 17:09:23 von peng.kyo
On Mon, Jun 30, 2008 at 11:07 PM, Perrin Harkins wrote:
> On Mon, Jun 30, 2008 at 11:00 AM, Jeff Peng wrote:
>> what's the standard module for storing sessions in a database?
>
> I recommend CGI::Session.
>
Yes, currently I'm also using CGI::Session.
How about Apache::Session? Is it more efficient under modperl?
--
Regards,
Jeff. - Peng.Kyo@gmail.com
Re: nginx load balance
am 30.06.2008 17:12:08 von Perrin Harkins
On Mon, Jun 30, 2008 at 11:09 AM, Jeff Peng wrote:
> How about Apache::Session? Is it more efficient under modperl?
No, it's about the same, and CGI::Session is better maintained. Don't
be fooled by the name: CGI::Session works well with mod_perl.
- Perrin