WordPress server/DB split!

So I finally quit being lazy and took this project off the back burner.

RasPi #1 has Apache2, PHP5 and WordPress
RasPi #2 has MySQL
Both are back-powered by the hub with a 2A PSU. Both are headless. This split server is only running inside my network right now and is not visible to the outside.

Double stacked RasPii.

Double stacked RasPii.

I am using two 256MB ver. 1.0 RasPi boards. Both are running Raspbian Server Edition (RSE 2.4). Both of them have 8GB transcend class 4 SD cards in them. These cards only average about 3MB/s to 4.5MB/s when I write to them with WIN32DiskImager.

My current WordPress is hosted on a 512MB Rev. 2.0 board with a SanDisk Ultra Class 10 SD card. WIN32DiskImager writes to this card at about 17MB/s to 18.3MB/s. The OS is a full Raspbian Wheezy
I rebuilt the split WordPress to be very close to what is on my server at http://rich1.dyndns.tv.

As I started copying text from my posts and my pages I noticed that the split server was keeping up if not beating my current web server. When you consider the difference in SD write speeds between the single web server and the split web/MySQL server that is pretty impressive. If I had a faster card in the MySQL server it will probably be faster than the single server. I also had to make sure that the split server was taking its pictures from its Database and not the single server. It was showing the pictures from the current server without any problems.

I connected my Kill-A-Watt meter to the split server and it was reporting 8watts at boot and 7watts continuous. This was in comparison to the single board at 7watts boot and 6watts continuous. That tells me that the power supply and hub are eating the lions share of the wattage.

No real definite performance figure as yet. Just the calibrated eyeball. Until I can have SD cards that are of like performance it will just be an apples vs. oranges test. So far looking pretty good. Current (single board) server to home page 3.78 seconds. Dual board (split) server 3.41 seconds and that is with the slower class 4 cards.

So I am going to have to dig up at least one faster card.

The question is which board to use it on, for the Database, or for the web server?

@technion (Raspberry Pi forums)

Theoretically the majority of IO should involve the DB server.

The web server, being largely static files, can be largely cached in memory. The database server is the one that needs to concern itself with safely writing everything to disk, and hence is the one that should have the faster card

So I am in the process of burning the split boards SD cards over to faster Sandisk Ultra class 6 cards. Using Win32DiskImager.

During the reading of the cards I noticed that the Transcend cards were reading at approx. 18.5MB/s. The Sandisk Ultra cards were reading at 18.6MB/s. I guess this should not surprise me but that means the read speed is almost no advantage at all.

Writing to the cards is a bit different. The Transcend cards were reading 3MB/s to 4.5MB/s. The Sandisk Ultra write at about 8MB/s to 8.6MB/s. So writing to the Database on the Ultra cards will most likely have an advantage. Of course the database is read from much more often than written too.

So the next step is to test some USB sticks and USB HDD’s read and write speeds. I know that moving OpenElec XBMC over to a USB stick (PNY Attache 8GB) improved performance for it. So it might be worth the work to see if this would improve performance on the MySQL board.

The journey continues!

With the SanDisk Ultra cards in place, the split Database is looking like a partial bust!

The average difference between serving pages, from the single board against the split boards, is about 2/10ths of a second. That is really not worth all the work (about 6 hours) of and expense (two boards, two SD cards and the extra wattage) of using two boards to run one web site.

Since I already have it set up I will try the a USB stick and a USB HDD on the Database board. I really do not expect that to halve the page serves, which is what it would take to make it all worth it. Publishing to the Database is faster than the single board by about 1/3 of a second, again not really worth it!

Win32DiskImager shows the SanDisk Cruzer 8GB stick at approx. write 11MB/s, read23MB/s or about 25% average faster read/write. So we will see if moving /rootfs to USB will provide any performance gains. I just burned a full image of the RSE 2.4 + MySQL onto the stick. I will have to change cmdline .txt to sda1 instead of mmcblk0p2. Oops make that sda2 since the /boot was copied also.

Ok starting up with the USB stick!

Ok I lost my little bit of gains that I had by splitting MySQL from the server. It averaged exactly the same 3.5 seconds to 3.8 seconds per page serve. It was 3.3 seconds to 3.6 seconds per page with the class 6 cards with the split boards!

Summary:

So unless you are running something else that uses MySQL, you are wasting your time and money splitting the Database from the web server. Gains were only 2/10ths of a second read and 3/10ths of a second writes, yet you have the price of two headless boards. Luckily they were just sitting around so I just played around at this.

The USB stick read/write was faster than the SD cards but in the RasPi it ended up working slower than the SD cards. I will not even bother trying the USB HDD. The HDD would only be a gain in size not really any speed.

 

Leave a Reply