As we know quality content and lot of unique articles is the best bet to drive traffic to a website . But along with the traffic on lovely pieces of text comes more twisted and resource intensive database queries which may not be liked by the server .  These queries can sometimes be “HOT TO HANDLE”  and may kill it in case of uneven traffic spikes.

Now we are left with only two options to save our “DEAR WORDPRESS BLOGGING SYSTEM” either we scale our server vertically or horizontally :

1. Vertical Scaling Brief

  • Useful for low traffic blog or website
  • Manageability is less complex
  • Feasible when redundancy is not required
  • Not recommended for enterprises
  • Fine tuning at granular level is required @mysql and @kernel level to accommodate high traffic
  • Sometimes application servers can limit vertical scaling to some level

2. Horizontal scaling Brief

  • Works well for medium traffic and high traffic websites
  • Manageability is sophisticated but will reap fruits at later stage
  • Recommended for enterprises
  • Redundancy is achievable and works well
  • Can be run in Load distribution + HA or HA only

All you must be yawning until now , what the crap … this article sucks and the author is only talking about blah blah.  We will take some scenarios on how can we scale WORDPRESS  CMS and cut to the chase.

Scenario 1

Problem : You are experiencing a heavy load on database server due to heavy mysql writes because of which read operations are slower and getting affected . It is also assumed web server (Apache or Nginx or any other) is separate

Solution :

  • Create a master-slave mysql replica of the server
  • Install and configure Hyperdb plugin such as mysql write operations go on master server and mysql read operation will be directed to slave server

Conclusion : It will give a redundancy at Mysql database level for which Hyperdb plugin is famous for. In case slave server fails all the queries will get redirected to Master. In case Master fails write operation will get blocked as slave doesnt allow to write to DB but the blog or site will always remain up.

Note : Do not ever think of creating master-master mysql server using its native replication tool , it is not an ideal solution and data consistency is not guaranteed.  If it is really necessary it is better to go for a third party mysql clustering tool or DRBD like solution.

Scenario 2

Problem : You are hosting Webserver and Mysql server on same machine and want to scale out with redundancy and load distribution. It is assumed you have an option of load balancer too (Either in a data center or public cloud service provider like Amazon or Linode)

Solution :

  • Create a replica set of your application dump on other server using Gluster-FS fileystem .
  • Mount the gluster partition on both the nodes .  Assuming Node1 is already running , create a mysql slave of Node 2.
  • After mysql and Glusterfs has been setup install and configure Hyperdb plugin.
  • Point the node balancer to both the nodes.

Conclusion : It will give redundancy at both application and database level.

Scenario 3

Problem : You are hosting Webserver and Mysql server on same machine and want to scale out with redundancy and load distribution. It is assumed you do not have a load balancer but each server is mapped to unique WAN IP

Solution :

  • Create a replica set of your application dump on other server using Gluster-FS fileystem
  • Mount the gluster partition on both the nodes
  • Assuming Node1 is already running , create a mysql slave of Node 2
  • After mysql and Glusterfs has been setup install and configure Hyperdb plugin.

Conclusion : It will give redundancy at both application and database level.

Their can be thousands more scenarios but it should be enough to get you started.

Tip :

Server scaling totally depends on the application structure and how the coding is done. Resource utilization on various CMS ie. wordpress,joomla,drupal etc can be brought down by using Object Caching and Page Level Caching. Both are very Important

Secret Ingredients for Running WordPress :

Batcache Plugin : For Page Level Caching

Memcached Object Cache Plugin: For Object Level Caching (It is not outdated , still if you have a doubt download it from vip quickstart enviornment)

HyperDB : For scaling WordPress horizontally

Quickstart Test Bed : Automattic has provided a test bed on git which replicates their environment. It can be a good start for understanding the best way to run the blog

Also I found Nginx Helper plugin to be better then batcache in case Nginx webserver was being used but for it to work Nginx cache purge module must be loaded.