<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>My AWS Musings &#187; Autoscaling</title>
	<atom:link href="http://aws-musings.com/category/autoscaling/feed/" rel="self" type="application/rss+xml" />
	<link>http://aws-musings.com</link>
	<description>Cloud computing, EC2, RDS, SQS, S3, Java...</description>
	<lastBuildDate>Mon, 30 May 2011 18:13:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Choosing the right metrics for autoscaling your ec2 cluster</title>
		<link>http://aws-musings.com/choosing-the-right-metrics-for-autoscaling-your-ec2-cluster/</link>
		<comments>http://aws-musings.com/choosing-the-right-metrics-for-autoscaling-your-ec2-cluster/#comments</comments>
		<pubDate>Sun, 07 Nov 2010 01:12:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Autoscaling]]></category>
		<category><![CDATA[EC2]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=343</guid>
		<description><![CDATA[At GumGum we are using autoscaling successfully. Choosing the right metrics for autoscaling is an ongoing process as your cluster and applications change. When we researched which metrics to use for autoscaling we found very little literature in the blogosphere. That is why I decided to document our experiences with it. To begin with let&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>At <a href="http://gumgum.com">GumGum</a> we are using <a href="http://aws.amazon.com/autoscaling/">autoscaling</a> successfully. Choosing the right metrics for autoscaling is an ongoing process as your cluster and applications change.  When we researched which metrics to use for autoscaling we found very little literature in the blogosphere. That is why I decided to document our experiences with it. </p>
<p><span id="more-343"></span></p>
<p>To begin with let&#8217;s look at an <a href="http://af-design.com/aws/auto_scaling/#as-create-or-update-trigger">autoscaling trigger creation command</a>:</p>
<p><code>as-create-or-update-trigger my-cpu --auto-scaling-group myautoscalinggroup --dimensions "AutoScalingGroupName=myautoscalinggroup" --measure CPUUtilization --period 60 --statistic Average --lower-threshold 20 --upper-threshold 50 --breach-duration 300 --upper-breach-increment 1 --lower-breach-increment 1</code></p>
<p>The dimensions parameter indicates that this is a trigger created on myautoscalinggroup autoscaling group. The measure indicates that it&#8217;s a trigger based on CPU Utilization. Period indicates that the trigger will be evaluated every 60 seconds. if upper threshold (average cpu utilization goes above 50%) is breached for 300 seconds then start 1 additional instance. If lower threshold (average cpu utilization goes below 20%) is breached for 300 seconds then 1 instance is scaled down.</p>
<p>The metrics on which a autoscaling trigger is built (<a href="http://aws.amazon.com/cloudwatch/">Cloudwatch</a> measure) is the most important decision you make when you set up an autoscaling cluster.</p>
<p>There are many metrics you can choose to scale up or down your cluster. CPU utilization, latency, network out bytes, disk reads in bytes etc. You can set up autoscaling based on whatever data Cloudwatch offers. </p>
<p>Latency or CPU utilization were obvious choices for our web cluster. We started out with latency as the metrics for autoscaling. Quickly we realized that latency was not the right metrics for us. Our application was making calls to some third party web services. Sometimes third party webservices problems caused our latency to go up. In that case, adding more instances to the cluster didn&#8217;t help much. Furthermore, third party calls made our latency spike unevenly. We wanted our cluster to go up smoothly as the traffic increases and come down smoothly as the traffic decreased.</p>
<p>We decided to switch to CPU Utilization as the metric for autoscaling. We started thinking about our upper and lower thresholds. We chose 50 as the upper threshold. It can take autoscaling few minutes to kick in. It was important for us to keep enough room (50%) for CPU to go up in those few minutes. In fact by setting a breach duration of 300 seconds we ensured that autoscaling did not kick in immediately. This adjustment accommodated occasional traffic spikes that went down on their own. By looking at our average CPU utilization, we decided to keep the lower threshold at 20% CPU utilization. This worked well when we had a relatively small cluster. Our traffic pattern caused dramatic increase in our average CPU utilization in a smaller cluster (3 to 5 instances). CPU went up to 50% quickly and came back down to 20% when traffic subsided.</p>
<p>Recently our traffic increased dramatically and as a result our cluster increased tenfold! Now we were running 40 instances! <a href="http://blog.kenweiner.com/">Our CTO</a> observed that the autoscaling was adding instances when they are necessary, but the cluster was not scaling down quickly enough. In a bigger cluster, average cpu was fairly stable and was not undergoing dramatic changes as in a smaller cluster. So our CTO decided to adjust the lower threshold to 40% of CPU Utilization. This worked and the autoscaling cluster started scaling down.</p>
<p>You can see the trigger scaling instances up and down throughout a day below. Time is on x axis and number of instances is on y axis.<br />
<a href="http://aws-musings.com/wp-content/uploads/2010/11/autoscaling-effect.png"><img src="http://aws-musings.com/wp-content/uploads/2010/11/autoscaling-effect.png" alt="" title="autoscaling-effect" width="402" height="134" class="alignnone size-full wp-image-353" /></a><br />
We hope our experiences are helpful to others implementing autoscaling. I am sure we will have to revisit these numbers when our cluster grows to 100s of instances! I will write a new blog post describing my experiences then.</p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/choosing-the-right-metrics-for-autoscaling-your-ec2-cluster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amazon AWS Java SDK released</title>
		<link>http://aws-musings.com/amazon-aws-java-sdk-released/</link>
		<comments>http://aws-musings.com/amazon-aws-java-sdk-released/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 01:25:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Autoscaling]]></category>
		<category><![CDATA[EBS]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[RDS]]></category>
		<category><![CDATA[S3]]></category>
		<category><![CDATA[SNS]]></category>
		<category><![CDATA[SQS]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=252</guid>
		<description><![CDATA[Amazon recently announced the AWS SDK for java. SDK or a java api is very much needed &#8211; especially if you are writing your automation scripts in groovy. We have tried multiple java apis in our scripts including JetS3t and Typica. These apis were really helpful, but they only supported some of the AWS services [...]]]></description>
			<content:encoded><![CDATA[<p>Amazon recently <a href="http://aws.amazon.com/about-aws/whats-new/2010/03/22/announcing-the-aws-sdk-for-java/">announced</a>  the AWS SDK for java. </p>
<p>SDK or a java api is very much needed &#8211; especially if you are writing your automation scripts in groovy. We have tried multiple java apis in our scripts including <a href="http://jets3t.s3.amazonaws.com/index.html">JetS3t</a>  and <a href="http://code.google.com/p/typica/">Typica</a>. These apis were really helpful, but they only supported some of the AWS services and were not up to date (for obvious reasons). Having one java api that can support all of AWS technologies was definitely the need of the hour. I am sure Amazon will keep it updated as new services are released. They have the necessary resources to do so.</p>
<p>Furthermore, Amazon has also uploaded the SDK to the <a href="http://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk/1.0.002">maven repository</a>.<br />
You can use the following dependency in your pom.xml:<br />
<code><br />
&lt;dependency><br />
    &nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId>com.amazonaws&lt;/groupId><br />
    &nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId>aws-java-sdk&lt;/artifactId><br />
    &nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;1.0.002&lt;/version><br />
&lt;/dependency><br />
</code><br />
The java doc for the SDK is hosted at <a href="http://docs.amazonwebservices.com/AWSJavaSDK/latest/javadoc/index.html">http://docs.amazonwebservices.com/AWSJavaSDK/latest/javadoc/index.html</a></p>
<p>Amazon has also opened the SDK source code for all. They have mirrored the SDK code repository at github. You can look at the SDK code at <a href="http://github.com/amazonwebservices/aws-sdk-for-java">http://github.com/amazonwebservices/aws-sdk-for-java</a></p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/amazon-aws-java-sdk-released/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>7 easy tips to reduce your Amazon ec2 cloud costs</title>
		<link>http://aws-musings.com/7-easy-tips-to-reduce-your-amazon-ec2-cloud-costs/</link>
		<comments>http://aws-musings.com/7-easy-tips-to-reduce-your-amazon-ec2-cloud-costs/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 18:54:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Autoscaling]]></category>
		<category><![CDATA[EBS]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[RDS]]></category>
		<category><![CDATA[cloud cost]]></category>
		<category><![CDATA[cloud money saving]]></category>
		<category><![CDATA[it cost]]></category>
		<category><![CDATA[reduce ec2 costs]]></category>
		<category><![CDATA[save ec2 money]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=177</guid>
		<description><![CDATA[Amazon ec2 costs can grow very fast if you are not mindful of the Amazon ec2 billing structure. We came across the following ways to save money at our company. Keep machines in the same availability zone Don&#8217;t scatter your machines that talk to each other across multiple availability zones. You will end up paying [...]]]></description>
			<content:encoded><![CDATA[<p>Amazon ec2 costs can grow very fast if you are not mindful of the Amazon ec2 billing structure. We came across the following ways to save money at <a href="http://gumgum.com">our company</a>. </p>
<p><strong>Keep machines in the same availability zone</strong><br />
Don&#8217;t scatter your machines that talk to each other across multiple availability zones. You will end up paying for the bandwidth. Off course this does not apply to the people who purposely keep their machines in different availibilty zones to ensure high availibility.</p>
<p><strong>Use cnames instead of A records </strong><br />
In other words do not map your domain name to an elastic ip. Map it to the public domain name of the instance. Let&#8217;s say you have a machine with name splunk.gumgum.com. All the web servers (within the same availability zone) send considerable data to this machine. If you setup splunk.gumgum.com as an A record, your data will go out and come back in. But if you map it as cname, your data will always remain within the ec2 cluster. To read more about this visit <a href="http://alestic.com/2009/06/ec2-elastic-ip-internal">Eric Hammond&#8217;s Using Elastic IP to Identify Internal Instances on Amazon EC2</a> post.</p>
<p><span id="more-177"></span><br />
<strong>Use spot instances</strong><br />
Use spot instances whenever possible. Spot instances cost less than on demand instances. You can read more about<a href="http://aws.amazon.com/ec2/spot-instances/"> spot instances on Amazon&#8217;s web page</a>.  There is a website that shows <a href="http://www.spothistory.com/">spot history price graphs</a>. It  will tell you an average price of various types of instances. The average price of a m1.small sport instance is 3 cents an hour. You pay 8.5 cents an hour for the same type of on demand instance.</p>
<p><strong>Choose your instance types wisely</strong><br />
A smallest possible instance may not be the right choice to save money. For example c1.medium costs twice as much as m1.small. But it offers 5 times more compute power than m1.small. Thus in some compute heavy jobs it might be cheaper to use c1.medium instead of the least expensive m1.small.</p>
<p><strong>Choose the smallest possible storage</strong><br />
Choose the smallest possible EBS volumes and RDS instances. It is very easy to expand an ebs volume when needed. Same is the case with a RDS instance. Furthermore by choosing smaller drives, you will save money needed for the backup(snapshot) storage too.</p>
<p><strong>Use Autoscaling</strong><br />
<a href="http://aws.amazon.com/autoscaling/">Autoscaling</a>  can start additional instances when needed. It can shut down the additional instances when the need disappears. This is especailly useful for hosting websites/web services that have a specific traffic/usage pattern.</p>
<p><strong>Reserve your instances</strong><br />
You can reduce your costs significantly by reserving number of instances for a year or for three years. Reservation is only a billing concept and thus you don&#8217;t have to designate any istances as reserved. If you reserve 4 m1.small instances, Amazon will make 4 of your running m1.small instances as reserved. For more information <a href="http://www.allthingsdistributed.com/2009/03/amazon_ec2_reserved_instances.html">visit Werner Vogels&#8217;s (Amazon CTO) blog</a>.  </p>
<p>There might be numerous other ways you can save money. Please feel free to leave a comment to share your ways. The more the merrier!</p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/7-easy-tips-to-reduce-your-amazon-ec2-cloud-costs/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>autoscaling in 10 mins</title>
		<link>http://aws-musings.com/autoscaling-in-10-mins/</link>
		<comments>http://aws-musings.com/autoscaling-in-10-mins/#comments</comments>
		<pubDate>Sat, 26 Dec 2009 21:46:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Autoscaling]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[aws]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=94</guid>
		<description><![CDATA[Amazon documentation states that Auto Scaling allows you to automatically scale your Amazon EC2 capacity up or down according to conditions you define. Simply put, it can start and stop ec2 instances based on a condition you define. This is especially important in an environment where you pay more for more capacity. Thus if a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://aws.amazon.com/autoscaling/">Amazon documentation</a> states that </p>
<blockquote><p>Auto Scaling allows you to automatically scale your Amazon EC2 capacity up or down according to conditions you define.</p></blockquote>
<p> Simply put, it can start and stop ec2 instances based on a condition you define. This is especially important in an environment where you pay more for more capacity. Thus if a website has a defined traffic pattern such as traffic peaks every afternoon and goes down in the night, you can have autoscaling start more web servers in the afternoon and shut down unnecessary ones in the night. Isn&#8217;t that amazing?</p>
<p><span id="more-94"></span><br />
You need to be using an <a href="http://aws.amazon.com/elasticloadbalancing/">elastic load balancer</a> to configure auto scaling. Configuring autoscaling consists of three steps:<br />
1) Create launch configuration<br />
2) Create auto scaling group<br />
3) Create auto scaling trigger</p>
<p><strong>Create launch configuration</strong><br />
Launch configuration provides information about the instance to be launched. You can see that an AMI, instance type, availability zone and security groups are specified when a luanch configuration is created.<br />
<code><br />
as-create-launch-config web --image-id ami-656583ff --instance-type m1.small --group ssh,web --key my-keypair<br />
</code></p>
<p><strong>Create autoscaling group</strong><br />
A launch configuration is attached with an autoscaling group.  The group consists of pool of instances. You can specify minimum and maximum size of the pool<br />
<code><br />
as-create-auto-scaling-group myasgroup --launch-configuration web --availability-zones us-east-1a --min-size 4 --max-size 10 --cooldown 120 --load-balancers myloadbalancer<br />
</code></p>
<p><strong>Create autoscaling trigger</strong><br />
The trigger defines the conditions to start or stop ec2 instances. For example:<br />
<code><br />
as-create-or-update-trigger my-latency-trigger --auto-scaling-group myasgroup --dimensions "LoadBalancerName=myloadbalancer" --measure Latency --period 60 --statistic Average --lower-threshold 0.25 --upper-threshold 0.75 --breach-duration 300 --lower-breach-increment=-1 --upper-breach-increment 1 --namespace "AWS/ELB" --unit Seconds<br />
</code><br />
will create a latency trigger with 0.25 as the lower threshold and 0.75 seconds as the upper threshold. If your website latency goes beyond 0.75 seconds, this trigger will be activated and hence an instance will be launched (as specified by upper breach increment). Besides latency you can use <a href="http://docs.amazonwebservices.com/AmazonCloudWatch/latest/DeveloperGuide/arch-AmazonCloudWatch-metricscollected.html#loadbalancing-metrics">different dimensions monitored by cloudwatch</a> such as request count, health host count and unhealthy host count.</p>
<p>That&#8217;s it! It&#8217;s that simple. More information about autoscaling can be read <a href="http://docs.amazonwebservices.com/AutoScaling/latest/DeveloperGuide/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/autoscaling-in-10-mins/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

