{"id":28,"date":"2015-01-13T06:29:00","date_gmt":"2015-01-13T06:29:00","guid":{"rendered":"http:\/\/www.asianux.org.vn\/index.php\/2015\/01\/13\/apache-optimization\/"},"modified":"2015-01-13T06:29:00","modified_gmt":"2015-01-13T06:29:00","slug":"apache-optimization","status":"publish","type":"post","link":"https:\/\/www.asianux.org.vn\/index.php\/2015\/01\/13\/apache-optimization\/","title":{"rendered":"Apache Optimization"},"content":{"rendered":"<p>The default Apache settings that cPanel sets upon install are  definitely something that can be improved on. With a few small tweaks,  the efficiency with which Apache runs with can be greatly improved.<br \/> <small>Please noted: This article assumes that you are using a Linux  server running Apache and cPanel or Plesk, and that you are familiar  with editing files from <a href=\"http:\/\/www.liquidweb.com\/kb\/new-user-tutorial-basic-ssh\/\" target=\"_blank\" rel=\"noopener\">the command line.<\/a><\/small><br \/> <span><\/span><br \/> To start, open the Apache configuration file and finding the  directives section. On a cPanel server, it will be located in  \/usr\/local\/apache\/conf\/. On a Plesk server, it will be in  \/etc\/httpd\/conf\/. If you are using vi or vim: once you open the file,  you can find the directives by scrolling through the file, or by typing  forward-slash \u2018\/\u2019 and typing the exact string that you are looking for  (search is case specific).<br \/> <code>[root@host \/] vim \/usr\/local\/apache\/conf\/httpd.conf<\/code><br \/>or <br \/> <code>[root@host \/] vim \/etc\/httpd\/conf\/httpd.conf<\/code><br \/> This list is a composite of the settings we will be reviewing from fresh install on a cPanel server: <\/p>\n<blockquote><p><code>Timeout 300<br \/>KeepAlive On<br \/>MaxKeepAliveRequests 100<br \/>KeepAliveTimeout 15<br \/>MinSpareServers 5<br \/>MaxSpareServers 10<br \/>StartServers 5<br \/>MaxClients 150<br \/>MaxRequestsPerChild 0<\/code><\/p><\/blockquote>\n<p><em>Please note, the settings that we will review in this article are  by no means a complete list of tweakable options in the Apache  configuration file.  The settings we will be focusing on are the ones  that control how Apache handles webpage requests.<\/em><br \/> <strong>Timeout<\/strong> <\/p>\n<blockquote><p>Timeout 300<\/p><\/blockquote>\n<p>Usually this value doesn\u2019t require editing and a default of <strong>300<\/strong> is sufficient. Lowering the \u2018Timeout\u2019 value will cause a long running script to terminate earlier than expected.<br \/> On virtualized servers like VPS servers, lowering this value to <strong>100<\/strong> can help improve performance.<br \/> <strong> <\/strong><br \/> <strong>KeepAlive<\/strong> <\/p>\n<blockquote><p>KeepAlive On<\/p><\/blockquote>\n<p>This setting should be \u201cOn\u201d unless the server is getting requests from hundreds of IPs at once.<br \/> High volume and\/or load balanced servers should have this setting disabled (<strong>Off<\/strong>) to increase connection throughput.<br \/> <strong> <\/strong><br \/> <strong>MaxKeepAliveRequests<\/strong> <\/p>\n<blockquote><p>MaxKeepAliveRequests 100<\/p><\/blockquote>\n<p>This setting limits the number of requests allowed per persistent  connection when KeepAlive is on. If it is set to 0, unlimited requests  will be allowed.<br \/> It is recommended to keep this value at <strong>100<\/strong> for virtualized accounts like VPS accounts. On dedicated servers it is recommended that this value be modified to <strong>150<\/strong>.<br \/> <strong> <\/strong><br \/> <strong>KeepAliveTimeout<\/strong> <\/p>\n<blockquote><p>KeepAliveTimeout 15<\/p><\/blockquote>\n<p>The number of seconds Apache will wait for another request before  closing the connection. Setting this to a high value may cause  performance problems in heavily loaded servers. The higher the timeout,  the more server processes will be kept occupied waiting on connections  with idle clients.<br \/> It is recommended that this value be lowered to <strong>5<\/strong> on all servers.<br \/> <strong> <\/strong><br \/> <strong>MinSpareServers<\/strong> <\/p>\n<blockquote><p>MinSpareServers 5<\/p><\/blockquote>\n<p>This directive sets the desired minimum number of idle child server  processes. An idle process is one which is not handling a request. If  there are fewer spareservers idle then specified by this value, then the  parent process creates new children at a maximum rate of 1 per second.  Setting this parameter to a large number is almost always a bad idea.<br \/> Liquidweb recommends adjusting the value for this setting to the following:<br \/> Virtualized server, ie VPS <strong>5<\/strong><br \/> Dedicated server with 1-2GB RAM <strong>10<\/strong><br \/> Dedicated server with 2-4GB RAM <strong>20<\/strong><br \/> Dedicated server with 4+ GB RAM <strong>25<\/strong><br \/> <strong>MaxSpareServers<\/strong> <\/p>\n<blockquote><p>MaxSpareServers 10<\/p><\/blockquote>\n<p>The MaxSpareServers directive sets the desired maximum number of idle  child server processes. An idle process is one which is not handling a  request. If there are more than MaxSpareServers idle, then the parent  process will kill off the excess processes.<br \/> The MaxSpareServers value should be set as double the value that is set in MinSpareServers.<br \/> <strong> <\/strong><br \/> <strong>StartServers<\/strong> <\/p>\n<blockquote><p>StartServers 5<\/p><\/blockquote>\n<p>This directivesets the number of child server processes created on  startup. This value should mirror what is set in MinSpareServers.<br \/> <strong> <\/strong><br \/> <strong>MaxClients<\/strong> <\/p>\n<blockquote><p>MaxClients 150<\/p><\/blockquote>\n<p>This directive sets the limit on the number of simultaneous requests  that will be served. Any connection attempts over the specified limit  will be queued. Once a process is freed at the end of a different  request, the queued connection will then be served.<br \/> For virtualized servers such as VPS accounts, it is recommended to keep this value at <strong>150<\/strong>. For all dedicated servers the recommended value for this setting is <strong>250<\/strong>.<br \/> <strong>MaxRequestsPerChild<\/strong> <\/p>\n<blockquote><p>MaxRequestsPerChild 0<\/p><\/blockquote>\n<p>This directive sets the limit on the number of requests that an  individual child server process will handle. After the number of  requests reaches the value specified, the child process will die. When  this value is set at 0, then the process will never expire.<br \/> Liquidweb recommends adjusting the value for this setting to the following:<br \/> Virtualized server, ie VPS <strong>300<\/strong><br \/> Dedicated server with 1-4GB RAM <strong>500<\/strong><br \/> Dedicated server with 4+GB RAM <strong>1000<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The default Apache settings that cPanel sets upon install are definitely something that can be improved on. With a few small tweaks, the efficiency with which Apache runs with can be greatly improved. Please noted:&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-28","post","type-post","status-publish","format-standard","hentry","category-optimization"],"_links":{"self":[{"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/posts\/28","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/comments?post=28"}],"version-history":[{"count":0,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/posts\/28\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/media?parent=28"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/categories?post=28"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/tags?post=28"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}