3

I have deployed a wsgi application on the apache and I have configured it like this: WSGIDaemonProcess wsgi-pcapi user= group= processes=2 threads=15

After I restart the apache I am counting the number of threads: ps -efL | grep | grep -c httpd

The local apache is running only one wsgi app but the number I get back is 36 and I cannot understand why. I know that there are 2 processes and 15 threads which means: 15*2+2=32 So why do I have 4 more?

1 Answer 1

3

You mean why do you have 3 extra per mod_wsgi daemon process.

For your configuration, 15 new threads will be created for handling the requests. The other 3 in a process are due to:

  1. The main thread which the process was started as. It will wait until the appropriate signal is received to shutdown the process.
  2. A monitor thread which checks for certain events to occur and which will signal the process to shutdown.
  3. A deadlock thread which checks to see if a deadlock has occurred in the Python interpreter. If it does occur, it will sent an event which thread (2) will detect. Thread (2) would then send a signal to the process to quit. That signal would be detected by thread (1) which would then gracefully exit the process and try and cleanup properly.

So the extra threads are all about ensuring that the whole system is very robust in the event of various things that can occur. Plus ensuring that when the process is being shutdown that the Python sub intepreters are destroyed properly to allow atexit registered Python code to run to do its own cleanup.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.