Optimize Apache server

Optimize Apache server

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 1 GHz CPU | 3 GB RAM | 60 GB storage | 3 TB bandwidth:

• StartServers: 3072/128=24
• MinSpareServers: 3072/256=12
• MaxSpareServers: 3072/64=48
• MaxClients: 3072/32=92
• Variables must be set in apache server configuration file. To edit this file, execute the following command:

nano /etc/httpd/conf/httpd.conf

Find variables described above and change them according to the formula. After modification, do not forget to restart apache server:

service httpd restart

Was this article helpful?

Related Articles