In Ubuntu (and Debian, and other distro) there is a few Apache packages (mpm-event, mpm-prefork, mpm-worker). Which is the most suitable for hosting Django mod_wsgi application on single CPU server? Which package is best choice for OpenVZ container?

up vote 3 down vote accepted

The worker MPM would be your best choice. It's compatible with mod_wsgi. The event MPM might give higher performance, but is far less often used, and any performance improvement is minimal -- hence I won't recommend it. The worker MPM handles each request in a separate thread, which makes it much more suitable for use on a VPS than the traditional prefork model, which uses a whole process for each connection.

  • 1
    mpm_event has become a much better option for Django in Apache 2.3, and the performance difference between mpm_worker and mpm_event is much larger than expressed in this answer. Every app is different, benchmark! – robbyt May 28 '12 at 14:55
  • seconded for the mpm_event. "far less often used" is because the above comment is from 2009, and all MPMs are compatible with mod_wsgi daemon mode. – zzzeek Jul 13 '17 at 20:21

If you use mod_wsgi daemon mode, it doesn't matter which Apache MPM you use, although suggested that for UNIX systems worker MPM be used unless you are stuck with having to also host PHP applications using mod_php as some PHP extensions aren't thread safe.

The suggestion that you have to have worker MPM in order to use mod_wsgi daemon mode is wrong. What is important is whether the underlying Apache Runtime Library (APR) is built with threading capabilities. This is usually always the case, even if the prefork MPM is being used in Apache. The only systems that don't have threading capabilities built in to APR are older BSD based systems where threading was a bit broken.

  • Since I'm still learning more about the subject of the different MPMs and the modes of mod_wsgi, this answer was very helpful to me, especially the first sentence. – mbaechtold Apr 8 '14 at 11:43

Worker is required if you use mod-wsgi in daemon mode (which I prefer as there are other sites running on my apache server).

If you use mod-wsgi in embedded mode, either is OK.

It's in the docs: http://code.google.com/p/modwsgi/

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.