Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

We run Apache version 2.2.8-1ubuntu0.15 on our VPS instance of Ubuntu 8.04.4 LTS \n \l, as I determined by asking this question.

When I issue pgrep apache2, I get the following:

 2691
24517
25330
25669
25672
25795
25796
25809
25825
26401
26402

That's 11 seperate instances of apache2! Is this normal? If not, what should I do about it?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Yes. Apache works like a traditional unix daemon, whereby:

  • Main program waits for an incoming request (blocks on a socket)
  • After receiving the request, the fork() system call is used, which causes the main process to clone itself
  • The main process then waits again for another request
  • The forked copy proceeds to handle the request, and terminates

Forking does consume time, so Apache preforks several instances in anticipation of handling multiple requests. This is totally configurable via /etc/apache2.conf. I can't think of the exact directives right now, but it's probably explained in the comments.

If you expect to handle sudden bursts of concurrrent HTTP requests, then it benefits you to have a lot of instances standing by to take them. The tradeoff is this consumes more memory.

share|improve this answer
    
What you say makes sense. I don't want to mess with this if it's by design. But one thing: I don't seem to have an /etc/apache2.conf file. Is this normal? –  Iain Elder Sep 4 '10 at 4:01
    
@isme ultrasawblade simply forgot the apache2 dir so it's really /etc/apache2/apache2.conf –  Rob Olmos Sep 4 '10 at 4:21

If you're looking to lower this number use the MinSpareServers and MaxSpareServers directives:

http://httpd.apache.org/docs/2.2/mod/prefork.html

share|improve this answer
    
+1 for the documentation. Is this Apache's default behavior? If it is then I have no reason to change it for now. –  Iain Elder Sep 4 '10 at 4:06
    
Yes it is. If you look at the description box there's a term for "Default" where it specifies the default value (should you not specify it) for that directive. In this case it's 10 for Max and 5 for Min. Usually the distro's default config will specify them. –  Rob Olmos Sep 4 '10 at 4:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.