I notice Apache is running multiple processes on my LAMP server (ubuntu 10.10). I'm just running a Wordpress site with MySQL as a database. It seems like www-data is running apache2 more than it should (using too much memory too), am I correct:

ID      Owner       Size        Command   
31200   www-data    251236 kB   /usr/sbin/apache2 -k start
20678   www-data    250948 kB   /usr/sbin/apache2 -k start
25781   www-data    248888 kB   /usr/sbin/apache2 -k start
31045   www-data    248844 kB   /usr/sbin/apache2 -k start
19926   www-data    246480 kB   /usr/sbin/apache2 -k start
20749   www-data    239380 kB   /usr/sbin/apache2 -k start
32616   www-data    238632 kB   /usr/sbin/apache2 -k start
8846    mysql   238128 kB   /usr/sbin/mysqld
24178   www-data    234228 kB   /usr/sbin/apache2 -k start
32618   www-data    232344 kB   /usr/sbin/apache2 -k start
32615   www-data    232204 kB   /usr/sbin/apache2 -k start
19805   root    208156 kB   /usr/sbin/apache2 -k start
  • This was the same case on my previous job too(CentOS). I just assumed they were all child processes apache starts for each request.We never faced performance/memory issues due to this though... May 14 '11 at 5:33
  • Hmm. I'm just worried about running out of memory on this system since it's a VPS. May 14 '11 at 5:38

Apache is running multiple processes to have them ready when a client request comes in. Spawning a server process is slow, so it's best to have one waiting for a client.

For memory usage, you should take into the account RES size (as displayed by top), which is the amount of physical memory used by the task.

Why do you think you have too many apache2 processes using too much memory? What do you expect? Why do you expect so?

  • This is on a Cloud-based image. It just seems like it's using more memory than it should for such a small site. Real memory: 496.36 MB total / 92.02 MB free Swap space: 1024 MB total / 975.93 MB free May 14 '11 at 5:36
  • 1
    @Trenton: With pawel's answer that sounds fine. Unless you actually run into a mysql crash or something due to lack of memory, you should be fine. If it happens, then you should look for apache configurations to limit these spawned processes. May 14 '11 at 5:45
  • 2
    Linux will try to keep most of the memory used. If there's nothing else to put in it, it will use RAM for cache and disk buffers. Empty memory is wasted memory (if you aren't running out of RAM). May 14 '11 at 7:05

As the answer by Pawel explains, apache uses a process per request model with a process pool (or thread per request with mpm_worker).

You might be able to reduce the memory usage by using a web server based on non-blocking IO, such as nginx. That way the server doesn't need to dedicate a process/thread per connection.


Apache will run as many processes as you configure it to. The configuration differs if you are using the prefork or worker multi-processing modules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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