Wordcamp New Zealand – Scaling Servers

On the 22nd of April, I (Liz) was lucky enough to be able to speak on scaling WordPress and servers at the New Zealand WordCamp.

The people there were great, and i ended up meeting and talking to many fascinating people about all sorts of code, servers, set ups among other things.
I was a little nervous that i only had 30 minutes to fit in a lot of information, and i had to dumb it down a fair bit for those with less technical knowledge to make it understandable.

I did manage to fit the talk in with no problems at all, it only took 45 mins, plus question time! Nobody seemed to notice the missing 15 minutes from their clocks luckily, and everyone appeared to understand and have great questions about how it worked.

Because scaling is really specific, the hardest part i came up against was really trying to describe something, and explain something, in a way that was non-specific. Anyone who knows servers, knows that there is no one solution to suit everyone. How ever there are a few common areas you can usually look into.

For WordPress one of the bet things you can do is deactivate and DELETE any unused plugins or themes. Get a developer to check them, a broken one can take down your entire server easily! Not deleting them leaves a potential security hole should that plugin be discontinued, those files are still accessible via the web remember!

A few things identified were setting up things like a Cache (or Cache Plugin), enabling the wordpress object cache in wp-config, and moving as many things offsite as possible.
By moving things offsite, i mean things like video content, photos, music etc.
Why spend hours of your time setting up a shockwave/html5 video player, converters, and using disk space to play video when you can just use youtube? This is what they do for a living, they have extensive programmers who specialize in this, so it stands to reason they are very good at it, and it will save you a lot of money and time.

The same method works for Photography, Music, or any other large files if you can do it. It will save you a lot of pain and money later on down the track.

Another key thing for scaling a single server larger is setting up HyperDB, then having 2 separate databases on other servers. This offloads database offsite, but without the difficulty of having to setup MySQL replication.

If you are using WordPress and want to know more, check here for your nearest WordCamp http://central.wordcamp.org/

Linux Xen Notes

Quick and dirty ref sheet for myself 🙂

vgdisplay – this command shows you all the disk space used/free
lvdisplay – this will show you all the partitions that you have running and how big they are etc

lvextend -L +10G /dev/vg00/files – this will increase /dev/vg0/files 10GB
xfs_growfs /dev/vg0/files – this will resize the xfs partition to take into account eh extra 10GB

lvcreate /dev/vg0 -n mail1 -L 10G # create a partition 10GB called mail1
lvcreate /dev/vg0 -n mail1-swap -L 1G # create a partition 1GB called mail1-swap
mkswap /dev/vg0/mail1-swap
xen-create-image --dist=sarge --debootstrap --hostname=mail1 --force --passwd --size=10G --swap=1G --lvm=vg00   --mirror=http://ftp.nz.debian.org/debian/ --mem=200 --gateway= --netmask= --ip=
cd /etc/xen/ # make a config/copy one from elsewhere and edit it
sudo ln -s /etc/xen/mail1.cfg /etc/xen/auto/
xm create -c mail1.cfg
xm console mail1

Terminology: In xen, everything runs as a virtual machine, even the ‘host operating system’ ( called dom0 ) is just the virtual machine from which you control all the others. The ‘virtual machines’ themselves are called ‘domU’ virtual machines & the only difference is their absence of this admin capability.

To do anything with Xen, ssh to the dom0 on which your xen domU runs and run the ‘xm’ xommand

xm #Lists xm subcommands
xm list # lists xen domUs
xm top # Show xen CPU usage
xm reboot xxxxx #Reboot xen nodes
xm shutdown xxxx # shutdown xen node
xm destry xxxx # equivalent of pulling power cable
xm create xxxx.cfg #Boot a xen node (note the cfg)
xm console xxx # Attach to the console of a xen node, press CTRL-] to exit

To create a xen machine try a shell script similar to this

dist=sarge # Or etch for a new system
xen-create-image --dist=$dist --debootstrap --hostname=$hostname --force --passwd --size=5G --swap=1G --lvm=vg00   --mirror=http://debian.orcon.net.nz/debian --mem=$mem --gateway= --netmask= --fs=xfs --ip=$ipaddress