configure apache

Apache VPS Optimization

Apache VPS Optimization – Memory Usage Tuning

I’ve recently had the need to optimize my VPS plan so it won’t consume that much memory.
The main culprit was Apache with more then a few processes using over 50MB.

How to limit processes amount

First you need to download a little script I found called apachebuddy.pl by Gustav Maskowitz.
Running this script shows you how many processes are running and how much memory the average process consumes.


Gathering information…
We are checking the service running on port 80
The process listening on port 80 is /usr/sbin/httpd
The process running on port 80 is Apache/2.2.15 (Unix)
Apache has been running 0d 0h 14m 20s
The full path to the Apache config file is: /etc/httpd/conf/httpd.conf
Apache is using prefork model

Examining your Apache configuration…
Apache runs as apache
Your max clients setting is 8

Analyzing memory use…
Your server has 490 MB of memory
The largest apache process is using 43.35 MB of memory
The smallest apache process is using 8.91 MB of memory
The average apache process is using 31.87 MB of memory
Going by the average Apache process, Apache can potentially use 254.97 MB RAM (52.04 % of available RAM)
Going by the largest Apache process, Apache can potentially use 346.81 MB RAM (70.78 % of available RAM)

Generating reports…
### GENERAL REPORT ###

Settings considered for this report:

Your server’s physical RAM: 490MB
Apache’s MaxClients directive: 8
Apache MPM Model: prefork
Largest Apache process (by memory): 43.35MB
Your MaxClients setting is within an acceptable range.
Max potential memory usage: 346.8 MB

Percentage of RAM allocated to Apache [ OK ]


Using this data I’ve calculated how many processes I can run.
These are the new settings I have set in my httpd.conf:

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves

StartServers 2
MinSpareServers 1
MaxSpareServers 3
ServerLimit 8
MaxClients 8
MaxRequestsPerChild 1000

You need to save at least 128MB for your operating system

Don’t forget to tweak MySQL if you are using it

2 thoughts on “Apache VPS Optimization

  1. Michael

    Hello,

    I am a methodical doer and thinker. I have avoided GIT because it was beyond my capacity. I am on a VPS Apache Server using CENTOS 5.9 x86_64 virtuozzo – vps WHM 11.36.1 (build 5) and am using PHP 5.x. I have zero access to GIT from the WHM and am quickly finding out the GIT is an essential part of the programming process.

    I just downloaded GIT (Windows Stable Release 1.8.1.2) to my Windows 7 command prompt and now am not sure how to connect the GIT to my VPS in order to execute the commands and control everything from my Windows 7 GIT Console.

    Please point me in the right direction as I am reading all I can but if you cannot connect, your digestion of the materials just don’t stick

    Thank you,

    Michael

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.