fbpx

Server Setup

Performance Stack for Single Server

by , , revisited on


We have by far the largest RPM repository with NGINX module packages and VMODs for Varnish. If you want to install NGINX, Varnish, and lots of useful performance/security software with smooth yum upgrades for production use, this is the repository for you.
Active subscription is required.

Let’s review best performance stack for hosting WordPress, Magento, Joomla or any other website with heavy usage of PHP. This stack includes all the software you need for running site with high speed. We also include some of the best practices in configuring the software mentioned.

The main prerequisite for this stack is VPS or dedicated server with at least 2GB RAM. With some configuration tinkering you may be able to run it fine with 1 GB of RAM.

You can use this as recipe for making a working web server solution with any providers like Linode, DigitalOcean or Vultr.

If you’re interested in having your server configured by us, contact any time and we will provide you with a quote.

PHP 7

With the recent release of PHP 7, there is no reason not to use it. New versions of WordPress or Magento are released, supporting the latest and greatest version of PHP.

The best feature of PHP 7, as you guessed it, is performance. It works twice as fast compared to PHP 5.6.

Major tweaks for PHP

  • Zend Opcache with disabled timestamps validation
  • Store PHP sessions to Memcached server installed on the same machine
  • Configure PHP to be run as PHP-FPM with Nginx

Percona MySQL Database

Percona is a great MySQL server fork, which can work as drop-in replacement to your MySQL server needs. Its primary goal is to achieve best performance. You can fetch it from here: http://www.percona.com/doc/percona-server/5.5/installation/yum_repo.html

Major tweaks for Percona MySQL

  • Enable query cache and optimize its size (or disable it altogether) and other variables using mysqltuner

Nginx as web server

Nginx has been much better than Apache for years. The latter was there only for the reason it was available earlier and better packaged. Apache is trying to catch up in performance, but Nginx is still outperforms it in many ways.

Major tweaks for Nginx

  • Enable SSL + SPDY
  • Enable FastCGI microcache
  • Enable OSCP stapling for faster SSL
  • Enable max Expires header for static files
  • Enable Gzip compression
  • Enable keep-alive
  • DO NOT install Google PageSpeed extension for Nginx. This will break Varnish caching. That is, unless you try to configure Downstream Caching in ngx_pagespeed, which may not work well. Most of the things PageSpeed module would do, can be done once by proper server configuration which will not waste CPU cycles every time a page is requsted
  • Disable unnecessary logging
  • Add support for conditional GET for dynamic pages

Varnish Caching

Keep Varnish on its default port 6081 and introduce it to your LEMP stack as the caching layer. Varnish is the greatest caching solution available for the Web. This will dramatically increase performance.

Major tweaks for Varnish

  • Configure / write your VCL correctly: ignore all the cookies irrelevant to your application
  • Adjust keep-alive

Configure the website

Nothing knows better when to cache things and when to invalidate Varnish cache besides the website itself.

WordPress

You need a WordPress plugin to invalidate Varnish cache when new post is added or modified: W3TC can do that. In addition, your Varnish VCL file should support the invalidation request.

Some of the things can be cached in addition to Varnish, specific to WordPress. As such, make sure to configure Object Cache and Database Cache in W3TC to store in APCu or Memcached.

Magento

Magento 1.x can support Varnish with the addition of Turpentine plugin, but this is a very bad idea, unfortunately. Use FPC that works instead.

Magento 2.x supports Varnish out of the box! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.