WordPress Hosting Optimization

Umumnya web wordpress itu kemooot banget. Hari ini saya mencoba membuat blog wordpress untuk Masjid Garuda (http://masjidgaruda.rajawali.web.id/) dengan teknik WordPress Hosting Optimization. Kayaknya kalau pakai turbolinks + html cache bakal kenceng webistenya. Setelah mencari-cari, konfigurasi dan plugin yang cocok, jalan, dan akhirnya dipakai adalah:

  • Host Virtual Machine di DigitalOcean yang $10 (Hosting udah pakai SSD)
  • NGINX web server
  • Ajaxify WordPress Site
  • WP Super Cache

Saya pun setup website-nya di server Digital Ocean yang $10 per bulan. Berikut ini komparasinya:

  1. Shared hosting biasa vs host VM: 3 request per second vs 65 request per second
  2. Shared hosting biasa vs host VM: 5 second page load vs 1 second page load
  3. Apache web server vs NGinx web server: 65 request per second vs 75 request per second
  4. Tanpa WP Super Cache vs Dengan WP Super Cache: 75 request per second vs 5500 request per second
  5. Tanpa WP Super Cache vs Dengan WP Super Cache: 1 second page load vs 65 milisecond page load
  6. Transisi halaman tanpa Ajaxify WordPress Site vs dengan Ajaxify WordPress Site: 3 second page render vs 300 milisecond page render

*Catatan: hasil diperoleh dari rata-rata ujicoba dan angka yang tertulis dibulatkan. Hasil mungkin berbeda dengan percobaan lain, tapi kurang lebih mirip lah.

Laravel: Should I Choose HHVM or PHP-FPM

My conclusion:
HHVM beats PHP-FPM by 20% to 45% at both request per second and average response time.

Well, if you also include database operation, the time margin should be around the same (the percentage may differ though), considering both HHVM and PHP-FPM consume about same time for database operation.

I ran the test for Lumen 5.2 and Laravel 5.2 using Apache Bench. The PHP version used is 5.6.13 and NGinx version 1.4.6.

If you are curious of “even better performance for Laravel”, try ReactPHP+NGinx (refer to http://marcjschmidt.de/blog/2014/02/08/php-high-performance.html) because it eliminates Laravel bootstrap’s code just being ran once at server startup, instead of ran at each request (See also https://github.com/php-pm/php-pm). But there is a fatal drawback: If your code throw uncatched exception, your server dies. Also other drawbacks such as reload server on code change and potential memory leaks.

If you need the test results / source code, just contact me. I don’t feel like putting them on this blog.

Enable Upload Large File on PHP + Nginx

  1. Open file php.ini (should be located at /etc/php5/fpm/php.ini if you are using PHP-FPM. Otherwise, just find it using: sudo updatedb && locate php.ini)
  2. Edit these 3 variables:
    1. upload_max_filesize => 2M to (whatever you want. I tend use 128M)
    2. post_max_size => 2M to (same as above. just note if you expect to upload multiple files, set this variable higher than above)
    3. max_input_time => 60 to (your client’s expected maximum upload time. should be max file size divided by minimum client’s upload speed)
  3. Open your nginx configuration, add this parameters:
    1. client_max_body_size xxM; (same as post_max_size)
    2. fastcgi_read_timeout xxM; (same as max_input_time)
  4. Restart PHP-FPM and nginx: sudo service php5-fpm restart && sudo service nginx restart
  5. That’s all folks!