8

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?

miHost
  • 183
  • 2
  • 6

3 Answers3

13

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.

Graham Dumpleton
  • 5,990
  • 2
  • 20
  • 19
  • 1
    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 08 '14 at 11:43
3

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.

Alex J
  • 2,804
  • 2
  • 21
  • 24
  • 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
0

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/

Rich
  • 945
  • 1
  • 6
  • 15