开发者

How does the apache lifecycle looks like?

As part of my learning process, I thought it would be good if I expand a little more knowledge on what I know about apache. I have several questions, and while I know some of the stuff may require a rather lengthy explanation, I hope you can provide an overview so I know where to go looking. (preferably reference to mod_wsgi)I have read some resources after searching on google, and what I know arrive from there, so please bear with me.

  1. What does the apache lifecyle looks like before, during, and after it receives a http开发者_运维百科 request? Does it spawns a new child process to do the work, or creates a thread in one of the child process?

  2. Does apache by default runs under www-data? So if that's the case, if I want a directory under my project folder to be used for logs, I can change just the folder group to www-data and allows write access?

  3. What user will the python interpreter run under, after being invoked by apache? And what will processes created by Popen or multiprocessing from there run under?

  4. I ran ps U www-data. Why are there so many processes with

S 0:00 /usr/sbin/apache2 -k start


The Apache mpm prefork module handles one connection in one process. To handle connections fast and not spawn processes on demand, apache maintains a process-pool. This explains why you see so many processes in the process-list. If a connection comes in, it is handed to one of the already existing processes.

Some more information is here: http://httpd.apache.org/docs/2.0/en/mod/prefork.html

The answer to question 2) is yes, apache always runs as www-data und you can grant access to any directory by changing it's group permissions to www-data.


Read:

http://www.fmc-modeling.org/category/projects/apache/amp/Apache_Modeling_Project.html http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide#Delegation_To_Daemon_Process http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess

The first one will tell you all the gory details of how Apache works internally. The latter relate to mod_wsgi specifically and process/threading model.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜