Mat Zo – Back In Time

Dancing to this at this at the moment

 

Posted in Foundations, Multimedia | Leave a comment

Scaling WordPress in the Joyent Cloud Part 3

You have hit the big time with your WordPress blog, GigaOM and Nikki Finke think you are the most influential blogger on the planet.

Congratulations, your mysql database is about ready to crash or worse, it already has.

In this post I discuss what you need to do with your database to keep this beast running smoothly and your blogging empire humming along.

Besides your users reporting the blog is slow, what objective measures are there? I use the NewRelic Std feature that lets me see database latency. Here an example of a database that needs help.

Site latency is almost 700ms or .7 seconds, visitors to the site will notice some lag.

NewRelic Slow DB

NewRelic Slow DB

The database latency between the application and database server is terrible, averaging about 500ms or 1/2 seconds.

NewRelic Slow DB CPM

NewRelic Slow DB CPM

 

Looking at the CPM(calls per minute) vs database response time, the database response seems reasonable.

This WordPress has a few forum message board plugins on it so we need to either shard the database or create a read/write database pool. Sharding is great I am opting for the latter to solve this.

Here is how to create a read/write database pool using the HyperDB plugin

 

The HyperDB plugin allows you set set up multiple slave mysql servers for read access and split write access to a master mysql servers.

Some additional features: Configurable priority for reading and writing, Different tables on different databases/hosts, Failover for downed host, and Advanced statistics for profiling.

Here is a sample of the config of 3 mysql servers, 1st one is a read/write and 2nd/3rd are read only:

$wpdb->add_database(array(
‘host’ => DB_HOST-1, // If port is other than 3306, use host:port.
‘user’ => DB_USER,
‘password’ => DB_PASSWORD,
‘name’ => DB_NAME,
‘write’ => 1,
‘read’ => 1,
‘dataset’ => ‘global’,
‘timeout’ => 0.2,
));

$wpdb->add_database(array(
‘host’ => DB_HOST-2, // If port is other than 3306, use host:port.
‘user’ => DB_USER,
‘password’ => DB_PASSWORD,
‘name’ => DB_NAME,
‘write’ => 0,
‘read’ => 1,
‘dataset’ => ‘global’,
‘timeout’ => 0.2,
));

$wpdb->add_database(array(
‘host’ => DB_HOST-3, // If port is other than 3306, use host:port.
‘user’ => DB_USER,
‘password’ => DB_PASSWORD,
‘name’ => DB_NAME,
‘write’ => 0,
‘read’ => 1,
‘dataset’ => ‘global’,
‘timeout’ => 0.2,
));

For those that are unfamiliar with read/write splitting, you can send read requests to a pool of mysql slave database servers while sending the write requests to the master. Additionally, if you have a failure of one of the slaves, HyperDB can detect and send the read request to another slave in the pool.

After adding a few more slaves to the pool latency was lowered by 300ms and added another 2000 cpm, Your blogging empire is back in business

 

 

 

Posted in Foundations, Technology | Leave a comment

Too cool Nokia 4D projection system w/deadmau5

This is something special to watch

Posted in Foundations, Multimedia, Technology | Tagged as: , , | Leave a comment

Node.js Ad hoc and anonymous chat

Do you ever need a quick chat room without the need for exchanging your skype, aim, msn, google chat id’s? Tried of installing a ton of chat clients.

Joyent had the 2nd annual NodeKnockOut coding competition this weekend.

One app I found and implemented was Speeka. A node.js anonymous chat system. Re-skinning it was a breeze. Feel free to give a drive.

Ad hoc and Anonymous chats

Let me know what you think

Posted in Foundations, Technology | Tagged as: , , , , | Leave a comment

Scaling WordPress in the JoyentCloud Part 2

To continue building on the foundation of a single WordPress server implementation.

In this article, I discuss how to bring in a second server and cluster them behind a Zeus Load Balancer.

joyent wp zeus web

Here is a typical 2 webnode with database, I recommend a Master/Slave MySQL config, but for simplicity, I have just one pictured.

Joyent can clone the first WordPress via a support ticket, you will need to set up replication via a rsync script:

rsync wp-content/* jill@2nd-wordpress-server:/home/wordpress/wp-content

Next we need to create a Zeus load balanced pool with our two servers

Use caching on the Zeus, even 200mb will help with images, css and javascript files.

A few cavets,

When doing upgrades to WordPress or WP plugins, you will need to drain/disable webnodes in your Zeus configuration one at a time during your normal maintenance windows. So drain/disable, upgrade, then repeat.

If you are running Multisite, you will need to update similar to the above instructions.

In my 3rd and final article, I will attack issues related to scaling databases when performance gets sluggish.

Posted in Foundations, Technology | Tagged as: , , , , , | Leave a comment