Jump to content

Optimize Apache server


Recommended Posts

LCwHost Ltd support department receives a lot of questions about how to optimize the Apache service. This article introduces basic, simple and yet effective ways to optimize Apache service according to VPS resources. By default, Apache "prefork" module is used. When this module is in use, one process serves one query. Those processes must be defined in strict numerical values to avoid VPS resource allocation to Apache only.

For traditional Apache optimization, there are four variables used by Apache:

• StartServers: number of child server processes created at startup;
• MinSpareServers: minimum number of idle child server processes;
• MaxSpareServers: maximum number of idle child server processes;
• MaxClients: maximum number of connections that will be processed simultaneously.

We can calculate optimal values for those variables:

• StartServers: RAM/128;
• MinSpareServers: RAM/256;
• MaxSpareServers: RAM/64;
• MaxClients: RAM/32.
• RAM: your server total Random Access Memory value;

Practical example in VPS plan with 4 GHz CPU | 4 GB RAM | 50 GB storage | 4 TB bandwidth:

• StartServers: 4096/128=32
• MinSpareServers: 4096/256=16
• MaxSpareServers: 4096/64=64
• MaxClients: 4096/32=128

 
Variables must be set in the Apache server configuration file. To edit this file, execute the following command:

nano /etc/httpd/conf/httpd.conf
 

Find the variables described above and change them according to the formula. If you can not find the variables, at the end of the file, add the following lines with your optimized limits being set:
</IfModule>
KeepAlive Off
<IfModule prefork.c>
   StartServers        32
   MinSpareServers     16
   MaxSpareServers     64
   MaxClients         128
</IfModule>

After modification, do not forget to restart apache server:

service httpd restart
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...