Unless you have been living under a rock, it’s official that Google counts a website speed as a ranking factor in the search engine. Now, how can we optimize our WordPress site to run as fast as it possibly can and reach its maximum performance?
Through this two part series article, we will guide you on how to tweak your WordPress configuration to get some significant performance.
I suggest you benchmark your current website performance before diving into the process to compare the improvements you have made. You may use any of the website speed and performance check tools.
Optimizing WordPress Site
- Server optimization – covers the optimization on Apache HTTP server, MySQL, and PHP.
- Site optimization – covers the optimization on WordPress and its plugins.
This article will cover the first part, the server optimization. This is best for those who have VPS (virtual private server) or a dedicated server that you can have access on the configuration of the necessary applications.
Apache HTTP Server
Trim Down Unnecessary Modules
By default, there are lot of modules that are active. Most of the modules are not useful at this point so in order to save resources, we have to trim it down by commenting the unnecessary modules except the following:
LoadModule authz_host_module modules/mod_authz_host.so LoadModule log_config_module modules/mod_log_config.so LoadModule expires_module modules/mod_expires.so LoadModule deflate_module modules/mod_deflate.so LoadModule headers_module modules/mod_headers.so LoadModule setenvif_module modules/mod_setenvif.so LoadModule mime_module modules/mod_mime.so LoadModule autoindex_module modules/mod_autoindex.so LoadModule dir_module modules/mod_dir.so LoadModule alias_module modules/mod_alias.so LoadModule rewrite_module modules/mod_rewrite.so
The MaxClients directive sets the number total concurrent connections. Setting values may vary depending on the capacity of RAM. Thus there is an article stating the formula:
MaxClients = 150 × RAM Capacity (in Gigabytes)
For example, if your server has 2GB RAM, you can set the value to 300. But if your server has only 512MB of RAM, set the value to 75.
ServerLimit directive sets the maximum number of processes. The value should be the same as setting the MaxClients. The hard limit for
MaxSpareServers is 20000 to avoid serious trouble due to primarily… typographical errors.
SpareServers set the desired number of idle child processes. The recommended values are the following:
MinSpareServers 5 MaxSpareServers 10
KeepAlive directive allows persistent HTTP connections. In theory, this will save significant latency time between connections, but this will create more resources.
If possible you should set the value of
KeepAlive to off.
KeepAliveTimeout sets the number of seconds of having persistent HTTP connections. The value should be low enough. Too high value will cause resource problems.
MaxKeepAliveRequests sets the maxiumum number of persistent requests in every connection.
StartServer directive sets the number of child processes upon startup. If your website receives low traffic, you can set the value to say, five (5). But if your website receives heavy traffic, it is best advised to set the value close to
This directive sets the number of seconds will wait during processing before it fails. This also helpful to mitigate denial-of-service attacks. Set the value low enough not to complete the process before it loses connection.
Save and Restart
So far, these are the recommended values for the Apache HTTP server configuration. You can tweak it as long as it won’t give problems.
Below are the recommended values in the configuration of MySQL server.
[mysqld] local-infile=0 key_buffer = 64M sort_buffer = 1M join_buffer = 1M max_allowed_packet = 8M max_heap_table_size = 16M table_cache = 1024 sort_buffer_size = 8M read_buffer_size = 1M read_rnd_buffer_size = 768K myisam_sort_buffer_size = 48M thread_cache_size = 512 query_cache_type = 1 query_cache_limit = 4M query_cache_size = 64M tmp_table_size = 16M thread_concurrency = 4 max_write_lock_count = 1 low_priority_updates = 1 [isamchk] key_buffer = 64M sort_buffer = 64M read_buffer = 16M write_buffer = 16M [myisamchk] key_buffer = 64M sort_buffer = 64M read_buffer = 16M write_buffer = 16M
Afterwards, save your configuration and restart the MySQL server.
The PHP is an interpreted language and builds an opcode on the fly when the HTTP server requests the script. In order to increase performance, the PHP compiler cache saves the compiled state to the memory which allows the PHP engine to execute the script without building the opcode again.
There are PHP compiler cache available for your installation.
A warning though, the PHP compiler cache does not work with suPHP.
Stay tuned for the second part of this Optimizing your WordPress site series. I will discuss about the general optimization of WordPress using plugins.