Optimizing Performance of WordPress Hosted on Cloud Servers is Required to Decrease the Latency and Page Loading Time. Technologies are discussed in this article. As for WordPress, the database is MySQL, not even MySQLi. PHP – MySQL Applications are famous but not known to be well performers. WordPress with modification or Plugin can run with PostgreSQL, but usually that is not a standard method follow. We are taking the widely used configuration for WordPress to Optimize, that is a typical Linux-Apache-MySQL-PHP (LAMP) Server driven WordPress. WordPress is not scalable, to make it fully scalable amount required to pay will not make the average webmaster happy, the wallet is unfortunately not scalable. So, some compromise is usually done.
Optimizing Performance of WordPress Hosted on Cloud Servers : Understanding the Basics
Practically, WordPress is not a Web App optimized for running on scalable Cloud Infrastructure. Technically WordPress should run quite nicely on a 256 MB server – unfortunately that is fully theoretical. There are Thousands of Plugins which adds more burden and the practical need to run WordPress nicely (with 5K Posts) becomes 01 GB. But, with only one 01 GB RAM, unfortunately; MySQL Server will not work optimally with co-shared processes and/or various running demons. The best solution would be to use :
- Using a Database as a Service of 512 MB for MySQL Server
- Using At least Two Servers of 512 MB size with Master Slave Configuration for running Apache2 and PHP
- Using nginx Reverse Proxy Server of 512MB with some Cache System – Memcache or Redis
As, this configuration is not only costly but also demands always on person to check the server side, we usually take an 01 GB Server Running WordPress as common standard. Theoretically, if all the pages are converted to HTML and served as cached version, an 01 GB Server would be sufficient. Unfortunately, a WordPress with 5K Posts can never convert all the Pages to HTML on the fly, a regularly updated blog posts 4-6 Posts per day. All the HTML Pages are cleared after Publication of a Single Post. Again, if you increase the number of Physical Processors on a single Server and Allocate more RAM to make the caching process faster, unfortunately your bill will reach typical 3-5 server configuration for making WordPress running on kind of legacy mode to make it scalable.
---
Apache is a robust Web Server Software, it is PHP plus badly coded Plugins make it worser. nginx is a compromise to run the poor WordPress faster. Apache is more secured, more developed. If you want to run WordPress with nginx WebServer – use a managed service. You can decrease the RAM to 512 MB. Still, 512 MB will not give much room to give PHP to use 256 MB of RAM.
We usually use :
- Either W3 Total Cache Plugin Alone
- WP Super Cache Plus 2-3 Add-on Plugins for WP Super Cache
- Batcache Plus MemCache Plus some Other Plugins to combine and/or minify CSS, HTML and infamous Javascripts.
- Memcache and Redis actually serves the same function.
Optimizing Performance of WordPress Hosted on Cloud Servers : Options
A PHP accelerator is definitely required on the server side. A PHP accelerator is a PHP extension designed to improve the performance of software applications written in the PHP programming language. Most PHP accelerators work by caching the compiled opcode/bytecode of PHP representation of php files to avoid the overhead of parsing and compiling source code on each request. There are various PHP Accelerators :
- Alternative PHP Cache (APC)
- eAccelerator
- ionCube PHP Accelerator
- Turck MMCache (it is a misnomer in strict sense)
- XCache
- Nusphere PhpExpress
Turck MMCache for PHP probably was the best solution, unfortunately it is not updated; Alternative PHP Cache (APC) is taken as the standard. eAccelerator is probably a fork of Turck MMCache, but in practical scenario with newest PHP, Alternative PHP Cache (APC) works better for most server hardwares. As like desktop computers, it matters what Processor, RAM, Chipset etc. are used on the server as hardware.
Second Part is that Caching Part. If we save data dynamically and serve in a pseudo static fashion – it actually becomes Caching – Disc Cache. We do not want go in to details, but Memcache or Redis is not the full solution to Cache all kind of data. We are talking about an 01 GB Server Running WordPress.
There are tweaks for Apache by enabling modules like deflate (gzip was for version 1 of Apache, we recommend to use both gzip and deflate directives on htaccess with overriding as Site specific settings – for browser issues, enabling both works better on tests). In the same way, there are tweaks for PHP, MySQL too.
For W3 Total Cache, the best settings is (again, it is for an 01 GB Server Running WordPress) :
- Page cache method ==> Disk Enhanced
- Minify cache method ==> Disk
- Database Cache ==> Alternative PHP Cache (APC)
- Object Cache ==> Memcached
- Varnish server is better to use (you can use your another server like in a daisy chain)
- CDN ==> Enabled except for the attachments for the sake of SEO (Google image search brings a lot of visitors)
Many things said in very small details, but unfortunately Google has added new “Laws” to measure “Quality” that practically renders W3 Total Cache using to an average result. It is difficult to score 90+ now as without hand coding, it is impossible to maintain all their points. There are many Managed WordPress Hosting services are available now, if you challenge; we can show, their own WordPress website can not score over 72 on Google’s test. Now on the security side, what W3 Total Cache does is not great, if you do a curl to get header :
1 2 3 4 5 6 7 8 9 10 11 12 13 | ? ~ curl -I example.com HTTP/1.1 200 OK Date: Wed, 26 Mar 2014 21:25:32 GMT Server: nginx (REHL) Vary: Host,User-Agent X-Powered-By: W3 Total Cache/0.9.3 Set-Cookie: PHPSESSID=lghseuhm2g02qehgvqpossnho5; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache X-Pingback: http://example.com/xmlrpc.php X-W3TC-Minify: On Content-Type: text/html; charset=UTF-8 |
X-Powered-By, X-W3TC-Minify are never standard headers and open up information about your setup. To modify them, you have to change them to arbitrary values, change ownership of the files to root and chmod to prevent overwritten. Other header data can be modified from php.ini file. You can compare the values with Yahoo! :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ? ~ curl -I https://www.yahoo.com/ HTTP/1.1 302 Found Date: Wed, 26 Mar 2014 21:33:26 GMT P3P: policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV" Cache-Control: private X-Frame-Options: SAMEORIGIN Strict-Transport-Security: max-age=0 Set-Cookie: DNR=deleted; expires=Tue, 26-Mar-2013 21:33:25 GMT; path=/; domain=.www.yahoo.com Set-Cookie: DNR=deleted; expires=Tue, 26-Mar-2013 21:33:25 GMT; path=/; domain=.www.yahoo.com Set-Cookie: fpc=d=0XXmOH7caCRdbDH88jwn8UqmD79VLVwaGhtkz6BFZtXlO1ifzF0Zq0Y66x4psNtLajys4Wa_ulyZcNJpRzdx9TRN_bJ2qHDuEwpKAsQi3IeTtA0_NT5dAfa38.MMYE0XfrfLlEImob.6nCKreuNwtsOhZYrLnSofJcaEr5xKlF63z0cLClEnIHV45TjJR42p_85jlhA-&v=2; expires=Thu, 26-Mar-2015 21:33:26 GMT; path=/; domain=www.yahoo.com Location: http://in.yahoo.com/?p=us Vary: Accept-Encoding Content-Type: text/html; charset=utf-8 Age: 1 Connection: keep-alive Via: http/1.1 ir6.fp.sg3.yahoo.com (ApacheTrafficServer/4.0.2) Server: ATS |