Merge lp:~jorge/juju-core/scaling-fixes into lp:juju-core/docs

Proposed by Jorge Castro
Status: Merged
Merged at revision: 126
Proposed branch: lp:~jorge/juju-core/scaling-fixes
Merge into: lp:juju-core/docs
Diff against target: 59 lines (+34/-7)
1 file modified
htmldocs/charms-scaling.html (+34/-7)
To merge this branch: bzr merge lp:~jorge/juju-core/scaling-fixes
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+187847@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'htmldocs/charms-scaling.html'
2--- htmldocs/charms-scaling.html 2013-09-18 15:10:22 +0000
3+++ htmldocs/charms-scaling.html 2013-09-26 16:42:39 +0000
4@@ -68,6 +68,7 @@
5 <section id="charms-scaling">
6 <h1>Scaling Charms</h1>
7 <p>One of the killer features of computing in the cloud is that it (should) seamlessly allow you to scale up or down your services to meet your needs and whims. Juju not only makes it simple to deploy services, but crucially makes it easy to manage them too. It won't anticipate you getting slashdotted or on the front page of hacker news (yet), but it does mean that when you do you can reliably scale your services to meet the demand.</p>
8+
9 <h1> Adding Units </h1>
10 <p> The general usage to scale a service up is via the <code>add-unit</code> command:</p>
11 <pre class="prettyprint">juju add-unit [options] &lt;service-name&gt;</pre>
12@@ -81,14 +82,40 @@
13 #the machine or container to deploy the unit in, bypasses constraints
14 --to &lt;machine&gt;
15 </pre>
16- <p>Scaling up services is really as simple as asking for more instances. Consider the following setup for a mediawiki:</p>
17-<pre class="prettyprint">juju bootstrap
18+
19+<h1>Scaling behind a Load Balancer</h1>
20+
21+Usually you just can't add more units to a service and have that magically scale, you need to put web heads behind a load balancer. In this case you can just deploy a proxy in front of your units; let's deploy a load balanced mediawiki:
22+
23+<pre class="prettyprint">
24+juju deploy haproxy
25+juju deploy mediawiki
26 juju deploy mysql
27-juju deploy mediawiki
28-juju add-relation mysql mediawiki:db
29-juju expose mediawiki</pre>
30- <p>When you notice the mediawiki instance is struggling under the load of people making edits, you can simply scale up the service using the command:</p>
31-<pre class="prettyprint">juju add-unit mediawiki</pre>
32+juju add-relation mediawiki mysql
33+juju add-relation mediawiki haproxy
34+juju expose haproxy
35+</pre>
36+
37+<p>Then you can <code>juju status haproxy</code> to get the public IP for the load balancer. This is the IP you want to point your DNS to.</p>
38+
39+Now that you are behind a load balancer and the traffic is hitting it, you can grow the mediawiki instances behind the proxy as you see fit, let's add 5 more:
40+
41+<pre class="prettyprint">
42+ juju add-unit -n5 mediawiki
43+</pre>
44+
45+<p>You don't need to worry about manually adding your units to the load balancer, you've made the relationship at the <em>service level</em>, so the new units know exactly how to relate. Juju is also smart enough to ensure that the new units are installed and configured <em>before</em> adding them to the load balancer, ensuring minimal user disruption of the service.</p>
46+
47+<h1>Scaling Charms with built in Horizontal scaling</h1>
48+
49+ <p>Some charms just have native scaling built in, for example the WordPress charm has built in load balancing.
50+ In this case Scaling up services is really as simple as asking for more instances. Note that this feature is charm specific, not all charms can scale this way. Consider the following setup for a WordPress:</p>
51+<pre class="prettyprint">juju deploy mysql
52+juju deploy wordpress
53+juju add-relation mysql wordpress
54+juju expose wordpress</pre>
55+ <p>When you notice the WordPress instance is struggling under the load, you can simply scale up the service using the command:</p>
56+<pre class="prettyprint">juju add-unit wordpress</pre>
57 <p>This will cause a new instance to be run and configured to work alongside the currently running one. Behind the scenes Juju is adding an instance to the Juju environment called a machine and provisioning the specified service onto that instance/machine.</p>
58 <p>Suppose your mysql service needs hyper-scale, you can use the <code>-n</code> or <code>--num-units</code> options to <code>add-unit</code> to specify the desired number of units you want to be added to the service. For example, to scale up your service by 100 units simply do:</p>
59 <pre class="prettyprint">juju add-unit -n 100 mysql</pre>

Subscribers

People subscribed via source and target branches