Scaling Down in the Cloud With Juju
I’ve talked in the past about The Way to Run Wordpress in the Cloud. It looked like this:
juju deploy wordpress juju deploy mysql juju add-relation wordpress mysql juju expose wordpress
But the problem with building tools that scale up is that we sometimes forget that people like to scale down too. Counting the bootstrap node that comes out to 3 instances. We default to m1.smalls so that comes out to about about $133 a month for an on-demand WordPress blog. Not very cost effective.
As of Juju 1.11.3 and newer, we can now deploy services to the same instance. How we express this is via the
juju deploy --to command. Let’s look at our WordPress example again, this time, let’s save some money and run the entire thing on one node.
juju bootstrap juju deploy --to 0 wordpress juju deploy --to 0 mysql juju add-relation wordpress mysql juju expose wordpress
Then run a quick
juju status to get the public IP of your WordPress installation, and you’re done. On reserved instances that comes down to $61 a year, or $5.08 a month! Commit to three years on AWS and it’s closer to $2.65 a month. Now we’re talking, just don’t forget to add the cost of bandwidth in there.
So what’s the big deal? Running these things on one instance isn’t exactly rocket science. Well ok. Your twitter moment has arrived and now you need to scale your blog. You need on-demand scalability:
juju add-unit wordpress
--to juju fires up a new instance of wordpress to help you scale. How famous is your new blog post?
juju add-unit -n4 wordpress will fire up another 4. Now let’s scale back down, let’s remove units 3 and 4:
juju remove-unit wordpress/4 juju remove-unit wordpress/3
This brings us down back to nodes 0, 1, and 2 running. Keep on going until you’re back to just node 0 running everything. Start on one instance and be able to scale up and down based on traffic. Not bad indeed!
You’re not just getting some out of the box vanilla WordPress and MySQL either. You’re getting a battle-hardened scalable WordPress deployment that’s tuned to scale with nginx. If you want to turn the crank to 11 you can also deploy memcached with it for a really fast blog.
Some caveats; while this works with WordPress right now the individual charms are running on the raw instance, they are NOT in containers yet! That is, if you deploy multiple charms to one box they might collide and stomp on each other. So play with it, but I recommend waiting until the next release of Juju (next month) for containers to land so we have a nice clean seperation of the units on the instance. Work on that continues, along with adding this ability to the GUI. However WordPress works today!
In the meantime here’s how to Get Started with Juju. Happy Orchestrating!
- Targetted Machine Deployment with Juju by James Page