Our Lightning Fast Recipe

This is how we managed to fit NginX, Varnish and Apache together.

Varnish is an excellent cache and speeds up web-sites significantly. Terminate the HTTP connection at Varnish on port 81 and point Varnish internally to an NginX server listening for HTTP on port 80 (they can’t both be on port 80). The NginX server terminates the HTTPS connection on port 443. With this configuration you can have high-speed and secure content from a single server combining the great features of both Varnish and NginX. Don’t think we’ve forgotten Apache. Apache and NginX essentially serve the same purpose. Read on to find out how this all works.

  • Static Files Execution

    Static Files Execution
  • Dynamic Files Execution

    Dynamic Files Execution
  • Performance

    Performance
  • Server Load

    Server Load
  • .htaccess

    .htaccess
$20 month
  • Static Files Execution

  • Dynamic Files Execution

  • Performance

  • Server Load

  • .htaccess

    YES
$30 month
  • Static Files Execution

  • Dynamic Files Execution

  • Performance

  • Server Load

  • .htaccess

    NO
$40 month
  • Static Files Execution

  • Dynamic Files Execution

  • Performance

  • Server Load

  • .htaccess

    YES

NginX also does both HTTP and HTTPS connections. It’s easy to get going with sites requiring static content but if you require PHP features, install and configure php-fpm and point NginX to it and the result is lightning fast. NginX doesn’t support “.htaccess” files so all server behavior changes are made by the system administrator via restricted configuration files.

Varnish is a caching server that works with HTTP only. That means no HTTPS/SSL. That’s why we configured NginX to server the HTTP/S/SSL request and send them accordingly to Varnish/Apache. Varnish is a cache only and does not serve any content from disks – only from up-stream web servers.

Apache does both HTTP and HTTPS connections. It’s easy to get going with for sites requiring PHP because it comes with PHP loaded in as a module. The down-side is that php runs better in large sites when run as a separate process. Apache “can” use php-fpm though. Apache supports the use of “.htaccess” files which allow developers to make (some) server behavior changes without altering the web server’s configuration.

PHP-FPM needs a little explanation. Web servers such as Apache and NginX don’t know about PHP. We have configured the web server to use a php interpreter. We have two options: a) mod_php and php-fpm. Mod_php is the php module that comes with Apache. It’s easy to get going and requires almost no configuration. But it performs less well in high-demand situations. The second option (the one we are using) is to use php-fpm which is server software that listens on a network port for connections from web servers. php-fpm can scale out easily to accommodate high demand. With php-fom, the web server needs to be told to use the network to get to the php interpreter.

The Conclusion is that you don’t have to spend loads of time to search and decide which server is best for you since you can have all of them blended to provide you with a lightning fast web server.

Fancy a Test Drive?