Skip to main content

New server setup

After running for years everything on one VPS, I thought it was time to move to a multiserver setup. Then people wonder if I need it and the answer isn’t as simple as saying no. I don’t need it because of traffic, load etc. On the moment you want to want 100% uptime but still like testing out new things then a multiserver setup is something you probably want. I also decided to change host and moved to DigitalOcean.

Basic setup

The basic setup is to have a loadbalancer with multiple webservers, a database server and a object cache. This is exactly what I have now except database and my object cache are on the same server. Probably this should be split up but moving an object cache isn’t hard science.

I do believe that my loadbalancer is more like a frontend server. I choose for nginx and currently it handles a bit more then redirecting traffic. It also handles SSL traffic and when all webservers are down, it will also show a message. Again, on the scale I’m working this is acceptable and when needed it’s easy to put a loadbalancer in front of the frontend server.

My webservers are running nginx mainline with PHP trunk. I will probably soon test out the repo from Zend so I don’t need to compile everything myself. This was a bit of a pain to get all the dependencies installed. Sites are structured in a way that they have a www folder for the site and a nginx folder for the server configuration. nginx will then read all the configuration by using a wildcard for the folder name. Otherwise the servers don’t do much more.

On my service server I have currently MariaDB installed for my database, Memcache as my object cache and Elasticsearch to make my search better. I’m planning to switch to Redis when the PHP module is ready. I tried to work on it myself but clearly that didn’t work out.


All page caching happens on the webservers with batcache. For now this is the default file but may change in the future. Currently nginx doesn’t do any caching while I don’t think it’s needed for now. It adds another complexity layer but I can see using this for certain actions that happen a lot. Like read actions on the REST API. Additionally I use the standard Opcache of PHP. The Opcache doesn’t expire so the moment I make changes I do need to restart PHP. This makes sense to me since why would my PHP code otherwise need to change.

Image handling

I always used Graphicsmagick for image manipulation since it was possible in 3.5. While I love the APIs WordPress has, I also acknowledge that there are better alternatives. One of them is Thumbor which I currently use. It’s a server written in Python what can do all the image manipulation on the fly and it’s really fast doing so. Currently I only implemented resize and crop (center) but will implement more soon. A great feature is that I finally can resize animated gifs and I also now serve .webp images when possible.

The future

I still need to have a solution for data storage since currently there is no sync between my two webservers. For obvious reasons this is a high priority task. After that I will look into using Elasticsearch and trying to kill the cronjob in WordPress by building something custom in Node or just use which Ryan McCue just tweeted about. Currently I’m already calling the cron job myself with a simple PHP script that loops all my network sites which works for now. Also I’m planning to dive more into Thumbor and it’s storage layers. Currently I use the default file storage but in memory would be nice too.

Leave a Reply

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

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