Author |
|
_db_
Joined: 16 Apr 2014 Posts: 8 Location: Canada
|
Posted: Thu 17 Apr '14 17:34 Post subject: How Apache Works process/threads ? |
|
|
Can someone explain how does Apache works? I see when I start Apache server, 2 httpd processes get created.
I understand one is the parent, other is the child.
What do they do?
I also see that other httpd processes are started and that they are also children. Why and what do they do?
I am asking the basic questions since I am a complete novice in Apache so please elaborate.
I am working on a shared Apache module written in Delphi 7 which is acting as a server for client applications running on Windows Mobile 5.0 devices.
Much appreciated, |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Sun 20 Apr '14 19:22 Post subject: |
|
|
A single control process (the parent) is responsible for launching child processes. Each child process creates a fixed number of server threads as specified, as well as a listener thread which listens for connections and passes them to a server thread for processing when they arrive.
This is how it basicly works for all mpms except prefork mpm. |
|
Back to top |
|
_db_
Joined: 16 Apr 2014 Posts: 8 Location: Canada
|
Posted: Tue 22 Apr '14 22:17 Post subject: |
|
|
So, my parent httpd will create one child httpd process for each request coming in or?
Thank you |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
|
Back to top |
|
_db_
Joined: 16 Apr 2014 Posts: 8 Location: Canada
|
Posted: Tue 22 Apr '14 23:19 Post subject: |
|
|
Thanks James,
So, on Windows (mpm_winnt), a single parent creates a single child which then creates ThreadsPerChild (as set in httpd-mpm.conf) threads to process incoming requests. By looking at my setting for example, that number is 25.
This tells me that there will be always only 1 parent and 1 child httpd process but I see different in Task Manager. I see sometimes 5, 6 httpd processes once of which is parent but others are children.
One of these will evenually reach memory cap of 2GB and if that happens, user has to manually restart Apache.
I am trying to understand how apache works to figure out why is one of the httpd processes growing in memory and not all of them.
In my case, I can have any number of barcode scanning device talk to database through an apache shared module file.
Say I have 5 devices connected, does it mean I will have 6 httpd processes running? (1 for parent, 5 for children)?
Much appreciated. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Wed 23 Apr '14 20:46 Post subject: |
|
|
There can be only 2 httpd.exe processes in your taskmanager.
There is 1 parent and 1 child. The child will start a number of threads (defined ThreadsPerChild). In your example 25. Those threads will serv the client connections. Don't forget that http is "fire and forget". After a thread has finished serving a request it is free to serv the next request.
There can be only one process listen to a single port. Which is the parent process. Are you sure your tool doesn't show the threads? Are you talking about the windows default task manager? |
|
Back to top |
|
_db_
Joined: 16 Apr 2014 Posts: 8 Location: Canada
|
Posted: Wed 23 Apr '14 21:10 Post subject: |
|
|
James, thanks for your reply.
On my dev machine, I have only 2 but on client, I have seen 5, 6, 7, 8 (usually btw 5 and 10) httpd processes. I have seen only one of these growing in memory until 2GB cap is reached when it crashes and Apache must be manually restarted.
Yes, I am talking about Windows Task Manager. It will show 6-8 httpd processes. One is parent; others are children. I have shared google drive location with the image showing it.
UPDATE
To explain a bit, there could be any number of devices connecting to the shared module running on apache server. On my system, I have only one device or emulator, but clients might use 20 devices. Could that be the reason there are multiple httpd processes showing in in Windows Task Manager?
Much appreciated,
https://drive.google.com/folderview?id=0BzdoGfp97QQbemxYN2tqQmU4NTQ&usp=sharing |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
|
Back to top |
|
_db_
Joined: 16 Apr 2014 Posts: 8 Location: Canada
|
Posted: Thu 24 Apr '14 18:33 Post subject: |
|
|
James, the link is to the German site to download Process Explorer. Is it the correct link?
Thanks for your help. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
|
Back to top |
|
_db_
Joined: 16 Apr 2014 Posts: 8 Location: Canada
|
Posted: Fri 25 Apr '14 20:20 Post subject: |
|
|
James, thanks for your help. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 29 Apr '14 15:40 Post subject: |
|
|
The sreenshot? |
|
Back to top |
|