Login or Sign up

Non-threadsafe libs, (geodjango-geos-proj), move from apache2 worker, threaded server, to prefork on ubuntu

Posted by: skyl on Dec. 24, 2009

GeoDjango relies on libraries that are not threadsafe as of right now. This is unfortunate. Because, otherwise, my favorite method to deploy a Django project is with a threaded mod_wsgi with something like:

WSGIDaemonProcess skyl.org user=myuser group=myuser processes=1 threads=8 python-path=/home/skyl/virtualenvs/myenv/lib/python2.6/site-packages/

Any fool would have looked at the deployment docs for GeoDjango. But somebody didn't. The consequences of running GeoDjango on apache2-mpm-worker for a low-traffic site have been seemingly limited in this case. It just seemed that over time memory was leaking. With the memory-starved slice, eventual crash was a foregone conclusion. This site is just for fun but we would still like it to work and be serviceable. So, I decided to change from apache2-mpm-worker to apache2-mpm-prefork. Which, with a recent ubuntu, is as simple as changing your above WSGIDaemonProcess with say processes=4 threads=1. Then, as if by magic, you may:

# if you need to: sudo aptitude update; sudo aptitude safe-upgrade;
sudo aptitude install apache2-mpm-prefork

We are now on prefork with about a second of downtime.

You can get to the official wsgi docs or get to them through here. I have been REALLY happy with nginx --> apache2 with mod_wsgi. You can serve a decent little smidgen of traffic with 256mb.

Comments on This Post:

Please Login (or Sign Up) to leave a comment