My street in SF

peteryorke-st

Posted in Foundations | Leave a comment

Scripting the Zeus/Stingray API

So you are digging the Joyent API, you have your provisioning working with your Chef or Puppet Scripts.
Here is a shell script you can use to add that new box to your Stingray load balancer.
#!/bin/bash
zxtm=localhost
/opt/zeus/zxtm/bin/zcli << EOF
Pool.addPool ["JoyentDemo"],[["help.joyent.com:80","joyent.com:80","wiki.joyent.com:80"]]
Pool.setLoadBalancingAlgorithm ["JoyentDemo"], roundrobin
Pool.setPassiveMonitoring ["JoyentDemo"], 0
Pool.setMonitors ["JoyentDemo"], "Full HTTP"
Pool.setKeepalive ["JoyentDemo"], 1
VirtualServer.addVirtualServer ["JoyentDemo"],{"default_pool" : "JoyentDemo","port" : "80","protocol":"http"}
VirtualServer.setCompressionEnabled ["JoyentDemo"], yes
VirtualServer.setEnabled ["JoyentDemo"], 1
exit
EOF

How the Script Works
You can see how this script works when you break it down.
The first line specifies you are running this local to the Zeus/Stingray. if you want to run remotely, change the value of this line to ssh.
zxtm=localhost
The next line initializes two Stingray load balancing objects: Pool and VirtualServer. The rest of the script sets properties in these objects.
Tip: if you are running this locally, you do not need to specify a password since you are already on the appliance.
The zcli command invokes the Stingray Command Line interface. This line starts unix shell scripting to redirect standard output to the zcli using << EOF.
/opt/zeus/zxtm/bin/zcli << EOF
Tip: For more detailed information on the zcli, type "help" and press ENTER.
The next few lines set properties in the Pool object.
This line creates a pool called "myPool" and populates it with three different servers: help.joyent.com:80, joyent.com:80, and wiki.joyent.com:80.
Note: Remember to include the port number after the DNS or IP address.
Pool.addPool ["myPool"],[["help.joyent.com:80","joyent.com:80","wiki.joyent.com:80"]]
This line sets the type of load balancing to use with this pool. In the below line, the keyword "roundrobin" specifies the algorithm used.
Pool.setLoadBalancingAlgorithm ["myPool"], roundrobin
Below is a list of other supported algorithms. The keyword to use for each algorithm appears in bold.
roundrobin: Round Robin
wroundrobin: Weighted Round Robin
cells: Perceptive
connections: Least Connections
wconnections: Weighted Least Connections
responsetimes: Fastest Response Time
random: Random Node
This line enables or disables passive monitoring for the generated pool. Supported values are 0 and 1.
Note: To avoid seeing false positives on service checks, set this to a value of 0.
Pool.setPassiveMonitoring ["myPool"], 0
This line sets the monitoring type for the generated pool. Joyent usually recommends Full HTTP or Simple HTTP
Pool.setMonitors ["myPool"], "Full HTTP"
This line enables or disables keep-alive in the generated pool. Supported values are 0 and 1.
Pool.setKeepalive ["myPool"], 1
The next few lines set properties in the VirtualServer object.
This line creates a new virtual server called "myServer" that uses the pool created in the previous lines.
Note: Ensure that you also specify the port number and protocol. In this case, the port number is 80 and the protocol is HTTP.
VirtualServer.addVirtualServer ["myServer"],{"default_pool" : "myPool","port" : "80","protocol":"http"}
This line enables compression on the appliance. Joyent recommends using compression on the appliance, rather than the web server.
VirtualServer.setCompressionEnabled ["myServer"], yes
This line enables your new config.
VirtualServer.setEnabled ["myServer"], 1
The last couple lines exit from the zcli and close the script.
exit
EOF
That's it.
If you have any other questions or idea's for Zeus/Stingray articles, please use the comments field

Posted in Foundations, Technology | 1 Comment

GDC in SF

Down to San Francisco this week for Game Developers Conference, see you at the Joyent booth

Posted in Technology | Leave a comment

Load Balance by domain name

Riverbed logo

Wrote this little bit of TrafficScript for some clients today and published to the Joyent wiki. I think it’s pretty readable.


$hostHeader = http.getHostHeader();
if( $hostHeader == "domain.com" || $hostHeader == "www.domain.com"){
pool.select( "domain.com-pool" );
}
else if( $hostHeader == "another-domain.com" ){
pool.select( "another-domain.com-pool" );

Enjoy

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

Karanda – Infectious (Original Mix)

I am feeling this at the moment

Posted in Foundations | Leave a comment

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 | 1 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: , , , , , | 1 Comment

Steve Brian and Noel Gitman – Luna System (Tritonal Remix)

Today’s musical mix – Dancing and cheerful

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

Craig Connelly – Absolute Electric (Tritonal Club Mix) [Garuda]

Been diggin on this little tune.

Posted in Foundations, Multimedia | Tagged as: , , | 1 Comment

Scaling WordPress in the JoyentCloud Part 1

In my role as a Solution Architect at Joyent, I get asked about ways to increase performance and scale of WordPress sites in the cloud. In this article, I discuss things you can do to get your WP site optimized at the server and database levels.

Here are a few easy prescriptive solutions for your Joyent SmartMachines:

1. APC

APC or Alternative PHP Cache compiles and caches you PHP code so that it doesn’t need to be rerun each time a page is requested. This provides a 2-5 times performance increase to page load times. To enable, uncomment the extension=apc.so line in your php.ini file. Restart the Apache process.

2. Memcached

Memcached is a memory object caching system that is used to remediate high database loads in WordPress sites by caching database results in memory. to enable, uncomment the extension=memcache.so in your php.ini file. Restart the Apache process.

3. W3 Total Cache

W3 Total Cache is a WordPress plugin that works well in the Joyent environment for caching various elements of WP sites. It can be used to leverage APC and memcached. Page and Object caches use APC and database uses memcached in the configuration.

4. Use NewRelic Application Monitoring agents

Joyent provides NewRelic application performance monitoring agents that are lightweight at the “Standard” level for free of charge to 1G or greater customers. Using NewRelic to validate system or code changes can tell you what your end user experience is as well as current load conditions of the various application layers like PHP, memcached or database. To sign up for your free account, click the SignUp button from this URL: http://newrelic.com/joyent.html

5. Optimize your Apache config

Tuning your mpm and file descriptors will help with scaling your sites. The Joyent Wiki has a has an excellent article on tuning the Apache mpm.conf and increasing file discriptors.

6. Give your MySQL database enough memory

Use the innodb database format and giving as much of your memory as you can without causing your machine to swap. I use a simple formula of 75% of memory to the MySQL config parameter innodb_buffer_pool_size on a dedicated MySQL server. This will cache most of your tables in memory thereby increasing the database response times. Watching this in NewRelic, you should be able to see if your are driving down the latency times. Then you can slowly bump up the memory until performance doesn’t improve any more.

In my next article, I will discuss solutions for more than one WordPress Server in a cluster and database scaling.

Posted in Foundations, Technology | Tagged as: , , , , , , | 1 Comment

NodeFly Revisited

NodeFly Logo

Playing with the new and improved NodeFly systems monitoring and reporting.

Based on the new application framework node.js

NodeFly has a broad range of support for system and applications, such as MySQL, Memcache, Apache. Additionally, NodeFly supports all the major cloud providers, Joyent, AWS, Rackspace and Softlayer.

Installation of the agents are simple and lightweight.

Check them out, you will be glad you did.

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

The machine is not capable of hatred. It loves everyone, especially you.

Paraphrased from Issac S.

Posted in Foundations | Leave a comment

I like these trees

20110626-021303.jpg

Posted in Foundations | Leave a comment

Yum, Dungeness Crab

20110616-123154.jpg

[wcs_qr_code]

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

Playing with QR Codes

[wcs_qr_code]

Having a bit of fun with QR Codes

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

Solaris Nagios Install at Joyent


I wrote this document to assist JoyentCloud customers with their Nagios install and configurations.

[wcs_qr_code]

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

Brendan Gregg – mpstat

Brendan is on fire with more videos

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