[Web-SIG] Daemon server management
renesd at gmail.com
Fri Jun 10 09:13:06 CEST 2005
This is a great idea! It gets around the problem of broken modules
too. If a module is updated on the live site, and it doesn't work for
whatever reason, then the old server is still around to serve
Keeping the old server around until it has finished its requests would
be good. It would need to be told to stop handling new requests...
Like stop binding. But then you still have a tiny window when they
switch over that requests may get a connection refused message? Still
100% better than the kill/start method.
I'm interested in handing sockets over to child proccesses(without a
fork). Not quite sure what the best way is for that though. If you
find out please let me know :)
The similar idea that needs handing over sockets, is for sending
files... you make a really tiny process that all it does is send a
file to a socket. I've done something like this based on the httpd in
asmutils, that only takes up 12KB of memory per process. It uses
linux clone(2) and sendfile(2) instead of fork, and read/write. So it
is very platform specific(x86/linux). It still has some bugs with
really high loads 1000+ concurrent connections. I'm going to fix them
before adapting it for my python server use. However it can do 1500+
req/s of 32KB files on linux/amd duron 850. It can also serve 10000+
connections at once without the machine dying.
Here's the work in progress of the httpd part, if anyone is interested:
On 6/10/05, David Fraser <davidf at sjsoft.com> wrote:
> Ian Bicking wrote:
> >I asked this on the Paste list, but no opinions there... maybe someone
> >here has a thought on this...
> >Does anyone have opinions on how to start and stop daemon servers? I've
> >added a --daemon option to paster serve, but I'd like to implement stop,
> >restart, and reload as well. Whenever I encounter servers that clobber
> >pid files, or where the only way you can tell you've started a server
> >twice is that you get an error message about not being able to bind to
> >the port, it annoys me. But I'm not sure how to best implement a better
> >system. Especially cross-platform -- though an entirely separate
> >process for Windows might make sense (as a windows service or something).
> >Opinions? Or examples of other servers (preferably Python-based) that
> >do this well?
> I think other people have expressed better ideas, but here are some of
> mine I recently implemented...
> This is from jToolkit (jtoolkit.sf.net but the site is horribly out of
> date) which I use for commercial work and for Pootle (pootle.wordforge.net)
> I wanted to make the server reload as quickly as possible with minimal
> handover time. So what I did is make a parent process which simply runs
> a child process that does all the actual work. When a reload is
> signalled, a new child is run. When it is ready to bind to the socket, a
> signal is sent to the first child, which finishes handling its current
> requests and then closes its listening socket. As soon as it closes the
> socket, it sends a signal back to the new child which binds to the socket.
> I think this could be improved by using the same bound socket and
> forking, but the idea of signalling and handover is quite nice. Not sure
> how to do it on Windows though...
> I also had a look into trying to pass sockets between processes which
> you're meant to be able to do with the win32 api but didn't quite get it
> As an aside, I have found problems with Python not releasing allocated
> memory which is why I need to restart every so often in the above manner.
> Web-SIG mailing list
> Web-SIG at python.org
> Web SIG: http://www.python.org/sigs/web-sig
> Unsubscribe: http://mail.python.org/mailman/options/web-sig/renesd%40gmail.com
More information about the Web-SIG