Change the future

Saturday 3:15 p.m.–3:45 p.m.

Making Apache suck less for hosting Python web applications.

Graham Dumpleton

Audience level:
Web Frameworks


It is not hard to find developers who will tell you that Apache sucks for running Python web applications. Is there a valid basis to such claims or have they simply been misguided by the views of others? This talk will endeavor to shine a light on the realities of and limitations in working with Apache, as well as the challenges in implementing the mod_wsgi module for Apache.


Apache started out life as a means of serving static files and has progressively evolved over the years to meet the ever growing requirements placed upon it. Because it is a generic solution, it isn't always going to be a perfect out of the box match for every specific task, but that does not automatically imply it is a poor platform to use. This is the case with using Apache to host Python web applications. The default configuration may not result in the best outcome when hosting Python web applications, but with a bit of diligence and good monitoring, it can be tuned to provide a more than capable solution that will stand up to the demands of even major web sites.

In order to dispel the myths and misperceptions that do exist around using Apache for hosting Python web applications, this talk will dive deeply into a range of issues related to the internal operation of Apache, its architecture and the manner in which mod_wsgi hooks into Apache. The topics to be covered will include:

  • A description of the differences that exists between the various Multi-Processing Modules (MPMs) that Apache provides.
  • How the mod_wsgi module integrates with Apache, the difference between embedded and daemon modes and how that relates to the MPM being used.
  • How the MPM configuration determines how Apache manages worker processes and the impacts of choosing a wrong configuration on performance and resource consumption of your system.
  • The mechanics of how the Python interpreter is embedded within Apache and the constraints that exist due to how Apache manages extension modules, made worse by problems that exist in Python itself when embedding it in other systems.
  • How web requests are proxied across to the Python web application processes when using mod_wsgi daemon mode and the design problems that existing around this mechanism.
  • How threads for handling web requests are managed and tricks daemon mode of mod_wsgi uses to try and limit the damage of users over allocating the number of threads.
  • The difficulties in using multiple Python sub interpreters within the same process and the less than complete separation that exists between sub interpreters when using this to host multiple web applications.
  • Where Apache is a poor solution, such as with long polling and streaming web applications where high number of concurrent requests need to be handled.
  • The benefits that come from placing a proxy such as nginx in front of Apache and how that can help to make Apache perform better.
  • Issues that can arise when the one Apache instance is used to host web applications using different languages such as PHP at the same time.
  • Guidelines for how to strip down and configure Apache to be a lean, mean speedster rather than a general purpose all in one solution.

So does Apache suck? In reality the answer is not a simple yes/no. Set it up wrong or try and use it for a specific task that it is not well suited for and the answer will of course be yes, but this is the same with any system.

Are those who say Apache sucks right? In the majority of cases the answer is no. More often than not they are just repeating the misguided advice of others, with even the source of the original comments having no real understanding of how Apache works and what the true challenges are in trying to use Apache to host Python web applications.

The primary purpose of this talk is therefore to educate users as to what is problematic about using Apache for Python web applications. People may still claim Apache sucks, but hopefully this talk will at least remove the ignorance that usually sits behind such views.