2

I have a django application which relies heavily on threading and I'm noticing no performance increment no matter how much processes or threads I add to the WSGIDaemonProcess.

I can't find a YES/NO answer out there and I'm wondering. Could it be that mod_wsgi is using the same interpreter for each request so I'm running in a bottleneck due to a GIL limitation?

If so, would you recommend something else that would help me workaround this limitation?

tutuca
  • 3,444
  • 6
  • 32
  • 54

2 Answers2

0

For a typical configuration, yes, all requests would be handle in same sub interpreter.

If in different sub interpreters of same process, you are still affected by the GIL.

Post your actual mod_wsgi configuration to confirm you have set things up right.

Consider trying New Relic to find out where real bottlenecks are.

Watch my PyCon US 2012 talk on finding bottlenecks

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • Does this mean that if you have a virtual environment mod_wsgi does not use the python interpreter from there but rather the OS level one? I know you allowed the search of site-packages from mod_wsgi, but I don't know which physical executable the process is using when I do a web request. Thanks. – johnny Apr 15 '15 at 17:58
  • When creating a Python virtual environment, it is effectively a layer in front of whatever Python installation the virtual environment was created against. Using the virtual environment, you are still using the Python executable from the original Python installation, but where it is looking for stuff is a bit different and it will use things from the virtual environment. In the case of mod_wsgi is is actually using the Python shared library and not the executable, but same deal. If you have a problem, create a separate question rather than following up to old issues. – Graham Dumpleton Apr 15 '15 at 23:28
-1

Short answer:

No.

Long answer:

This ability to make good use of more than processor, even when using multithreading, is further enchanced by the fact that Apache uses multiple processes for handling requests and not just a single process. Thus, even when there is some contention for the GIL within a specific process, it doesn't stop other processes from being able to run as the GIL is only local to a process and does not extend across processes.

Citation: https://code.google.com/p/modwsgi/wiki/ProcessesAndThreading

You haven't given enough information for anybody to recommend how to improve performance, but if you've actually written a thread-heavy program in Python, that's your first mistake. Instead of running your program on CPython, maybe you should try Jython or IronPython instead. But then it wouldn't work with mod_wsgi, so we really need more details to understand what you're trying to do...

Mark E. Haase
  • 25,965
  • 11
  • 66
  • 72