frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

Optimize Apache server

JustinJustin Member
edited February 20 in Performance and Security
Time4VPS 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


Sign In or Register to comment.

Learn how to install a web and database server, email, FTP client or other applications. Discover and share information on server security or optimization recommendations.
Feel free to join our constantly expanding community, participate in discussions, strengthen your knowledge on Linux and Windows server management!
© 2013 - 2020 Time4VPS. All rights reserved.

Get In Touch