You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jeff Peng <pe...@gmail.com> on 2008/06/28 15:48:45 UTC

nginx load balance

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

Posted by Perrin Harkins <pe...@elem.com>.
On Mon, Jun 30, 2008 at 11:09 AM, Jeff Peng <pe...@gmail.com> 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

Re: nginx load balance

Posted by Jeff Peng <pe...@gmail.com>.
On Mon, Jun 30, 2008 at 11:07 PM, Perrin Harkins <pe...@elem.com> wrote:
> On Mon, Jun 30, 2008 at 11:00 AM, Jeff Peng <pe...@gmail.com> 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

Posted by Perrin Harkins <pe...@elem.com>.
On Mon, Jun 30, 2008 at 11:00 AM, Jeff Peng <pe...@gmail.com> wrote:
> what's the standard module for storing sessions in a database?

I recommend CGI::Session.

- Perrin

Re: nginx load balance

Posted by Jeff Peng <pe...@gmail.com>.
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 <pe...@elem.com> wrote:
> On Mon, Jun 30, 2008 at 3:18 AM, James Smith <js...@sanger.ac.uk> 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

Posted by Perrin Harkins <pe...@elem.com>.
On Mon, Jun 30, 2008 at 3:18 AM, James Smith <js...@sanger.ac.uk> 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

Posted by James Smith <js...@sanger.ac.uk>.

On Sun, 29 Jun 2008, Perrin Harkins wrote:

> On Sat, Jun 28, 2008 at 9:48 AM, Jeff Peng <pe...@gmail.com> 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

Posted by Perrin Harkins <pe...@elem.com>.
On Sat, Jun 28, 2008 at 9:48 AM, Jeff Peng <pe...@gmail.com> 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

Posted by Yuri Pac <yu...@gmail.com>.
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,  <de...@gmail.com> 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

Posted by de...@gmail.com.
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

Posted by Jeff Peng <pe...@gmail.com>.
On Sat, Jun 28, 2008 at 10:14 PM,  <de...@gmail.com> 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

Posted by de...@gmail.com.
http://wiki.codemongers.com/NginxHttpUpstreamModule

IP hash based distribution is probably what you want

On 6/28/08, Jeff Peng <pe...@gmail.com> 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
>