<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Cloud Developer Tips by Shlomo Swidler</title> <link>http://shlomoswidler.com</link> <description>Cloud Developer Tips: Practical tips for developers of cloud computing applications.</description> <lastBuildDate>Wed, 23 Nov 2011 22:12:42 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CloudDeveloperTips" /><feedburner:info uri="clouddevelopertips" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>Ten^H^H^H Many Cloud App Design Patterns</title><link>http://feedproxy.google.com/~r/CloudDeveloperTips/~3/2-qBcOQmMcI/tenhhh-many-cloud-app-design-patterns.html</link> <comments>http://shlomoswidler.com/2011/05/tenhhh-many-cloud-app-design-patterns.html#comments</comments> <pubDate>Sun, 08 May 2011 21:54:45 +0000</pubDate> <dc:creator>shlomo</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[cloud application]]></category> <category><![CDATA[design pattern]]></category> <category><![CDATA[interop]]></category> <category><![CDATA[presentation]]></category><guid isPermaLink="false">http://shlomoswidler.com/?p=295</guid> <description><![CDATA[Today I presented at the Enterprise Cloud Summit at the Interop conference. The talk was officially entitled Ten Cloud Design Patterns, but because my focus is on the application, I re-titled it. And I mention more than ten patterns, hence the final title Many Cloud App Design Patterns. I explore a number of important issues for [...]]]></description> <content:encoded><![CDATA[<p></p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F05%2Ftenhhh-many-cloud-app-design-patterns.html"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F05%2Ftenhhh-many-cloud-app-design-patterns.html&amp;source=shlomoswidler&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br
/> </a></div><p>Today I presented at the Enterprise Cloud Summit at the <a
href="http://www.interop.com/lasvegas/">Interop conference</a>. The talk was officially entitled <em>Ten Cloud Design Patterns</em>, but because my focus is on the application, I re-titled it. And I mention more than ten patterns, hence the final title <em>Many Cloud App Design Patterns</em>.</p><p>I explore a number of important issues for cloud applications. Application state and behavior must both be scaled. Availability is dependent on MTTR and MTTF &#8211; but one of them is much more important than the other in the cloud. Single Points of Failure are the nemesis of availability, and I walk through some typical patterns for reducing SPOFs in the cloud.</p><p>Hat tips to Jonas Bonér for his inspiring presentation <a
title="Scalability, Availability, Stability Patterns" href="http://www.slideshare.net/jboner/scalability-availability-stability-patterns" target="_blank">Scalability, Availability, Stability Patterns</a> and to George Reese for his blog <a
title="The AWS Outage: The Cloud's Shining Moment" href="http://broadcast.oreilly.com/2011/04/the-aws-outage-the-clouds-shining-moment.html" target="_blank">The AWS Outage: The Cloud&#8217;s Shining Moment</a>.</p><p>Here&#8217;s the presentation &#8211; your comments are welcome.</p><div
id="__ss_7886436" style="width: 425px;"><strong
style="display: block; margin: 12px 0 4px;"><a
title="Many Cloud App Design Datterns" href="http://www.slideshare.net/shl0m0/many-cloud-app-design-datterns">Many Cloud App Design Datterns</a></strong><object
id="__sse7886436" width="425" height="355"><param
name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=cloudappdesignpatterns-110508154824-phpapp01&amp;stripped_title=many-cloud-app-design-datterns&amp;userName=shl0m0" /><param
name="allowFullScreen" value="true" /><param
name="allowScriptAccess" value="always" /><embed
type="application/x-shockwave-flash" width="425" height="355" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=cloudappdesignpatterns-110508154824-phpapp01&amp;stripped_title=many-cloud-app-design-datterns&amp;userName=shl0m0" allowfullscreen="true" allowscriptaccess="always" name="__sse7886436"></embed></object></p><div
style="padding: 5px 0 12px;">View more <a
href="http://www.slideshare.net/">presentations</a> from <a
href="http://www.slideshare.net/shl0m0">Shlomo Swidler</a>.</div></div><p><script src="http://b.scorecardresearch.com/beacon.js?c1=7&amp;c2=7400849&amp;c3=1&amp;c4=&amp;c5=&amp;c6="></script></p> <img src="http://feeds.feedburner.com/~r/CloudDeveloperTips/~4/2-qBcOQmMcI" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://shlomoswidler.com/2011/05/tenhhh-many-cloud-app-design-patterns.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> <feedburner:origLink>http://shlomoswidler.com/2011/05/tenhhh-many-cloud-app-design-patterns.html</feedburner:origLink></item> <item><title>Roundup: CloudConnect 2011 Platforms and Ecosystems BOF</title><link>http://feedproxy.google.com/~r/CloudDeveloperTips/~3/5sEbh8yS1fc/roundup-cloudconnect-2011-platforms-and-ecosystems-bof.html</link> <comments>http://shlomoswidler.com/2011/03/roundup-cloudconnect-2011-platforms-and-ecosystems-bof.html#comments</comments> <pubDate>Mon, 14 Mar 2011 16:44:47 +0000</pubDate> <dc:creator>shlomo</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[cloudconnect]]></category><guid isPermaLink="false">http://shlomoswidler.com/?p=284</guid> <description><![CDATA[The need for cloud provider price transparency. What is a workload and how to move it. &#8220;Open&#8221;ness and what it means for a cloud service. Various libraries, APIs, and SLAs. These are some of the engaging discussions that developed at the Platforms and Ecosystems &#8220;Birds of a Feather&#8221;/&#8221;Unconference&#8221;, held on Tuesday evening March 8th during the CloudConnect 2011 [...]]]></description> <content:encoded><![CDATA[<p></p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F03%2Froundup-cloudconnect-2011-platforms-and-ecosystems-bof.html"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F03%2Froundup-cloudconnect-2011-platforms-and-ecosystems-bof.html&amp;source=shlomoswidler&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br
/> </a></div><div><p>The need for cloud provider price transparency. What is a workload and how to move it. &#8220;Open&#8221;ness and what it means for a cloud service. Various libraries, APIs, and SLAs. These are some of the engaging discussions that developed at the <a
href="http://shlomoswidler.com/2011/02/cloudconnect-2011-platforms-and-ecosystems-bof.html" target="_blank">Platforms and Ecosystems &#8220;Birds of a Feather&#8221;/&#8221;Unconference&#8221;</a>, held on Tuesday evening March 8th during the <a
href="http://www.cloudconnectevent.com/" target="_blank">CloudConnect 2011</a> conference. What about the BOF worked? What didn&#8217;t? What should be done differently in the future? Below are some observations gathered from early feedback; please leave your comments, too.</p><h2>Roundup</h2><p>In true unconference form, the discussions reflected what was on the mind of the audience. Some were more focused than others, and some were more contentious than others. Each turn of the wheel brought a new combination of experts, topics, themes, and participants.</p><p>Provider transparency was a hot subject, both for IaaS services and for PaaS services. When you consume a utility, such as water, you have a means to independently verify your usage: you can look at the water meter. Or, if you don&#8217;t trust the supplier&#8217;s meter, you can install your own meter on your main intake line. But with cloud services there is no way to measure many kinds of usage that you pay for &#8211; you must trust the provider to bill you correctly. How many Machine Hours did it take to process my SimpleDB query, or CPU Usage for my Google App Engine request? Is that internal IP address I&#8217;m communicating with in my own availability zone (and therefore free to communicate with) or in a different zone (and therefore costs money)? Today, the user&#8217;s only option is to trust the provider. Furthermore, it would be useful if we had tools to help estimate the cost of a particular workload. We look forward to more transparency in the future.</p><p>As they rotated through the topics, two of the themes generated similar discussions: Workload Portability and Avoiding Vendor Lock-in. The themes are closely related, so this is not surprising. Lesson learned: next time use themes that are more orthogonal, to explore the ecosystem more thoroughly.</p><p>In total nine planned discussions took place over the 90 minutes. A few interesting breakaway conversations spun off as well, as people opted to explore other aspects separately from the main discussions. I think that&#8217;s great: it means we got people thinking and engaged, which was the goal.</p><p>Some points for improvement: The room was definitely too small and the acoustics lacking. We had a great turnout &#8211; over 130 people, despite competing with the OpenStack party &#8211; but the undersized room was very noisy and some of the conversations were difficult to follow. Next time: a bigger room. And more pizza: the pizza ran out during the first round of discussions.</p><p>Participants who joined after the BOF had kicked off told me they were confused about the format. It is not easy to join in the middle of this kind of format and know what&#8217;s going on. In fact, I spent most of the time orienting newcomers as they arrived. Lesson learned: next time show a slide explaining the format, and have it displayed prominently throughout the entire event for easy reference.</p><p>Overall the BOF was very successful: lots of smart people having interesting discussions in every corner of the room. Would you participate in another event of this type? Please leave a comment with your feedback.</p><h2>Thanks</h2><p>Many thanks to the moderators who conducted each discussion, and the experts who contributed their experience and ideas. These people are: Dan Koffler, Ian Rae, Steve Wylie, David Bernstein, Adrian Cole, Ryan Dunn, Bernard Golden, Alex Heneveld, Sam Johnston, David Kavanagh, Ben Kepes, Tony Lucas, David Pallman, Jason Read, Steve Riley, Andrew Shafer, Jeroen Tjepkema, and James Urquhart. Thanks also to Alistair Croll not only for chairing a great CloudConnect conference overall, but also for inspiring the format of this BOF.</p><p>And thanks to all the participants &#8211; we couldn&#8217;t have done it without you.</p></div> <img src="http://feeds.feedburner.com/~r/CloudDeveloperTips/~4/5sEbh8yS1fc" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://shlomoswidler.com/2011/03/roundup-cloudconnect-2011-platforms-and-ecosystems-bof.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://shlomoswidler.com/2011/03/roundup-cloudconnect-2011-platforms-and-ecosystems-bof.html</feedburner:origLink></item> <item><title>Recapture Unused EC2 Minutes</title><link>http://feedproxy.google.com/~r/CloudDeveloperTips/~3/OiowTvg8cZ0/recapture-unused-ec2-minutes.html</link> <comments>http://shlomoswidler.com/2011/02/recapture-unused-ec2-minutes.html#comments</comments> <pubDate>Mon, 28 Feb 2011 20:43:31 +0000</pubDate> <dc:creator>shlomo</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[aws]]></category> <category><![CDATA[ec2]]></category><guid isPermaLink="false">http://shlomoswidler.com/?p=262</guid> <description><![CDATA[How much time is &#8220;wasted&#8221; in the paid-for but unused portion of the hour when you terminate an instance? How can you recapture this time &#8211; which represents compute power &#8211; and put it to good use? After all, you&#8217;ve paid for it already. This article presents a technique for repurposing an instance after you&#8217;re [...]]]></description> <content:encoded><![CDATA[<p></p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F02%2Frecapture-unused-ec2-minutes.html"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F02%2Frecapture-unused-ec2-minutes.html&amp;source=shlomoswidler&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br
/> </a></div><p>How much time is &#8220;wasted&#8221; in the paid-for but unused portion of the hour when you terminate an instance? How can you recapture this time &#8211; which represents compute power &#8211; and put it to good use? After all, you&#8217;ve paid for it already. This article presents a technique for repurposing an instance after you&#8217;re &#8220;done&#8221; with it, until the current billing hour is up. It&#8217;s inspired by a <a
href="http://twitter.com/DEVOPS_BORAT/status/41360261902381056" target="_blank">tweet from DEVOPS_BORAT</a>:</p><p
style="text-align: center;"><a
href="http://blogstatic.shlomoswidler.com.s3.amazonaws.com/wp-content/uploads/2011/02/devops_borat.png"><img
class="size-full wp-image-275 aligncenter" title="devops_borat" src="http://blogstatic.shlomoswidler.com.s3.amazonaws.com/wp-content/uploads/2011/02/devops_borat.png" alt="We have new startup CloudJanitor. We recycle old or unuse cloud instance. Need only your cloud account login!" width="545" height="253" /></a></p><p
style="text-align: left;">To clarify, we&#8217;re talking about per-hour pricing in public cloud IaaS services, where partial hours consumed are billed as whole hours. AWS EC2 is the most prominent example of a cloud sporting this <a
href="http://aws.amazon.com/ec2/#pricing" target="_blank">pricing policy</a> (search for &#8220;partial&#8221;). In this pricing policy, terminating (or stopping) an instance after it&#8217;s been running for 121 minutes results in a usage charge for three hours, &#8220;wasting&#8221; an extra 59 minutes that you have paid for but not used.</p><h2>What&#8217;s Involved</h2><p>You might think it&#8217;s easy to repurpose an instance: just Stop it (if it&#8217;s EBS-backed), change its root volume to a new one, and Start the instance again. Not so fast: Stopping an EC2 instance immediately ends the current billing hour before you can use it all, and when you Start the instance again a new billing hour begins &#8211; so we can&#8217;t Stop the instance. We also can&#8217;t Terminate the instance &#8211; that would also immediately curtail the billing hour and prevent us from utilizing it. Instead, we&#8217;re going to reboot the instance, which does not affect the billing.</p><p>We&#8217;ll need an EBS volume that has a bootable distro on it &#8211; let&#8217;s call this the &#8220;beneficiary&#8221; volume, because it&#8217;s going to benefit from the extra time on the clock. The beneficiary volume should have the same distro as the &#8220;normal&#8221; root volume has. [Actually, to be more precise, it need only have a distro that works with the same kernel that the instance is currently running.] I&#8217;ve tested this technique with Ubuntu 10.04 Lucid and 10.10 Maverick.</p><p>One of the great things about the Ubuntu images is how easy it is to play this root volume switcheroo: these distros boot from any volume that has the label <code>uec-rootfs</code>. To change the root volume we&#8217;ll change the volume labels, so a different volume is used as the root filesystem upon reboot.</p><p>It&#8217;s very important to disassociate the instance from all external hooks, such as Auto-Scaling Triggers and Elastic Load Balancers before you repurpose it. Otherwise the beneficiary workload will influence those no-longer-relevant systems. However, this may not be possible if you use hooks that cannot be de-coupled from the instance, such as a CloudWatch Dimension of <code>ImageId</code>, <code>InstanceId</code>, or <code>InstanceType</code>.</p><p>The network I/O incurred during the recaptured time may be subject to additional charges. In EC2, only communications between instances in the same availability zone, or between EC2 and S3 in the same region, are free of charge.</p><p>You&#8217;ll need to make sure the beneficiary workload only accepts communications on ports that are open in the normal instance&#8217;s security groups. It&#8217;s not possible to add or remove security groups while an instance is running. You also wouldn&#8217;t want to be modifying the security groups dynamically because that will influence all instances in those security groups &#8211; and you may have other instances that are still performing their normal workload.</p><p>The really cool thing about this technique is that it can be used on both EBS-backed and instance-store instances. However, you&#8217;ll need to prepare separate beneficiary volumes (or snapshots) for 32-bit and 64-bit instances.</p><h2>How to Do it</h2><p>There are three stages in repurposing an instance:</p><ol><li>Preparing the beneficiary volume (or snapshot).</li><li>Preparing the normal workload image.</li><li>Actually repurposing the instance.</li></ol><p>Stages 1 and 2 are only performed once. Stage 3 is performed for every instance you want to repurpose.</p><h3>Preparing the beneficiary snapshot</h3><p>First we&#8217;re going to prepare the beneficiary snapshot. Beginning with a pristine Ubuntu 10.10 Maverick EBS-based instance (at the time of publishing this article that&#8217;s <code>ami-ccf405a5</code> for 32-bit instances), let&#8217;s create a clone of the root filesystem:</p><p><code>ec2-run-instances ami-ccf405a5 -k my-keypair -t m1.small -g default</code></p><p><code>ec2-describe-instances $instanceId #use the instanceId outputted from the previous command</code></p><p>Wait for the instance to be &#8220;running&#8221;. Once it is, identify the volumeId of the root volume &#8211; it will be indicated in the ec2-describe-instances output, the one attached to device <code>/dev/sda1</code>.</p><p>At this point you have a running Ubuntu 10.10 instance. For real-world usage you&#8217;ll want to customize this instance by installing the beneficiary workload and arranging for it to automatically start up on boot. (I recommend <a
href="http://folding.stanford.edu/" target="_blank">Folding@home</a> as a worthy beneficiary project.)</p><p>Now we create the beneficiary snapshot:</p><p><code>ec2-create-snapshot $volumeId #use the volumeId from the previous command</code></p><p>And now we have the beneficiary snapshot.</p><h3>Preparing the normal workload image</h3><p>Begin with the same base AMI that you used for the beneficiary snapshot. Launch it and customize it to contain your normal workload stuff. You&#8217;ll also need to put in a custom script that will perform the repurposing. Here&#8217;s what that script will do:</p><ol><li>Determine how much time is left on the clock in the current billing hour. If it&#8217;s not enough time to prepare and to reboot into the beneficiary volume, just force ourselves to shut down.</li><li>Disassociate any external hooks the instance might participate in: remove it from ELBs, force it to fail any Auto-Scaling health checks, and make sure it&#8217;s not handling &#8220;normal&#8221; workloads anymore.</li><li>Attach the beneficiary volume to the instance.</li><li>Change the volume labels so the beneficiary volume will become the root filesystem at the next reboot.</li><li>Edit the startup scripts on the beneficiary volume to start a self-destruct timer.</li><li>Reboot.</li></ol><p>The following script performs steps 1, 4, 5, and 6, and clearly indicates where you should perform steps 2 and 3.</p><pre><code>#! /bin/bash
# reboot into the attached EBS volume on the specified device, but terminate
# before this billing hour is complete.
# requires the first argument to be the device on which the EBS volume is attached

device=$1
safetyMarginMinutes=1 # set this to how long it takes to attach and reboot

# make sure we have at least "safetyMargin" minutes left this hour
t=/tmp/ec2.running.seconds.$$
if wget -q -O $t http://169.254.169.254/latest/meta-data/local-ipv4 ; then
	# add 60 seconds artificially as a safety margin
	let runningSecs=$(( `date +%s` - `date -r $t +%s` ))+60
	rm -f $t
	let runningSecsThisHour=$runningSecs%3600
	let runningMinsThisHour=$runningSecsThisHour/60
	let leftMins=60-$runningMinsThisHour-$safetyMarginMinutes
	# start shutdown one minute earlier than actually required
	let shutdownDelayMins=$leftMins-1
	if [[ $shutdownDelayMins &lt; 2 || $shutdownDelayMins &gt; 59 ]]; then
		echo "Shutting down now."
		shutdown -h now
		exit 0
	fi
fi

## here is where you would disassociate this instance from ELBs,
# force it to fail AutoScaling health checks, and otherwise make sure
# it does not participate in "normal" activities.

## here is where you would attach the beneficiary volume to $device
# ec2-create-volume --snapshot snap-00000000 -z this_availability_zone
# dont forget to wait until the volume is "available"

# ec2-attach-volume . . . and don't forget to wait until the volume is "attached"

## (optionally) force the beneficiary volume to be deleted when this instance terminates:
# ec2-modify-instance-attribute --block-device-mapping '$device=::true' this_instance_id

## get the beneficiary volume ready to be rebooted into
# change the filesystem labels
e2label /dev/sda1 old-uec-rootfs
e2label $device uec-rootfs
# mount the beneficiary volume
mountPoint=/tmp/mountPoint.$$
mkdir -m 000 $mountPoint
mount $device $mountPoint
# install the self-destruct timer
sed -i -e "s/^exit 0$/shutdown -h +$shutdownDelayMins\nexit 0/" \
	$mountPoint/etc/rc.local
# neutralize the self-destruct for subsequent boots
sed -i -e "s#^exit 0#chmod -x /etc/rc.local\nexit 0#" $mountPoint/etc/rc.local
# get out
umount $mountPoint
rmdir $mountPoint

# do the deed
shutdown -r now
exit 0
</code></pre><p>Save this script into the instance you&#8217;re preparing for the normal workload (perhaps, as the root user, into <code>/root/repurpose-instance.sh</code>) and <code>chmod</code> it to 744.</p><p>Now, make your application detect when its normal workload is completed &#8211; this exact method will be very specific to your application. Add in a hook there to invoke this script as the root user, passing it the device on which the beneficiary volume will be attached. For example, the following command will cause the instance to repurpose itself to a volume attached on /dev/sdp:</p><p><code>sudo /root/repurpose-instance.sh /dev/sdp</code></p><p>Once all this is set up, use the usual EC2 AMI creation methods to create your normal workload image (either as an instance-store AMI or as an EBS-backed AMI).</p><h3>Actually repurposing the instance</h3><p>Now that everything is prepared, this is the easy part. Your normal workload image can be launched. When it is finished, the repurposing script will be invoked and the instance will be rebooted into the beneficiary volume. The repurposed instance will self-destruct before the billing hour is complete.</p><p>You can force this repurposing to happen by explicitly invoking the command at an SSH prompt on the instance:</p><p><code>sudo /root/repurpose-instance.sh /dev/sdp</code></p><p>Notice that you will be immediately kicked out of your SSH session &#8211; either the instance will reboot or the instance will terminate itself because there isn&#8217;t enough time left in the current billable hour. If it&#8217;s just a reboot (which happens when there is significant time left in the current billing hour) then be aware: the SSH host key will most likely be different on the repurposed instance than it was originally, and you may need to clean up your local <code>~/.ssh/known_hosts</code> file, removing the entry for the instance, before you can SSH in again.</p> <img src="http://feeds.feedburner.com/~r/CloudDeveloperTips/~4/OiowTvg8cZ0" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://shlomoswidler.com/2011/02/recapture-unused-ec2-minutes.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://shlomoswidler.com/2011/02/recapture-unused-ec2-minutes.html</feedburner:origLink></item> <item><title>Play “Chicken” with Spot Instances</title><link>http://feedproxy.google.com/~r/CloudDeveloperTips/~3/Gr_4c4RODCo/play-chicken-with-spot-instances.html</link> <comments>http://shlomoswidler.com/2011/02/play-chicken-with-spot-instances.html#comments</comments> <pubDate>Sun, 27 Feb 2011 12:13:42 +0000</pubDate> <dc:creator>shlomo</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[spot instance]]></category><guid isPermaLink="false">http://shlomoswidler.com/?p=266</guid> <description><![CDATA[AWS Spot Instances have an interesting economic characteristic that make it possible to game the system a little. Like all EC2 instances, when you initiate termination of a Spot Instance then you incur a charge for the entire hour, even if you&#8217;ve used less than a full hour. But, when AWS terminates the instance due [...]]]></description> <content:encoded><![CDATA[<p></p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F02%2Fplay-chicken-with-spot-instances.html"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F02%2Fplay-chicken-with-spot-instances.html&amp;source=shlomoswidler&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br
/> </a></div><p>AWS Spot Instances have an interesting economic characteristic that make it possible to game the system a little. Like all EC2 instances, when you initiate termination of a Spot Instance then you incur a charge for the entire hour, even if you&#8217;ve used less than a full hour. But, when AWS terminates the instance due to the spot price exceeding the bid price, you do not pay for the current hour.</p><p>What if your Spot Instance could wait, after finishing its work, to see if AWS will terminate it involuntarily in this hour and avoid the hour&#8217;s cost? In the worst case, your instance can kill itself in the last few minutes of the hour and you will not have incurred any extra unplanned cost. In the best case, the spot price will rise above the instance&#8217;s bid price before the hour is up, AWS will terminate the instance involuntarily, and you will not be charged for that entire hour. Wouldn&#8217;t this technique reduce costs, especially when performed at large scale?</p><p>I call this technique Playing Chicken, based on <a
href="http://en.wikipedia.org/wiki/Chicken_(game)" target="_blank">the game of that name</a>, because it shares similar characteristics to the game:</p><ul><li>Whoever &#8220;swerves&#8221; (terminates) first, loses (pays for the hour)</li><li>If nobody &#8220;swerves&#8221; (terminates), then an undesirable situation occurs (the instance remains running)</li></ul><h2>How to Play Chicken</h2><p>Playing Chicken is really as simple as running a script on the instance when you&#8217;re done with the work. Here&#8217;s such a script:</p><pre><code>#! /bin/bash
t=/tmp/ec2.running.seconds.$$
if wget -q -O $t http://169.254.169.254/latest/meta-data/local-ipv4 ; then
	# add 60 seconds artificially as a safety margin
	let runningSecs=$(( `date +%s` - `date -r $t +%s` ))+60
	rm -f $t
	let runningSecsThisHour=$runningSecs%3600
	let runningMinsThisHour=$runningSecsThisHour/60
	let leftMins=60-$runningMinsThisHour
	# start shutdown one minute earlier than actually required
	let shutdownDelayMins=$leftMins-1
	if [[ $shutdownDelayMins &gt; 1 &amp;&amp; $shutdownDelayMins &lt; 60 ]]; then
		echo "Shutting down in $shutdownDelayMins mins."
		# TODO: Notify off-instance listener that the game of chicken has begun
		sudo shutdown -h +$shutdownDelayMins
	else
		echo "Shutting down now."
		sudo shutdown -h now
	fi
	exit 0
fi
echo "Failed to determine remaining minutes in this billable hour. Terminating now."
sudo shutdown -h now
exit 1
</code></pre><p>This script uses the technique <a
href="http://www.somic.org/2009/06/04/how-long-ago-was-this-ec2-instance-started/" target="_blank">published by Dmitriy Samovskiy</a> to determine the launch time of the current instance without using the EC2 API, using the instance meta-data instead. We include a safety margin of two minutes: accounting for the remaining time conservatively adding 1 minute, and beginning the shutdown sequence one minute earlier.</p><p>You would run this script on the instance when the Spot Instance is done with its work <em>instead of</em> terminating the instance immediately. You also can add a hook at the indicated place to notify an off-instance listener that the game of chicken has begun, to allow you to track the savings delivered by this technique.</p><p>Warning: Make sure you really understand what this script does before you use it. If you mistakenly schedule an instance to be shut down you can cancel it with this command, run on the instance: <code>sudo shutdown -c</code></p><h2>How Much is Saved by Playing Chicken?</h2><p>The extent to which you can benefit from playing chicken depends on a number of factors:</p><ul><li>The difference between the spot price and your instance&#8217;s bid price. The further away the spot price is from your bid, the less likely it is that the spot price will hit the bid and save you money.</li><li>The volatility of the spot price. The more volatile the spot price, the more likely it will hit the bid and save you money.</li><li>The number of Spot Instances you terminate in a given period of time. If you normally don&#8217;t terminate any Spot Instances then you won&#8217;t save anything; if you terminate many then you can potentially save an hour&#8217;s worth of cost for each of them.</li><li>The EC2 Region and instance type. The actual spot price varies by region and instance type, so the potential savings depends on these factors as well.</li></ul><p>I&#8217;m looking for help to work out a model that can describe the potential savings. If you are interested and able to help with the financial math, please get in touch.</p><p><strong><em>Update:</em></strong> Hat tip to Simon Wardley who pointed out the site <a
href="http://cloudexchange.org/" target="_blank">CloudExchange</a> that shows great visualizations of the spot prices by region and instance type. This may help you formulate a bidding strategy.</p> <img src="http://feeds.feedburner.com/~r/CloudDeveloperTips/~4/Gr_4c4RODCo" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://shlomoswidler.com/2011/02/play-chicken-with-spot-instances.html/feed</wfw:commentRss> <slash:comments>3</slash:comments> <feedburner:origLink>http://shlomoswidler.com/2011/02/play-chicken-with-spot-instances.html</feedburner:origLink></item> <item><title>CloudConnect 2011 Platforms and Ecosystems BOF</title><link>http://feedproxy.google.com/~r/CloudDeveloperTips/~3/wmMVDgHwWz0/cloudconnect-2011-platforms-and-ecosystems-bof.html</link> <comments>http://shlomoswidler.com/2011/02/cloudconnect-2011-platforms-and-ecosystems-bof.html#comments</comments> <pubDate>Mon, 14 Feb 2011 12:33:58 +0000</pubDate> <dc:creator>shlomo</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[cloudconnect]]></category><guid isPermaLink="false">http://shlomoswidler.com/?p=245</guid> <description><![CDATA[This March 7-10 2011 I will be in Santa Clara for the CloudConnect conference. There are many reasons you should go too, and I&#8217;d like to highlight one session that you should not miss: the Platforms and Ecosystems BOF, on Tuesday March 8 at 6:00 &#8211; 7:30 PM. Read on for a detailed description of [...]]]></description> <content:encoded><![CDATA[<p></p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F02%2Fcloudconnect-2011-platforms-and-ecosystems-bof.html"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F02%2Fcloudconnect-2011-platforms-and-ecosystems-bof.html&amp;source=shlomoswidler&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br
/> </a></div><p>This March 7-10 2011 I will be in Santa Clara for the <a
href="http://www.cloudconnectevent.com/" target="_blank">CloudConnect conference</a>. There are many reasons you should go too, and I&#8217;d like to highlight one session that you should not miss: the Platforms and Ecosystems BOF, on Tuesday March 8 at 6:00 &#8211; 7:30 PM. Read on for a detailed description of this BOF session and why it promises to be worthwhile.</p><p>[<strong>Full disclosure</strong>: I'm the track chair for the Design Patterns track and I'm running the Platforms and Ecosystems BOF. The event organizers are sponsoring my hotel for the conference, and like all conference speakers my admission to the event is covered.]</p><p>CloudConnect 2011 promises to be a high-quality conference, as last year&#8217;s was. This year you will be able to learn all about design patterns for cloud applications in the <a
href="http://www.cloudconnectevent.com/cloud-computing-conference/design-patterns.php" target="_blank">Design Patterns track</a> I&#8217;m leading. You&#8217;ll also be able to hear from an <a
href="http://www.cloudconnectevent.com/2011/speaker-list/" target="_blank">all-star lineup</a> about many aspects of using cloud: <a
href="http://www.cloudconnectevent.com/cloud-computing-conference/cloud-economics.php" target="_blank">cloud economics</a>, <a
href="http://www.cloudconnectevent.com/cloud-computing-conference/cloudsec.php" target="_blank">cloud security</a>, <a
href="http://www.cloudconnectevent.com/cloud-computing-conference/culture-risks-and-governance.php" target="_blank">culture, risks, and governance</a>, <a
href="http://www.cloudconnectevent.com/cloud-computing-conference/data-and-storage.php" target="_blank">data and storage</a>, <a
href="http://www.cloudconnectevent.com/cloud-computing-conference/devops-and-automation.php" target="_blank">devops and automation</a>, <a
href="http://www.cloudconnectevent.com/cloud-computing-conference/performance-and-monitoring.php" target="_blank">performance and monitoring</a>, and <a
href="http://www.cloudconnectevent.com/cloud-computing-conference/private-clouds.php" target="_blank">private clouds</a>.</p><p>But I&#8217;m most looking forward to the Platforms and Ecosystems BOF because the format of the event promises to foster great discussions.</p><h2>The BOF Format</h2><p>The BOF will be conducted as a&#8230; well, it&#8217;s hard to describe in words only, so here is a picture:</p><p><a
href="http://blogstatic.shlomoswidler.com.s3.amazonaws.com/wp-content/uploads/2011/02/BOF-overview.png"><img
class="alignleft size-full wp-image-257" title="BOF-overview" src="http://blogstatic.shlomoswidler.com.s3.amazonaws.com/wp-content/uploads/2011/02/BOF-overview.png" alt="BOF Overview" width="720" height="540" /></a></p><p>At three fixed points around the outside of the room will be three topics: Public IaaS, Public PaaS, and Private Cloud Stacks. There will also be three themes which rotate around the room at each interval; these themes are: Workload Portability, Monitoring &amp; Control, and Avoiding Vendor Lock-in. At any one time there will be three discussions taking place, one in each corner, focusing on the particular combination of that theme and topic.</p><p>Here is an example of the first set of discussions:</p><p><a
href="http://blogstatic.shlomoswidler.com.s3.amazonaws.com/wp-content/uploads/2011/02/BOF-1.png"><img
class="alignleft size-full wp-image-258" title="BOF Session 1" src="http://blogstatic.shlomoswidler.com.s3.amazonaws.com/wp-content/uploads/2011/02/BOF-1.png" alt="BOF Session 1" width="720" height="540" /></a></p><p>And here is the second set of discussions, which will take place after one &#8220;turn&#8221; of the inner &#8220;wheel&#8221;:</p><p><a
href="http://blogstatic.shlomoswidler.com.s3.amazonaws.com/wp-content/uploads/2011/02/BOF-2.png"><img
class="alignleft size-full wp-image-256" title="BOF Session 2" src="http://blogstatic.shlomoswidler.com.s3.amazonaws.com/wp-content/uploads/2011/02/BOF-2.png" alt="BOF Session 2" width="720" height="540" /></a></p><p>And here is the final set of discussions, after the second turn of the inner wheel:</p><p><a
href="http://blogstatic.shlomoswidler.com.s3.amazonaws.com/wp-content/uploads/2011/02/BOF-3.png"><img
class="alignleft size-full wp-image-255" title="BOF Session 3" src="http://blogstatic.shlomoswidler.com.s3.amazonaws.com/wp-content/uploads/2011/02/BOF-3.png" alt="BOF Session 3" width="720" height="540" /></a></p><p>In all, nine discussions are conducted. Here is a single matrix to summarize:</p><p><a
href="http://blogstatic.shlomoswidler.com.s3.amazonaws.com/wp-content/uploads/2011/02/BOF-matrix.png"><img
class="alignleft size-full wp-image-254" title="BOF Summary Matrix" src="http://blogstatic.shlomoswidler.com.s3.amazonaws.com/wp-content/uploads/2011/02/BOF-matrix.png" alt="BOF Summary Matrix" width="720" height="540" /></a></p><h2>Anatomy of a Discussion</h2><p>What makes a discussion worthwhile? Interesting questions, focus, and varied opinions. The discussions in the BOF will have all of these elements.</p><h3>Interesting Questions</h3><p>The questions above are just &#8220;seeder&#8221; questions. They are representative questions related to the intersection of each topic and theme, but they are by no means the only questions. Do you have questions you&#8217;d like to see discussed? Please, leave a comment below. Better yet, attend the BOF and raise them there, in the appropriate discussion.</p><h3>Focus</h3><p>Nothing sucks more than a pointless tangent or a a single person monopolizing the floor. Each discussion will be shepherded by a capable moderator, who will keep things focused on the subject area and encourage everyone&#8217;s participation.</p><h3>Varied Opinions</h3><p>Topic experts and theme experts will participate in every discussion.</p><p>Vendors will be present as well &#8211; but the moderators will make sure they do not abuse the forum.</p><p>And interested parties &#8211; such as you! &#8211; will be there too. In unconference style, the audience will drive the discussion.</p><p>These three elements all together provide the necessary ingredients to make sure things stay interesting.</p><h2>At the Center</h2><p>What, you may ask, is at the center of the room? I&#8217;m glad you asked. There&#8217;ll be beer and refreshments at the center. This is also where you can conduct spin-off discussions if you like.</p><p>The Platforms and Ecosystems BOF at CloudConnect is the perfect place to bring your cloud insights, case studies, anecdotes, and questions. It&#8217;s a great forum to discuss the ideas you&#8217;ve picked up during the day at the conference, in a less formal atmosphere where deep discussion is on the agenda.</p><p>Here&#8217;s a discount code for 25% off <a
href="http://www.cloudconnectevent.com/registration/" target="_blank">registration</a>: <code>CNXFCC03</code>. I hope to see you there.</p> <img src="http://feeds.feedburner.com/~r/CloudDeveloperTips/~4/wmMVDgHwWz0" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://shlomoswidler.com/2011/02/cloudconnect-2011-platforms-and-ecosystems-bof.html/feed</wfw:commentRss> <slash:comments>4</slash:comments> <feedburner:origLink>http://shlomoswidler.com/2011/02/cloudconnect-2011-platforms-and-ecosystems-bof.html</feedburner:origLink></item> <item><title>Lessons Learned from Using Multiple Cloud APIs</title><link>http://feedproxy.google.com/~r/CloudDeveloperTips/~3/fRdj9Pcv4ow/lessons-learned-from-using-multiple-cloud-apis.html</link> <comments>http://shlomoswidler.com/2011/01/lessons-learned-from-using-multiple-cloud-apis.html#comments</comments> <pubDate>Thu, 27 Jan 2011 07:00:35 +0000</pubDate> <dc:creator>shlomo</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[apis]]></category> <category><![CDATA[devops]]></category> <category><![CDATA[jclouds]]></category><guid isPermaLink="false">http://shlomoswidler.com/?p=243</guid> <description><![CDATA[Adrian Cole, author of the jClouds library, has an excellent writeup of the trajectory the library&#8217;s development followed as it added support for more cloud providers&#8217; APIs. [Update August 2011: Blogger.com has removed Adrian's blog so that link no longer works.] Some important takeaways for application developers: Your unit tests are as valuable as your [...]]]></description> <content:encoded><![CDATA[<p></p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F01%2Flessons-learned-from-using-multiple-cloud-apis.html"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F01%2Flessons-learned-from-using-multiple-cloud-apis.html&amp;source=shlomoswidler&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br
/> </a></div><p>Adrian Cole, author of the <a
href="http://www.jclouds.org/" target="_blank">jClouds</a> library, has an <a
href="http://anyweight.blogspot.com/2011/01/in-beginning-there-was-stub.html" target="_blank" class="broken_link">excellent writeup of the trajectory the library&#8217;s development followed</a> as it added support for more cloud providers&#8217; APIs.</p><p><em><strong>[Update August 2011</strong></em>: Blogger.com has removed Adrian's blog so that link no longer works.]</p><p>Some important takeaways for application developers:</p><ul><li>Your unit tests are as valuable as your code. The tests ensure the code works to spec, and they should be used as frequently as possible during development.</li><li>Make your code easy to test, with sensible defaults that require no external dependencies: e.g. don&#8217;t require internet connectivity.</li><li>Cloud  limitations, both general (such as eventual consistency) and cloud-specific (such as a limit on the number of buckets per S3 account), will require careful consideration in your code (and tests).</li><li>Some things can only really be tested against a live cloud service. As Adrian points out, the only way to test that an instance launched with the desired customizations is to ssh in to that instance and explore it from the inside. This is not testable using an offline stub emulator.</li></ul><p><strong>But the key lesson developers can learn </strong>is: Whenever possible, use an existing library to interface with your clouds. As Adrian&#8217;s post makes patently clear, a lot of effort goes into ensuring the library works properly with the various supported APIs, and you can only benefit by leveraging those accomplishments.</p><p>On the other side of the fence, API developers can also learn from Adrian&#8217;s article. As William Vambenepe <a
href="http://stage.vambenepe.com/archives/1712" target="_blank" class="broken_link">recently commented</a>:</p><blockquote><p>Rather than spending hours obsessing about the finer points of your API, spend the time writing love letters to [<a
href="http://code.google.com/p/boto/" target="_blank">boto</a> author] <a
href="http://twitter.com/garnaat">Mitch</a> and <a
href="https://twitter.com/adrianfcole">Adrian</a> so they support you in their libraries.</p></blockquote><p>In fact, Adrian&#8217;s blog can be viewed as a TODO list for API creators who want to encourage adoption.</p><p>API authors should also refer to Steve Loughran&#8217;s <a
href="http://1060.org/blogxter/entry?publicid=12CE2B62F71239349F3E9903EAE9D1F0&amp;token=" target="_blank">Cloud Tools Manifesto</a> for more great ideas on how to make life easy for developers.</p> <img src="http://feeds.feedburner.com/~r/CloudDeveloperTips/~4/fRdj9Pcv4ow" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://shlomoswidler.com/2011/01/lessons-learned-from-using-multiple-cloud-apis.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://shlomoswidler.com/2011/01/lessons-learned-from-using-multiple-cloud-apis.html</feedburner:origLink></item> <item><title>AWS Auto-Scaling and ELB with Reliable Root Domain Handling</title><link>http://feedproxy.google.com/~r/CloudDeveloperTips/~3/8qYe54_VaVE/aws-auto-scaling-and-elb-with-reliable-root-domain-handling.html</link> <comments>http://shlomoswidler.com/2011/01/aws-auto-scaling-and-elb-with-reliable-root-domain-handling.html#comments</comments> <pubDate>Mon, 24 Jan 2011 15:56:42 +0000</pubDate> <dc:creator>shlomo</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[auto scaling]]></category> <category><![CDATA[aws]]></category> <category><![CDATA[dns]]></category> <category><![CDATA[elastic load balancing]]></category> <category><![CDATA[elb]]></category><guid isPermaLink="false">http://shlomoswidler.com/?p=236</guid> <description><![CDATA[Update May 2011: Now that AWS Route 53 can be used to allow an ELB to host a domain zone apex, the technique described here is no longer necessary. Cool, but not necessary. Someone really has to implement this. I&#8217;ve had this draft sitting around ever since AWS announced support for improved CloudWatch alerts and [...]]]></description> <content:encoded><![CDATA[<p></p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F01%2Faws-auto-scaling-and-elb-with-reliable-root-domain-handling.html"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F01%2Faws-auto-scaling-and-elb-with-reliable-root-domain-handling.html&amp;source=shlomoswidler&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br
/> </a></div><p><em><strong>Update May 2011</strong></em>: Now that <a
href="http://aws.typepad.com/aws/2011/05/moving-ahead-with-amazon-route-53.html" _mce_href="http://aws.typepad.com/aws/2011/05/moving-ahead-with-amazon-route-53.html">AWS Route 53 can be used to allow an ELB to host a domain zone apex</a>, the technique described here is no longer necessary. Cool, but not necessary.</p><p>Someone really has to implement this. I&#8217;ve had this draft sitting around ever since AWS announced support for improved CloudWatch alerts and AutoScaling policies (August 2010), but I haven&#8217;t yet turned it into a clear set of commands to follow. If you do, please comment.</p><h2>Background</h2><p>You want an auto-scaled, load-balanced pool of web servers to host your site at example.com. Unfortunately it&#8217;s not so simple, because AWS Elastic Load Balancer can&#8217;t be used to host a domain apex (AKA a root domain). <a
href="https://forums.aws.amazon.com/message.jspa?messageID=185427" _mce_href="https://forums.aws.amazon.com/message.jspa?messageID=185427" target="_blank">One of the longest threads on the AWS Developer Forum discusses this limitation</a>: because ELB utilizes DNS CNAMEs, which are not legal for root domain entries, ELB does not support root domains.</p><p>An often-suggested workaround is to use an instance with an Elastic IP address to host the root domain, via standard static DNS, with the web server redirecting all root domain requests to the subdomain (www) served by the ELB. There are four drawbacks to this approach:</p><ol><li>The instance with the Elastic IP address is liable to be terminated by auto-scaling, leaving requests to the root domain unanswered.</li><li>The instance with the Elastic IP address might fail unnaturally, again leaving requests to the root domain unanswered.</li><li>Even when traffic is very low, we need at least two instances running: the one handling the root domain outside the auto-scaled ELB group (due to issue #1) and the one inside the auto-scaled ELB group (to handle the actual traffic hitting the ELB-managed subdomain).</li><li>The redirect adds additional latency to requests hitting the root domain.</li></ol><p>While we can&#8217;t do anything about the fourth issue, what follows is a technique to handle the first three issues.</p><h2>The Idea</h2><p>The idea is built on these principles:</p><ul><li>The instance with the Elastic IP is outside the auto-scaled group so it will not be terminated by auto-scaling.</li><li>The instance with the Elastic IP is managed using AWS tools to ensure the root domain service is automatically recovered if the instance dies unexpectedly.</li><li>The auto-scaling group can scale back to zero size, so only a single instance is required to serve low traffic volumes.</li></ul><p>How do we put these together?</p><p>Here&#8217;s how:</p><ol><li>Create an AMI for your web server. The AMI will need some special boot-time hooks, which are described below<em> in italics</em>. The web server should be set up to redirect root domain traffic to the subdomain that you&#8217;ll want to associate with the ELB, and to serve the subdomain normally.</li><li>Create an ELB for the site&#8217;s subdomain with a meaningful Health Check (e.g. a URL that exercises representative areas of the application).</li><li>Create an AutoScaling group with min=1 and max=1 instances of that AMI. This AutoScaling group will benefit from the default health checks that such groups have, and if EC2 reports the instance is degraded it will be replaced. The LaunchConfiguration for this AutoScaling group should <em>specify user-data that indicates this instance is the &#8220;root domain&#8221; instance. Upon booting, the instance will notice this flag in the user data, associate the Elastic IP address with itself, an add itself to the ELB</em>.<br
/> <strong>Note: </strong>At this point, we have a reliably-hosted single instance hosting the root domain and the subdomain.</li><li>Create a second AutoScaling group (the &#8220;ELB AutoScaling group&#8221;) that uses the same AMI, with min=0 instances &#8211; the max can be anything you want it to &#8211; and set it up to use the ELB&#8217;s Health Check. The LaunchConfiguration for this group should not contain the abovementioned special flag &#8211; these are not root domain instances.</li><li>Create an Alarm that looks at the CPUUtilization across all instances of the AMI, and connect it to the &#8220;scale up&#8221; and &#8220;scale down&#8221; Policies for the ELB AutoScaling group.</li></ol><p>That is the basic idea. The result will be:</p><ul><li>The root domain is hosted on an instance that redirects to the ELB subdomain. This instance is managed by a standalone Auto Scaling group that will replace the instance if it becomes degraded. This instance is also a member of the ELB, so it serves the subdomain traffic as well.</li><li>A second AutoScaling group manages the &#8220;overflow&#8221; traffic, measured by the CPUUtilization of all the running instances of the AMI.</li></ul><h2>TODO</h2><p>Here are the missing pieces:</p><ol><li>A script that can be run as a boot-time hook that checks the user-data for a special flag. When this flag is detected, the script associates the root domain&#8217;s Elastic IP address (which should be specified in the user-data) and adds the instance to the ELB (whose name is also specified in the user-data). This will likely require AWS Credentials to be placed on the instance &#8211; perhaps in the user-data itself (be sure you <a
href="http://shlomoswidler.com/2009/08/how-to-keep-your-aws-credentials-on-ec2.html" _mce_href="http://shlomoswidler.com/2009/08/how-to-keep-your-aws-credentials-on-ec2.html" target="_blank">understand the security implications of this</a>) as well as a library such as boto or the AWS SDK to perform the AWS API calls.</li><li>The explicit step-by-step instructions for carrying out steps 1 through 5 above using the relevant AWS command-line tools.</li></ol><p>Do you have these missing pieces? If so, please comment.</p> <img src="http://feeds.feedburner.com/~r/CloudDeveloperTips/~4/8qYe54_VaVE" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://shlomoswidler.com/2011/01/aws-auto-scaling-and-elb-with-reliable-root-domain-handling.html/feed</wfw:commentRss> <slash:comments>6</slash:comments> <feedburner:origLink>http://shlomoswidler.com/2011/01/aws-auto-scaling-and-elb-with-reliable-root-domain-handling.html</feedburner:origLink></item> <item><title>Using Elastic Beanstalk via command-line on a Mac? Keep that OS X Install DVD handy</title><link>http://feedproxy.google.com/~r/CloudDeveloperTips/~3/sHkhDv7MXdk/using-elastic-beanstalk-via-command-line-on-a-mac-keep-that-os-x-install-dvd-handy.html</link> <comments>http://shlomoswidler.com/2011/01/using-elastic-beanstalk-via-command-line-on-a-mac-keep-that-os-x-install-dvd-handy.html#comments</comments> <pubDate>Thu, 20 Jan 2011 04:59:06 +0000</pubDate> <dc:creator>shlomo</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[aws]]></category> <category><![CDATA[beanstalk]]></category> <category><![CDATA[cli]]></category> <category><![CDATA[osx]]></category><guid isPermaLink="false">http://shlomoswidler.com/?p=231</guid> <description><![CDATA[The title pretty much says it all. Elastic Beanstalk is the new service from Amazon Web Services offering you easier deployment of Java WAR files. More languages and platforms are expected to be supported in the future. Most people will use the service via the convenient web console, but if you want to automate things [...]]]></description> <content:encoded><![CDATA[<p></p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F01%2Fusing-elastic-beanstalk-via-command-line-on-a-mac-keep-that-os-x-install-dvd-handy.html"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fshlomoswidler.com%2F2011%2F01%2Fusing-elastic-beanstalk-via-command-line-on-a-mac-keep-that-os-x-install-dvd-handy.html&amp;source=shlomoswidler&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br
/> </a></div><p>The title pretty much says it all.</p><p><a
href="http://aws.amazon.com/elasticbeanstalk/" target="_blank">Elastic Beanstalk</a> is the new service from Amazon Web Services offering you easier deployment of Java WAR files. More languages and platforms are expected to be supported in the future.</p><p>Most people will use the service via the convenient <a
href="https://console.aws.amazon.com/elasticbeanstalk/home" target="_blank">web console</a>, but if you want to automate things you&#8217;ll either end up using the <a
href="http://aws.amazon.com/code/6752709412171743" target="_blank">command-line tools (CLI tools)</a> or the API in the <a
href="http://aws.amazon.com/sdkforjava/" target="_blank">Java SDK</a> (until their other SDKs add Beanstalk support).</p><p>But, if you&#8217;re running on a Mac, you&#8217;ll have a problem running the command-line tools:</p><blockquote><p><code>Shlomos-MacBook-Pro:ec2 shlomo$ elastic-beanstalk-describe-applications/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- json (LoadError)<br
/> from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'<br
/> from /Users/shlomo/ec2/elasticbeanstalk/bin/../lib/aws/client/awsqueryhandler.rb:2<br
/> from /Users/shlomo/ec2/elasticbeanstalk/bin/../lib/aws/client/awsquery.rb:4:in `require'<br
/> from /Users/shlomo/ec2/elasticbeanstalk/bin/../lib/aws/client/awsquery.rb:4<br
/> from /Users/shlomo/ec2/elasticbeanstalk/bin/../lib/aws/elasticbeanstalk.rb:19:in `require'<br
/> from /Users/shlomo/ec2/elasticbeanstalk/bin/../lib/aws/elasticbeanstalk.rb:19<br
/> from /Users/shlomo/ec2/elasticbeanstalk/bin/setup.rb:18:in `require'<br
/> from /Users/shlomo/ec2/elasticbeanstalk/bin/setup.rb:18<br
/> from /Users/shlomo/ec2/elasticbeanstalk/bin/elastic-beanstalk-describe-applications:18:in `require'<br
/> from /Users/shlomo/ec2/elasticbeanstalk/bin/elastic-beanstalk-describe-applications:18</code></p></blockquote><p>If you remember from the README (which you read, of course <img
src='http://blogstatic.shlomoswidler.com.s3.amazonaws.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> there was some vague mention of this:</p><blockquote><p><code>If you're using Ruby 1.8, you will have to install the JSON gem:<br
/> gem install json</code></p></blockquote><p>OK, let&#8217;s try that:</p><blockquote><p><code>Shlomos-MacBook-Pro:ec2 shlomo$ sudo gem install json<br
/> Building native extensions.  This could take a while...<br
/> ERROR:  Error installing json:<br
/> ERROR: Failed to build gem native extension.</code></p><p><code>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb<br
/> mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h</code></p><p><code> </code><code>Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/json-1.4.6 for inspection.<br
/> Results logged to /Library/Ruby/Gems/1.8/gems/json-1.4.6/ext/json/ext/generator/gem_make.out</code></p></blockquote><p>The first complaint is about the ruby tools not being in the path. Let&#8217;s fix that and try again:</p><blockquote><p><code>Shlomos-MacBook-Pro:ec2 shlomo$ export PATH=$PATH:/Users/shlomo/.gem/ruby/1.8/bin<br
/> Shlomos-MacBook-Pro:ec2 shlomo$ sudo gem install json<br
/> Building native extensions.  This could take a while...<br
/> ERROR:  Error installing json:<br
/> ERROR: Failed to build gem native extension.</code></p><p><code>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb<br
/> mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h</code></p><p><code> </code><code>Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/json-1.4.6 for inspection.<br
/> Results logged to /Library/Ruby/Gems/1.8/gems/json-1.4.6/ext/json/ext/generator/gem_make.out<br
/> </code></p></blockquote><p>Uh oh, no dice. What now? <a
href="http://stackoverflow.com/questions/761521/when-i-try-sudo-gem-install-json-i-get-the-following-error" target="_blank">StackOverflow to the rescue</a>:</p><blockquote><p>The ruby headers don’t come installed with the base ruby install with Mac OS X. These can been found on Mac OS X Install Disc 2 by installing the XCode Tools.</p></blockquote><p>If you&#8217;re like me and you don&#8217;t carry around the OS X Install DVD wherever you go, you&#8217;re stuck.<br
/> Any readers in Seoul with an OS X 10.6 Install DVD?</p><p><em><strong>Update 20 Jan 2011:</strong></em> I&#8217;ve gotten some comments that made me realize the title really didn&#8217;t say it all. Some clarifications are in order.</p><p>Some people pointed out that I should just download the XCode .dmg DVD image &#8211; all 3.4 GB of it. Unfortunately that wasn&#8217;t applicable for me at the time: I was connected via 3G, tethered to my Android phone. I&#8217;ve never tried to download 3.4 GB on that connection, and I don&#8217;t plan to try today: it would be expensive.</p><p>See the great comment below by Beltran (who works for Bitnami) about a great solution.</p> <img src="http://feeds.feedburner.com/~r/CloudDeveloperTips/~4/sHkhDv7MXdk" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://shlomoswidler.com/2011/01/using-elastic-beanstalk-via-command-line-on-a-mac-keep-that-os-x-install-dvd-handy.html/feed</wfw:commentRss> <slash:comments>4</slash:comments> <feedburner:origLink>http://shlomoswidler.com/2011/01/using-elastic-beanstalk-via-command-line-on-a-mac-keep-that-os-x-install-dvd-handy.html</feedburner:origLink></item> <item><title>Using AWS Route 53 to Keep Track of EC2 Instances</title><link>http://feedproxy.google.com/~r/CloudDeveloperTips/~3/2L5R5H0yWB0/using-aws-route-53-to-keep-track-of-ec2-instances.html</link> <comments>http://shlomoswidler.com/2010/12/using-aws-route-53-to-keep-track-of-ec2-instances.html#comments</comments> <pubDate>Wed, 22 Dec 2010 17:37:17 +0000</pubDate> <dc:creator>shlomo</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[aws]]></category> <category><![CDATA[dns]]></category> <category><![CDATA[ec2]]></category> <category><![CDATA[guest post]]></category> <category><![CDATA[route53]]></category><guid isPermaLink="false">http://shlomoswidler.com/?p=220</guid> <description><![CDATA[This article is a guest post by Guy Rosen, CEO of Onavo and author of the Jack of All Clouds blog. Guy was one of the first people to produce hard numbers on cloud adoption for site hosting, and he continues to publish regular updates to this research in his State of the Cloud series. [...]]]></description> <content:encoded><![CDATA[<p></p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fshlomoswidler.com%2F2010%2F12%2Fusing-aws-route-53-to-keep-track-of-ec2-instances.html"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fshlomoswidler.com%2F2010%2F12%2Fusing-aws-route-53-to-keep-track-of-ec2-instances.html&amp;source=shlomoswidler&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br
/> </a></div><p><em>This article is a guest post by Guy Rosen, CEO of <a
href="http://www.onavo.com/" target="_blank">Onavo</a> and author of the <a
href="http://www.jackofallclouds.com/" target="_blank">Jack of All Clouds</a> blog. Guy was one of the first people to produce hard numbers on cloud adoption for site hosting, and he continues to publish regular updates to this research in his <a
href="http://www.jackofallclouds.com/category/state-of-the-cloud/" target="_blank">State of the Cloud</a> series. These days he runs his startup Onavo which uses the cloud to offer smartphone users a way to slash overpriced data roaming costs.</em></p><p><em>In this article, Guy provides another technique to <a
href="http://shlomoswidler.com/2010/06/track-changes-to-your-dynamic-cloud-services-automatically.html" target="_blank">track changes to your dynamic cloud services automatically</a>, possible now that AWS has released <a
href="http://aws.amazon.com/route53/" target="_blank">Route 53</a>, DNS services. Take it away, Guy.</em></p><p>While one of the greatest things about EC2 is the way you can spin up, stop and start instances to your heart&#8217;s desire, things get sticky when it comes to actually connecting to an instance. When an instance boots (or comes up after being in the Stopped state), Amazon assigns a pair of unique IPs (and DNS names) that you can use to connect: a private IP used when connecting from another machine in EC2, and a public IP is used to connect from the outside. The thing is, when you start and stop dozens of machines daily you lose track of these constantly changing IPs. How many of you have found, like me, that each time you want to connect to a machine (or hook up a pair of machines that need to communicate with each other, such as a web and database server) you find yourself going back to your EC2 console to copy and paste the IP?</p><p>This morning I got fed up with this, and since Amazon launched their new Route 53 service I figured the time was ripe to make things right. Here&#8217;s what I came up with: a (really) small script that takes your EC2 instance list and plugs it into DNS. You can then refer to your machines not by their IP but by their instance ID (which is preserved across stops and starts of EBS-backed instances) or by a user-readable tag you assign to a machine (such as &#8220;webserver&#8221;).</p><p>Here&#8217;s what you do:</p><ol><li>Sign up to Amazon Route 53.</li><li>Download and install cli53 from <a
href="https://github.com/barnybug/cli53">https://github.com/barnybug/cli53</a> (follow the instructions to download the latest Boto and dnspython)</li><li>Set up a domain/subdomain you want to use for the mapping (e.g., ec2farm.mycompany.com):<ol
type="a"><li>Set it up on Route53 using cli53:<br
/> <code>./cli53.py create <strong>ec2farm.mycompany.com</strong></code></li><li>Use your domain provider&#8217;s interface to set Amazon&#8217;s DNS servers (reported in the response to the <code>create</code> command)</li><li>Run the following script (replace any details and paths, emphasized in bold, with your own):<br
/><blockquote><p><code> #!/bin/tcsh -f<br
/> set root=`dirname $0`<br
/> setenv EC2_HOME <strong>/usr/local/ec2-api-tools</strong><br
/> setenv EC2_CERT <strong>$root/ec2_x509_cert.pem</strong><br
/> setenv EC2_PRIVATE_KEY <strong>$root/ec2_x509_private.pem</strong><br
/> setenv AWS_ACCESS_KEY_ID <strong>myawsaccesskeyid</strong><br
/> setenv AWS_SECRET_ACCESS_KEY <strong>mysecretaccesskey</strong></code></p><p><code>$EC2_HOME/bin/ec2-describe-instances | \<br
/> perl -ne '/^INSTANCE\s+(i-\S+).*?(\S+\.amazonaws\.com)/ \<br
/> and do { $dns = $2; print "$1 $dns\n" }; /^TAG.+\sShortName\s+(\S+)/ \<br
/> and print "$1 $dns\n"' | \<br
/> perl -ane 'print "$F[0] CNAME $F[1] --replace\n"' | \<br
/> xargs -n 4 <strong>$root/cli53/cli53.py</strong> \<br
/> rrcreate -x 60 <strong>ec2farm.mycompany.com</strong></code></p></blockquote></li></ol></li></ol><p>Voila! You now have DNS names such as <code>i-abcd1234.ec2farm.mycompany.com</code> that point to your instances. To make things more helpful, if you add a tag called <code>ShortName</code> to your instances it will be picked up, letting you create names such as <code>dbserver2.ec2farm.mycompany.com</code>. The script creates CNAME records, which means that you will automatically get internal EC2 IPs when querying inside EC2 and public IPs from the outside.</p><p>Put this script somewhere, run it in a cron &#8211; and you&#8217;ll have an auto-updating DNS zone for your EC2 servers.</p><p>Short disclaimer: the script above is a horrendous one-liner that roughly works and uses many assumptions, it works for me but no guarantees.</p> <img src="http://feeds.feedburner.com/~r/CloudDeveloperTips/~4/2L5R5H0yWB0" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://shlomoswidler.com/2010/12/using-aws-route-53-to-keep-track-of-ec2-instances.html/feed</wfw:commentRss> <slash:comments>15</slash:comments> <feedburner:origLink>http://shlomoswidler.com/2010/12/using-aws-route-53-to-keep-track-of-ec2-instances.html</feedburner:origLink></item> <item><title>S3 Reduced Redundancy Storage with Simple Notification Service: What, Why, and When</title><link>http://feedproxy.google.com/~r/CloudDeveloperTips/~3/k5yDXwABrGU/s3-reduced-redundancy-storage-with-simple-notification-service-what-why-and-when.html</link> <comments>http://shlomoswidler.com/2010/07/s3-reduced-redundancy-storage-with-simple-notification-service-what-why-and-when.html#comments</comments> <pubDate>Thu, 22 Jul 2010 00:16:24 +0000</pubDate> <dc:creator>shlomo</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[aws]]></category> <category><![CDATA[ec2]]></category> <category><![CDATA[rrs]]></category> <category><![CDATA[s3]]></category> <category><![CDATA[sns]]></category><guid isPermaLink="false">http://www.shlomoswidler.com/?p=200</guid> <description><![CDATA[AWS recently added support for receiving Simple Notification Service notifications when S3 loses a Reduced Redundancy Storage S3 object. This raises a number of questions: What the heck does that even mean? Why would I want to do that? Under what conditions does it make financial sense to do that? Let&#8217;s take a look at [...]]]></description> <content:encoded><![CDATA[<p></p><div
class="tweetmeme_button" style="float: right; margin-left: 10px;"> <a
href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fshlomoswidler.com%2F2010%2F07%2Fs3-reduced-redundancy-storage-with-simple-notification-service-what-why-and-when.html"><br
/> <img
src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fshlomoswidler.com%2F2010%2F07%2Fs3-reduced-redundancy-storage-with-simple-notification-service-what-why-and-when.html&amp;source=shlomoswidler&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br
/> </a></div><p>AWS recently added support for <a
href="http://aws.typepad.com/aws/2010/07/amazon-s3-and-amazon-sns-best-friends-forever.html" target="_blank">receiving Simple Notification Service notifications when S3 loses a Reduced Redundancy Storage S3 object</a>. This raises a number of questions:</p><ul><li>What the heck does that even mean?</li><li>Why would I want to do that?</li><li>Under what conditions does it make financial sense to do that?</li></ul><p>Let&#8217;s take a look at these questions, and we&#8217;ll also do a bit of brainstorming (please participate!) to design a service that puts it all together.</p><h2>What is S3 Reduced Redundancy Storage?</h2><p>Standard objects stored in S3 have &#8220;eleven nines&#8221; of durability annually. This means 99.999999999% of your objects stored in S3 will still be there after one year. On average, you will need to store 100,000,000,000 &#8211; that&#8217;s one hundred billion &#8211; objects in standard S3 storage before you will, on average, have one of them disappear over a year&#8217;s time. Pretty great.</p><p>Reduced Redundancy Storage (RRS) is a different class of S3 storage that, in effect, has a lower durability: 99.99% annually. On average, you will need to store only 10,000 objects in RRS S3 before you should expect one of them to disappear over a year&#8217;s time. Not quite as great, but still more than 400 times better than a traditional hard drive.</p><p>When an RRS object is lost S3 will return an HTTP 405 response code, and your application is supposed to be built to understand that and take the appropriate action: most likely regenerate the object from its source objects, which have been stored elsewhere more reliably &#8211; probably in standard eleven-nines S3. It&#8217;s less expensive for AWS to provide a lower durability class of service, and therefore RRS storage is priced accordingly: it&#8217;s about 2/3 the cost of standard S3 storage.</p><p>RRS is great for derived objects &#8211; for example, image thumbnails. The source object &#8211; the full-quality image or video &#8211; can be used to recreate the derived object &#8211; the thumbnail &#8211; without losing any information. All it costs to create the derived object is time and CPU power. And that&#8217;s most likely why you&#8217;re creating the derived objects and storing them in S3: to act as a cache so the app server does not need to spend time and CPU power recreating them for every request. Using S3 RRS as a cache will save you 1/3 of your storage costs for the derived objects, but  you&#8217;ll need to occasionally recreate a derived object in your application.</p><h2>How Do You Handle Objects Stored in RRS?</h2><p>If you serve the derived objects to clients directly from S3 &#8211; as many web apps do with their images &#8211; your clients will occasionally get a HTTP 405 response code (about once a year for every 10,000 RRS objects stored). The more objects you store the higher the likelihood of a client&#8217;s browser encountering a HTTP 405 error &#8211; and most browsers show ugly messages when they get a 405 error. So your application should do some checking.</p><p>To get your application to check for a lost object you can do the following: Send S3 an HTTP HEAD request for the object before giving the client its URL. If the object exists then the HEAD request will succeed. If the object is lost the HEAD request will return a 405 error. Once you&#8217;re sure the object is in S3 (either the HEAD request succeeded, or you recreated the derived object and stored it again in S3), give the object&#8217;s URL to the client.</p><p>All that HEAD checking is a lot of overhead: each S3 RRS URL needs to be checked every time it&#8217;s served. You can add a cache of the URL of objects you&#8217;ve checked recently and skip those. This will cut down on the overhead and reduce your S3 bill &#8211; remember that each HEAD request costs 1/10,000 of a cent &#8211; but it&#8217;s still a bunch of unnecessary work because most of the time you check its HEAD the object will still be there.</p><h2>Using Simple Notification Service with RRS</h2><p>Wouldn&#8217;t it be great if you could be notified when S3 RRS loses an object?</p><p>You can. <a
href="http://aws.typepad.com/aws/2010/07/amazon-s3-and-amazon-sns-best-friends-forever.html" target="_blank">AWS&#8217;s announcement</a> introduces a way to receive notification &#8211; via Simple Notification Service, SNS &#8211; when S3 RRS detects that an object has been lost. This means you no longer need your application to check for 405s before serving objects. Instead you can have your application listen for SNS notifications (either via HTTP or via email or via SQS) and proactively process them to restore lost objects.</p><p>Okay, it&#8217;s not<em> really</em> true that your application no longer needs to check for lost objects. The latency between the actual loss of an object and the time you recreate and replace it is still nonzero, and during that time you probably want your application to behave nicely.</p><p>[An aside: I do wonder what the expected latency is between the object's loss and the SNS notification. I've <a
href="http://developer.amazonwebservices.com/connect/thread.jspa?threadID=48031&amp;tstart=0#187429" target="_blank">asked on the Forums</a> and in a comment to Jeff Barr's blog post - I'll update this article when I have an answer.]</p><h2>When Does it Make Financial Sense to Use S3 RRS?</h2><p>While you save on storage costs for using S3 RRS you still need to devote resources to recreating any lost objects. How can you decide when it makes sense to go with RRS despite the need to recreate lost objects?</p><p>There are a number of factors that influence the cost of recreating lost derived objects:</p><ul><li>Bandwidth to get the source object from S3 and return the derived object to S3. If you perform the processing inside the same EC2 region as the S3 region you&#8217;re using then this cost is zero.</li><li>CPU to perform the transformation of the source object into the derived object.</li><li>S3 requests for GETting the source object and PUTting the derived object.</li></ul><p>I&#8217;ve prepared a <a
href="http://spreadsheets.google.com/ccc?key=0AhOse1HN7LTHdGRBYzJuVmMxc3pscFVoTG5rWDFmQUE&amp;hl=en&amp;authkey=COaZk8kJ" target="_blank">spreadsheet analyzing these costs</a> for various different numbers of objects, sizes of objects, and CPU-hours required for each derived object.</p><p>For 100,000 source objects of average 5MB size stored in Standard S3, each of which creates 5 derived objects of average 500KB size stored in RRS and requiring 1 second of CPU time to recreate, the savings in choosing RRS is $12.50 per month. Accounting for the cost of recreating lost derived objects reduces that savings to $12.37.</p><p>For the same types of objects but requiring 15 minutes of CPU time to recreate each derived object the net savings overall is $12.28. Still very close to the entire savings generated by using RRS.</p><p>For up to about 500,000 source objects it doesn&#8217;t pay to launch a dedicated m1.small instance just for the sake of recreating lost RRS objects. An m1.small costs $61.20 per month, which is approximately the same as the net savings from 500,000 source objects of average 5MB size with 5 derived objects each of average size 500KB. At this level of usage, if you have spare capacity on an existing instance then it would make financial sense to run the recreating process there.</p><p>For larger objects the savings is also almost the entire amount saved by using RRS, and the amounts saved are larger than the cost of a single m1.small so it already pays to launch your own instance for the processing.</p><p>For larger numbers of objects the savings is also almost the entire amount saved by using RRS.</p><p>As far down as you go in the spreadsheet, and as much as you may play with the numbers, it makes financial sense to use RRS and have a mechanism to recreate derived objects.</p><p>Which leads us to the the brainstorming.</p><h2>Why Should I Worry About Lost Objects?</h2><p>Let&#8217;s face it, nobody wants to operate a service that is not core to their business. Most likely, creating the derived objects from the source object is not your business core competency. Creating thumbnails and still frame video captures is commodity stuff.</p><p>So let&#8217;s imagine a service that does the transformation, storage in S3, and maintenance of RRS derived objects for you so you don&#8217;t have to.</p><p>You&#8217;d drop off your source object in your bucket in S3. Then you&#8217;d send an SQS message to the service containing the new source object&#8217;s key and a list of the transformations you want applied. As Jeff Bar suggests in his blog, the service would process the message and create derived objects (stored in RRS) whose keys (the name) would be composed of the source object&#8217;s name and the name of the transformation applied. You&#8217;d know how to construct the name of every derived object, so you would know how to access them. The service would subscribe to the RRS SNS notifications and recreate the derived objects when they are lost.</p><p>This service would need a way for clients to discover the supported file types and the supported transformations for each file type.</p><p>As we pointed out above, there is a lot of potential financial savings in using RRS, so such a service has plenty of margin to price itself profitably, below the cost of standard S3 storage.</p><p>What else would such a service need? Please comment.</p><p>If you build such a service, please cut me in for 30% for giving you the idea. Or, at least acknowledge me in your blog.</p> <img src="http://feeds.feedburner.com/~r/CloudDeveloperTips/~4/k5yDXwABrGU" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://shlomoswidler.com/2010/07/s3-reduced-redundancy-storage-with-simple-notification-service-what-why-and-when.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> <feedburner:origLink>http://shlomoswidler.com/2010/07/s3-reduced-redundancy-storage-with-simple-notification-service-what-why-and-when.html</feedburner:origLink></item> </channel> </rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: basic
Database Caching 11/57 queries in 0.016 seconds using disk: basic
Object Caching 1431/1524 objects using disk: basic
Content Delivery Network via Amazon Web Services: S3: blogstatic.shlomoswidler.com.s3.amazonaws.com

Served from: shlomoswidler.com @ 2012-01-19 17:55:21 -->

