[Web-SIG] question about connection pool, task queue in WSGI

Benoit Chesneau bchesneau at gmail.com
Sun Jul 15 22:42:53 CEST 2012


On Sun, Jul 15, 2012 at 5:14 PM, Simon Sapin <simon.sapin at exyr.org> wrote:
> Le 14/07/2012 06:07, Graham Dumpleton a écrit :
>
>>>> >>2. Is the socket FD the same mechanism like nginx? If you upgrade
>>>> >> nginx
>>>> >>binary, restart nginx, the existing http connection won't break.
>>
>> I would be very surprised if you could upgrade nginx, perform a
>> restart and preserve the HTTP listener socket. If you are talking
>> about some other socket I don't know what you are talking about.
>>
>> As you can with Apache, you can likely enact a configuration file
>> change and perform a restart or trigger rereading of the configuration
>> and it would maintain the HTTP listener socket across the
>> configuration restart, but an upgrade implies changing the binary and
>> I know no way that you could easily persist a HTTP listener socket
>> across to an invocation of a new web server instance using a new
>> executable. In Apache you certainly cannot do it, and unless nginx has
>> some magic where the existing nginx execs the new nginx version and
>> somehow communicates through open socket connections to the new
>> process, I very much doubt it would as it would be rather messy to do
>> so.
>
>
> I think that est refers to this:
> http://wiki.nginx.org/CommandLine#Upgrading_To_a_New_Binary_On_The_Fly
>
> Apparently yes, there is specific code in nginx to start the new binary and
> give it the existing socket.
>
> And I think that yes, Tarek’s new Circus is similar to the nginx magic
> upgrade in that an open socket is passed around processes. Maybe nginx even
> does this in normal operation with multiple worker processes, but I don’t
> know.
>
> Regards,
> --
> Simon Sapin
Gunicorn does upgrade itself using the USR2 signal just like nginx and
share the socket like using an fd between OS processes.

However the case of a db is a little different since you handle a
connection to a db and not listening on a port. You will need either a
multiprocess queue passing messages to one process or launching a
connection per processes. You can do that using the hook system of
gunicorn.


- benoît


More information about the Web-SIG mailing list