keepalive and workers

Michał Jaszczyk jasiu85 at
Mon Jul 7 16:55:13 MSD 2008

2008/7/7 Manlio Perillo <manlio_perillo at>:
> Michał Jaszczyk ha scritto:
>> Hi,
>> I'm creating a website with Nginx and have some questions. When a user
>> comes with a request, my application server has to connect to many
>> other servers in order to create the response. Due to separation of
>> concerns pattern, application server and all other servers are
>> separate HTTP servers, each built with Nginx.
> So you have the main frontend server, with mod_proxy to N backend servers,
> and then each backend connects to M other servers?

Nope, I have the following layout:
- HAProxy LB
- several app servers Nginx+mod_wsgi
- several 'backend' servers Nginx+mod_wsgi
- each app server needs to retrieve information from each backend in
order to render response

'Backend' in this context means that it provides some kind of
information (for example what ads to display where on a page). App
server in order to render the page needs to contact several 'backends'
of this kind. The reason for such layout is that my company will
perhaps buy some software to do the ads stuff. So when I have these
'backends', I keep my layout modular.

And the question is: Can I keep a connection in the python app in the
app server to the 'backend' server in order to improve performance
(i.e. omit unnecessary tcp handshakes)? How will the connections from
all app servers to a particular 'backend' be spread between its
workers? I'm concerned that if connections from all app servers are
handled by one worker in the 'backend', than I have a bottleneck,
because backend uses mod_wsgi so it can't do multiple request

Hope this explains my situation.

Thanks for all the help and prompt response!

>> Okay, so this is the
>> situation I'm in (hopefully my description was clear :) ), and now
>> come the questions:
>> - Will I have any performance gain if I keep connections from app
>> server to other servers instead of opening/closing them with every
>> request from a user?
> I'm not sure to understand how do you handle the connections, but the Nginx
> mod_proxy does not support persistent connections.
>> - Can I set keepalive in Nginx to last forever?
>> - If a connection is kept alive, is it handled by the same Nginx
>> worker when new requests come in?
>> Regards,
>> Mike
> Manlio Perillo

More information about the nginx mailing list