1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Linux Speeding up Apache

Discussion in 'Software' started by Confused Fishcake, 10 Dec 2006.

  1. Confused Fishcake

    Confused Fishcake Minimodder

    Joined:
    25 Sep 2005
    Posts:
    698
    Likes Received:
    1
    I have installed apache2 on an old P-III running xubuntu, for file/web serving. However, when I looked in top or htop, it shows between 50 or 60 processes (all apache) My maximum usage is going to be:

    2 video streams (via http) to 2 machines on a lan
    Possibly a single user browsing simple webpages across the internet

    As you can see, this means I should only be getting a maximum of 3 connections, so the numerous processes seem a little unecessary, as well as the fact that eah process gobbles up almost 2mb of precious ram (I only have 192mb in total)

    I crudely tried to fix the problem by changing the following lines in /etc/apache2/apache2.conf:

    This aids the problem a little, but I still get 11 processes, and in /var/logs/apache22/error.log I get "server reached MaxClients setting" errors. I don't think my modifications work properly.

    If anyone has any ideas on how to properly configure apache2 in this way, I would be very grateful.
     
  2. andatche

    andatche What's a Dremel?

    Joined:
    11 Nov 2005
    Posts:
    16
    Likes Received:
    0
    When you request a web page, multiple connections are opened to the server to receive each item of content from the page (i.e. images) as well as the page it's self. Restricting the maximum number of servers to 3 means at most 3 connections can be open, a better solution would be something like the following:

    Code:
    <IfModule prefork.c>
        StartServers         5
        MinSpareServers      5
        MaxSpareServers     10
        MaxClients         20
        MaxRequestsPerChild  0
    </IfModule>
    If you are running apache on Linux then you will almost certainly be using the prefork MPM, and thus only need to set up that MPM. The above would keep at least 5 and at most 10 server processes running all the time waiting to serve, and allow at maximum 20 to exist at any one time. This should allow reasonable use of the server without using too much memory. Reducing this number much further will dramatically degrade the performance of your web server.
     
  3. Confused Fishcake

    Confused Fishcake Minimodder

    Joined:
    25 Sep 2005
    Posts:
    698
    Likes Received:
    1
    Thanks a lot, I never would have figured that out without help. As it happens, I had to use MaxClients set to 16 or apache got all funny and complained about not having enough servers :miffed: . Still, works much faster now.
     
  4. simon w

    simon w What's a Dremel?

    Joined:
    3 Nov 2003
    Posts:
    1,302
    Likes Received:
    0
    I'd set MaxRequestsPerChild to something high, say 10000. The smallest of memory leaks will build up over time.
     
Tags:

Share This Page