<?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>A Day At The Races &#187; amazon</title>
	<atom:link href="http://blog.jetztgrad.net/category/amazon/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jetztgrad.net</link>
	<description>Programming was my first love, and it will be my last.</description>
	<lastBuildDate>Thu, 05 May 2011 08:21:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Presentation: Introduction to Amazon Elastic Beanstalk</title>
		<link>http://blog.jetztgrad.net/2011/04/presentation-introduction-to-amazon-elastic-beanstalk/</link>
		<comments>http://blog.jetztgrad.net/2011/04/presentation-introduction-to-amazon-elastic-beanstalk/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 14:06:55 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[amazon]]></category>
		<category><![CDATA[beanstalk]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[presentation]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=386</guid>
		<description><![CDATA[Lars Vogel gave a talk on Google AppEngine at the Mannheim Java User Group (Majug). Afterwards, I gave a short introduction to Amazon Elastic Beanstalk. The slides are available here: The slides are available under the CreativeCommons license BY-NC-SA.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.vogella.de/">Lars Vogel</a> gave a <a href="http://jug-mannheim.mixxt.de/networks/events/show_event.35453">talk</a> on <a href="http://code.google.com/intl/de-DE/appengine/">Google AppEngine</a> at the <a href="http://majug.de">Mannheim Java User Group</a> (Majug). </p>
<p>Afterwards, I gave a short introduction to <a href="http://aws.amazon.com/elasticbeanstalk/">Amazon Elastic Beanstalk</a>. The slides are available here:</p>
<iframe src="http://www.slideshare.net/slideshow/embed_code/7703995" width="600" height="489" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br/><br/>
<p><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/"><img src="http://i.creativecommons.org/l/by-nc/3.0/88x31.png" alt="CC BY-NC-SA" /></a> The slides are available under the <a href="http://creativecommons.org/licenses/by-nc-sa/2.5/">CreativeCommons license BY-NC-SA</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2011/04/presentation-introduction-to-amazon-elastic-beanstalk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to customize an Amazon Elastic Beanstalk instance</title>
		<link>http://blog.jetztgrad.net/2011/02/how-to-customize-an-amazon-elastic-beanstalk-instance/</link>
		<comments>http://blog.jetztgrad.net/2011/02/how-to-customize-an-amazon-elastic-beanstalk-instance/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 02:24:57 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[amazon]]></category>
		<category><![CDATA[beanstalk]]></category>
		<category><![CDATA[ec2]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=345</guid>
		<description><![CDATA[The default Amazon Elastic Beanstalk AMI provides a Java-based application container with Apache Tomcat as the work horse. All you have to do is to deploy a standard Java WAR file containing your web application. But sometimes, the standard AMI does not provide everything. Maybe the Apache configuration needs to be tweaked or some package, [...]]]></description>
			<content:encoded><![CDATA[<p>The default <a href="http://aws.amazon.com/elasticbeanstalk/">Amazon Elastic Beanstalk</a> AMI  provides a Java-based application container with <a href="http://tomcat.apache.org/">Apache Tomcat</a> as the work horse. All you have to do is to deploy a standard <a href="http://en.wikipedia.org/wiki/WAR_(Sun_file_format)">Java WAR file</a> containing your web application.</p>
<p>But sometimes, the standard AMI does not provide everything. Maybe the Apache configuration needs to be tweaked or some package, e.g. a local <a href="http://memcached.org/">memcached</a> server, is missing. </p>
<p>Customizing the Beanstalk AMI is easy, there are only a few simple steps, which are outlined <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?ebs-creating-snapshot.html">here</a>.</p>
<p>First of all, start the AMI to be customized in the <a href="https://console.aws.amazon.com/ec2/home">AWS console</a>. <strong>Note</strong>: as described by <a href="https://forums.aws.amazon.com/profile.jspa?userID=159556">foremosttravel</a> in the <a href="https://forums.aws.amazon.com/thread.jspa?threadID=59380&#038;tstart=0">Beanstalk forum</a>, the instance should be started from the <a href="https://console.aws.amazon.com/ec2/home">EC2 console</a>, <em>NOT</em> the <a href="https://console.aws.amazon.com/elasticbeanstalk/home">Beanstalk console</a>, as running the AMI within the Beanstalk environment may lead to it being terminated during the EBS snapshot, as it might fail to answer to the Beanstalk health checks.</p>
<p><strong>Preparation</strong></p>
<p>So here are the step by step instructions for the preparation:</p>
<ol>
<li>Go to the <a href="https://console.aws.amazon.com/ec2/home">EC2 console</a></li>
<li>Select region <em>US-East</em>, as Beanstalk is currently available only there</li>
<li>Click <em>Launch instance</em></li>
<li>Enter either <code>ami-100fff79</code> for the 64bit AMI or <code>ami-060fff6f</code> for the 32bit AMI (as of Feb 8th, 2011; these AMIs contain <a href="https://forums.aws.amazon.com/message.jspa?messageID=220954#220954">fixes</a> to preserve the original hostname and protocol, which are stripped by the load balancer)
<p><code></code><br />
<a href="http://blog.jetztgrad.net/wp-content/uploads/2011/02/start-instance.png"><img src="http://blog.jetztgrad.net/wp-content/uploads/2011/02/start-instance-1024x400.png" alt="Start instance from EC2 console" title="Start instance from EC2 console" width="1024" height="400" class="aligncenter size-large wp-image-347" /></a><br />
<code></code></p>
</li>
<li>Click <em>Select</em>, then <em>Continue</em>, until the step <strong>Create Key Pair</strong></li>
<li>Choose an existing key pair or create a new one. This will be used to access the running instance using SSH</li>
<li>In the next step, specify an appropriate security group, which allows SSH access, e.g. <code>SSH</code></li>
<li>Press continue and finally launch the instance</li>
<li>In the instance list, press the right mouse button over the instance and choose <em>Connect</em></li>
<li>Copy the SSH command line, adjust the path to your private key and connect to the instance using a SSH client.
<p><strong>Note</strong>: you need to connect as user <code>ec2-user</code>, <code>root</code> access can be obtained using the command <code>sudo su -</code>. See <a href="/2011/01/dissecting-an-amazon-elastic-beanstalk-instance/">this blog post</a> for details on how to access the instance.</p>
<p><code></code><br />
<a href="http://blog.jetztgrad.net/wp-content/uploads/2011/02/connect-instance.png"><img src="http://blog.jetztgrad.net/wp-content/uploads/2011/02/connect-instance.png" alt="" title="connect-instance" width="602" height="509" class="aligncenter size-full wp-image-350" /></a><br />
<code></code></p>
</li>
</ol>
<p><strong>Customization</strong></p>
<p>Now we are free to customize the AMI&#8217;s files to our heart&#8217;s content.</p>
<p><strong>Note</strong>: As the AMI is running outside the Beanstalk environment, <code>Apache</code>, <code>Tomcat</code>, and <code>HostManager</code> (the software interface to Beanstalk), are not running, as they didn&#8217;t get the expected parameters, such as the path of the application to start. This doesn&#8217;t matter, as soon as we start the customized AMI in an Beanstalk environment, everything works again.</p>
<p>As a proof of concept, we change <code>HostManager</code>&#8216;s default index page (<code>/opt/elasticbeanstalk/srv/hostmanager/views/index.erb</code>) to contain the following HTML body:</p>
<p><code>&lt;body style=&quot;font-family:Verdana,Arial,Sans-serif;&quot;&gt;<br />
	&lt;div class=&quot;logo&quot;&gt;<br />
		&lt;img src=&quot;http://awsmedia.s3.amazonaws.com/logo_aws.gif&quot; /&gt;<br />
		&lt;h2&gt;Host Manager&lt;/h2&gt;<br />
		&lt;b&gt;Haz customization!&lt;/b&gt;<br />
	&lt;/div&gt;<br />
&lt;/body&gt;</code></p>
<p><strong>Note</strong>: when changing <code>HostManager</code> or the <code>Apache</code> configuration, please make sure, that <code>HostManager</code> still answers to Beanstalk requests on <code>/_hostmanager</code> and the application to health checks on <code>/</code>, otherwise the instance will be terminated and another will be started!</p>
<p><strong>Persisting changes</strong></p>
<p>Now that we are done,  we need to create an EBS snapshot to preserve our customizations. The AMI is <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?Concepts_BootFromEBS.html">EBS-backed</a>, so a snapshot can be used to register an AMI, which is based on the snapshot.</p>
<p>Again, here are the step by step instructions:</p>
<ol>
<li>Remove eveything you do not want to remain in the instance such as the bash history, SSH keys, &#8230;</li>
<li>Create an EBS snapshot, either from the <a href="https://console.aws.amazon.com/ec2/home">EC2 console</a> or the command line tools. See the <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?Tutorial_CreateImage.html">user guide</a> for details.
<li>You now have an AMI. See <em>Images &gt; AMI</em> on the left side of the <a href="https://console.aws.amazon.com/ec2/home">EC2 console</a> and choose <em>Owned By Me</em> in the AMI tab to view your newly create AMI. Note down the AMI id.</li>
</ol>
<p>If you want to make some more changes, keep the current instance running, while you test your changes from within Beanstalk. After a test drive (see below), make some more changes and create another image. Rinse and repeat until you are satisfied with the results. Don&#8217;t forget to clean up any unnecessary EBS snapshots and AMIs, as they cost actual money!</p>
<p><strong>Start customized instance in Beanstalk</strong></p>
<p>If you want to test-drive your customized AMI, you need to start an Beanstalk environment with the id of the customized AMI. There are two ways to perform this, via the <a href="https://console.aws.amazon.com/elasticbeanstalk/home">Beanstalk console</a> or from the <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-cli-overview.html">command line</a>.</p>
<p><em>Via Beanstalk console</em></p>
<ol>
<li>Go to the <a href="https://console.aws.amazon.com/elasticbeanstalk/home">Beanstalk console</a></li>
<li>Create an environment</li>
<li>Wait for everything to be started so you can change the configuration</li>
<li>Adjust the AMI id as described in the <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-features.managing.ec2.html">user guide</a></li>
<li>Restart the environment</li>
<li>Test your changes. In our example, we go to the changed <code>HostManager</code> index page at <a href="http://myenv.elasticbeanstalk.com/_hostmanager">http://myenv.elasticbeanstalk.com/_hostmanager</a><y/li>
</ol>
<p><em>Via command line</em></p>
<p>We use my <a href="http://blog.jetztgrad.net/2011/02/script-to-start-an-amazon-elastic-beanstalk-application/">simplified script</a> to start an Amazon Elastic Beanstalk application from command line. See <a href="http://blog.jetztgrad.net/2011/02/script-to-start-an-amazon-elastic-beanstalk-application/">here</a> for a detailed description. We can specify all parameters right from the start, so we do not need to wait for the initial start, before we can adjust the configuration.</p>
<ol>
<li><a href="https://gist.github.com/raw/808948/45cf55a10b9d6799bf21f7008fe10cba089e8cab/eb-create-app.sh">Download</a> the script from GitHub</li>
<li>Start an environment with the following command:<br />
<code>eb-create-app.sh -a myapp -i ami-be55a5d7 -t t1.micro -C 64 -e myenv -k mykeypair</code></p>
<p>Make sure to specify the id of your AMI as created above. Also don&#8217;t forget to specify a keypair, otherwise you won&#8217;t be able to log in using SSH. The name of the environment must be unique, as it is also used as CNAME (this can be overridden with <code>-c &lt;CNAME&gt;</code> though)
</li>
<li>Test your changes. In our example, we go to the changed <code>HostManager</code> index page at <a href="http://myenv.elasticbeanstalk.com/_hostmanager">http://myenv.elasticbeanstalk.com/_hostmanager</a><y/li>
</ol>
<p><strong>Outlook</strong></p>
<p>Have fun creating customized instances. Please leave feedback and/or a note in the comments, which describes your changes. I will try to change <code>HostManager</code> to run the <a href="http://eclipse.org/virgo/">Virgo</a> OSGi server instead of Tomcat, so stay tuned for the next installment.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2011/02/how-to-customize-an-amazon-elastic-beanstalk-instance/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Script to start an Amazon Elastic Beanstalk application from command line</title>
		<link>http://blog.jetztgrad.net/2011/02/script-to-start-an-amazon-elastic-beanstalk-application/</link>
		<comments>http://blog.jetztgrad.net/2011/02/script-to-start-an-amazon-elastic-beanstalk-application/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 03:28:35 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[amazon]]></category>
		<category><![CDATA[beanstalk]]></category>
		<category><![CDATA[ec2]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=330</guid>
		<description><![CDATA[After playing around with Amazon Elastic Beanstalk, I started to explore the command line tools. Starting an Amazon Elastic Beanstalk application from the AWS console is easy and reasonably fast. The main problem is that you can&#8217;t currently provide additional settings such as the instance type (e.g. m1.small or t1.micro), a SSH key or application [...]]]></description>
			<content:encoded><![CDATA[<p>After <a href="/2011/01/dissecting-an-amazon-elastic-beanstalk-instance/">playing around</a> with Amazon Elastic Beanstalk, I started to explore the <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-cli-overview.html">command line tools</a>.</p>
<p>Starting an <a href="http://aws.amazon.com/elasticbeanstalk/">Amazon Elastic Beanstalk</a> application from the <a href="https://console.aws.amazon.com/elasticbeanstalk/home">AWS console</a> is easy and reasonably fast. The main problem is that you can&#8217;t currently provide additional settings such as the instance type (e.g. <code>m1.small</code> or <code>t1.micro</code>), a SSH key or application parameters. </p>
<p>After starting the application environment, it must be stopped again, before the configuration can be changed. This costs an instance hour but, more importantly, this procedure takes quite a while, as AWS must reconfigure the load balancer, auto-scaling group, start your instance(s), etc.</p>
<p>I created a <a href="https://gist.github.com/808948">script</a>, which can be used to start an application environment from the command line. The most important parameters can be set as command line parameters:</p>
<script src="http://gist.github.com/808950.js"></script>
<p>All you need is to install the Elastic Beanstalk <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-cli-overview.html">command line tools</a> and my <a href="https://gist.github.com/808948">script</a>.</p>
<p><b>Example</b></p>
<p>Starting an application <code>myapp</code> with environment <code>myenv</code> on a <code>m1.small</code> instance with SSH key <code>mysshkey</code> is as simple as:</p>
<p><code>eb-create-app.sh -a myapp -k mysshkey -e myenv -t m1.small -f 'mybucket/myapp.war'</code></p>
<p>Some notes:</p>
<ul>
<li>the application WAR file must already be uploaded to <a href="http://aws.amazon.com/s3/">S3</a>. The format of the file name (parameter <code>-f</code>) is <code>bucketname/key</code>. If the file name is not specified, Beanstalk will deploy the sample application</li>
<li>the environment can only be created, if the <code>CNAME</code> (which is identical to the environment name, if not specified with <code>-c</code>) is not already used. The <code>CNAME</code> is used as sub-domain under <code>elasticbeanstalk.com</code>. When creating an environment with name (and CNAME)  <code>myenv</code>, the full DNS name would be <a href="http://myenv.elasticbeanstalk.com">myenv.elasticbeanstalk.com</a></li>
<li>starting an environment will fail, if the SSH key name does not exist. You can look up the name of your SSH key in the <a href="https://console.aws.amazon.com/ec2/home">EC2 console</a></li>
</ul>
<p><strong>Elastic Beanstalk Parameters</strong></p>
<p>Elastic Beanstalk provides many parameters, which can be set. A full list can be obtained using <code>elastic-beanstalk-describe-configuration-settings</code>, also from the <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-cli-overview.html">command line tools</a> (NOTE: <a href="https://forums.aws.amazon.com/thread.jspa?messageID=220042">fix required</a>!).</p>
<p>I created a list of all Elastic Beanstalk configuration options using <a href="https://gist.github.com/808962">another script</a> (requires ruby gem <a href="http://rubygems.org/gems/jazor">jazor</a>):</p>
<script src="http://gist.github.com/808968.js"></script>
<p>The <a href="https://gist.github.com/808972">long version</a> in JSON format is available <a href="https://gist.github.com/808972">here</a>.</p>
<p><strong>Final words</strong></p>
<p>Starting an application environment is easy and the command line tools help a lot. There are still some bugs, but I&#8217;m sure, the Beanstalk team will address them soon. The <a href="https://forums.aws.amazon.com/forum.jspa?forumID=86&#038;start=0">forum</a> is a great resource.</p>
<p>My next post will be about creating a customized Beanstalk AMI. Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2011/02/script-to-start-an-amazon-elastic-beanstalk-application/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dissecting an Amazon Elastic Beanstalk instance</title>
		<link>http://blog.jetztgrad.net/2011/01/dissecting-an-amazon-elastic-beanstalk-instance/</link>
		<comments>http://blog.jetztgrad.net/2011/01/dissecting-an-amazon-elastic-beanstalk-instance/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 13:15:41 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[amazon]]></category>
		<category><![CDATA[beanstalk]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[infrastructure]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[osgi]]></category>
		<category><![CDATA[s3]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=295</guid>
		<description><![CDATA[Amazon Elastic Beanstalk provides a PaaS similar to Google AppEngine, bundling many of their existing offerings such as Elastic Compute Cloud (EC2), Simple Storage Service (S3), Simple Notification Service (SNS), Elastic Load Balancing, Auto Scaling, and monitoring using Cloud Watch into a simple to use service. Additionally, other Amazon services such as SimpleDB, Relational Database [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://aws.amazon.com/elasticbeanstalk/">Amazon Elastic Beanstalk</a> provides a PaaS similar to <a href="http://code.google.com/appengine/">Google AppEngine</a>, bundling many of their existing offerings such as <a href="http://aws.amazon.com/de/ec2/">Elastic Compute Cloud</a> (EC2), <a href="http://aws.amazon.com/de/s3/">Simple Storage Service</a> (S3), <a href="http://aws.amazon.com/de/sns/">Simple Notification Service</a> (SNS), <a href="http://aws.amazon.com/de/elasticloadbalancing/">Elastic Load Balancing</a>, <a href="http://aws.amazon.com/autoscaling/">Auto Scaling</a>, and monitoring using <a href="http://aws.amazon.com/de/cloudwatch/">Cloud Watch</a> into a simple to use service. Additionally, other <a href="http://aws.amazon.com/">Amazon services</a> such as <a href="http://aws.amazon.com/de/simpledb/">SimpleDB</a>, <a href="http://aws.amazon.com/de/rds/">Relational Database Service</a> (RDS), <a href="http://aws.amazon.com/de/sqs/">Simple Queue Service</a> (SQS) may be used as well.</p>
<p>Currently, Elastic Beanstalk provides a Java-based application container with <a href="http://tomcat.apache.org/">Apache Tomcat</a> as the work horse. All you have to do is to deploy a standard <a href="http://en.wikipedia.org/wiki/WAR_(Sun_file_format)">Java WAR file</a> containing your web application.</p>
<p>Simply create a Java web application with <a href="http://static.springsource.org/spring/docs/3.0.x/reference/mvc.html">Spring MVC</a>, <a href="http://grails.org/">Grails</a>, <a href="http://eclipsesource.com/blogs/2011/01/20/amazon-aws-beanstalk-and-eclipse-equinox/">OSGi</a>, <a href="http://eclipsesource.com/blogs/2011/01/20/amazon-aws-beanstalk-and-eclipse-equinox/">Eclipse RAP</a>, or any other of the numerous Java web frameworks and upload it using the <a href="https://console.aws.amazon.com/elasticbeanstalk/home">AWS web console</a>.</p>
<p>Additional containers for other platforms such as Ruby, Python or PHP may follow later, but as Tomcat hosts standard Java WAR files, anything with a Java implementation may be run. Ruby apps based on <a href="http://rubyonrails.org/">Rails</a> or <a href="http://rack.rubyforge.org/">Rack</a> using <a href="http://caldersphere.rubyforge.org/warbler/">Warbler</a> and <a href="http://jruby.org/">JRuby</a>, Python apps using <a href="http://www.jython.org/">Jython</a>, even PHP apps can be <a href="http://cameronstokes.com/2011/01/20/php-on-aws-elastic-beanstalk/">made to run</a> on Beanstalk.  </p>
<p>In this blog post, I&#8217;ll dive into the inner workings of a Beanstalk server instance and poke around its internals. I invite you to come along for the ride.</p>
<p><strong>Accessing your instance</strong><br />
The first step in dissecting a Beanstalk instance is <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-features.ec2connect.html">getting access via SSH</a>.<br />
In order to acces your running instance(s), you first need to configure the SSH key pair to be used:<br />
<div id="attachment_297" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.jetztgrad.net/wp-content/uploads/2011/01/config-server.png"><img src="http://blog.jetztgrad.net/wp-content/uploads/2011/01/config-server-300x204.png" alt="Configuration dialog in Elastic Beanstalk web console" title="config-server" width="300" height="204" class="size-medium wp-image-297" /></a><p class="wp-caption-text">Configuration dialog in Elastic Beanstalk web console</p></div></p>
<p>Enter the name of a key pair as configured in your <a href="https://console.aws.amazon.com/ec2/home#s=KeyPairs">EC2 web console</a>. See the <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?using-credentials.html">EC2 guide</a> and the description in the <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-features.managing.ec2.html">Elastic Beanstalk guide</a> for details on creating and configuring a key pair.</p>
<p>Setting the key pair requires a restart of your Beanstalk environment, which may take a couple of minutes.</p>
<p>Finally <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-features.ec2connect.html">look up your instance id</a> and get the instance&#8217;s hostname. Connecting to the server is now as simple as this:</p>
<p><code>ssh -i .ec2/mykeypair.pem ec2-user@ec2-184-72-134-2.compute-1.amazonaws.com</code></p>
<p>Please note, that you need to connect as user <code>ec2-user</code>, <code>root</code> access can be reached using the command</p>
<p><code>sudo su -</code></p>
<p><strong>Getting around your instance</strong><br />
The first steps are to collect some interessting facts. The instance uses a <a href="http://aws.amazon.com/amazon-linux-ami/">Amazon Linux AMI</a> (release 2010.11.1 (beta), <a href="https://gist.github.com/791135">README</a>). The AMI id for the ElasticBeanstalk-Tomcat6-32bit is <code>ami-7609f81f</code>, the kernel id is <code>aki-407d9529</code>. The instance is EBS-based and there is no ephemeral storage. Currently, Beanstalk is only available in the US East zone.</p>
<p><strong>Software</strong><br />
The <a href="https://gist.github.com/791133">process list</a> reveals: along with <a href="http://tomcat.apache.org/">Apache Tomcat</a>, Beanstalk uses the venerable <a href="http://httpd.apache.org/">Apache Web Server</a>. Additional software includes <a href="https://github.com/arya/bluepill">Bluepill</a> for basic process monitoring, and Amazons own HostManager (see below), which is run within a <a href="http://code.macournoyer.com/thin/">Thin</a> web server.</p>
<p><strong>Network setup</strong><br />
Elastic Beanstalk scales EC2 instances as needed. Therefore the first target is a load balancer provided by <a href="http://aws.amazon.com/de/elasticloadbalancing/">Elastic Load Balancing</a>. Each instance runs Apache as the front end on port <code>80</code>, with web request being reverse proxied into Tomcat on port <code>8080</code>. Requests for URI <code>/_hostmanager</code> are forwarded to HostManager on port <code>8999</code>.</p>
<p>CloudWatch performs health checks by periodically requesting the root page (URI <code>/</code>) of your application. Both health check URI and frequency are configurable. If an instance is no longer available or the load changes, CloudWatch starts or stops instances. </p>
<p><img src="http://media.amazonwebservices.com/blog/cb_env_1.png" alt="Application stack" /><br />
[Image from <a href="http://aws.typepad.com/aws/2011/01/aws-beanstalk-concepts.html">AWS Elastic Beanstalk Concepts</a> blog post]</p>
<p><strong>HostManager</strong><br />
Local instance management is performed by Amazons HostManager. HostManager is a Ruby application based on Rack and running in a <a href="http://code.macournoyer.com/thin/">Thin</a> server on port 8999. It receives requests on URI <code>/_hostmanager</code>.</p>
<p>Some examples from the access log:</p>
<p><code>72.21.217.96 (72.21.217.96) - - [21/Jan/2011:22:00:45 +0000] "POST /_hostmanager/tasks HTTP/1.1" 200 368 "-" "AWS ElasticBeanstalk Health Check/1.0"<br />
10.223.61.43 (10.223.61.43) - - [21/Jan/2011:22:01:05 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
10.122.19.154 (10.122.19.154) - - [21/Jan/2011:22:01:11 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
10.223.61.43 (10.223.61.43) - - [21/Jan/2011:22:01:36 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
10.122.19.154 (10.122.19.154) - - [21/Jan/2011:22:01:42 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
72.21.217.96 (72.21.217.96) - - [21/Jan/2011:22:01:46 +0000] "POST /_hostmanager/tasks HTTP/1.1" 200 368 "-" "AWS ElasticBeanstalk Health Check/1.0"<br />
10.223.61.43 (10.223.61.43) - - [21/Jan/2011:22:02:07 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
10.122.19.154 (10.122.19.154) - - [21/Jan/2011:22:02:13 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
10.223.61.43 (10.223.61.43) - - [21/Jan/2011:22:02:38 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
10.122.19.154 (10.122.19.154) - - [21/Jan/2011:22:02:44 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
72.21.217.96 (72.21.217.96) - - [21/Jan/2011:22:02:47 +0000] "POST /_hostmanager/tasks HTTP/1.1" 200 368 "-" "AWS ElasticBeanstalk Health Check/1.0"<br />
</code></p>
<p><strong>Files</strong><br />
HostManager is installed in <code>/opt/elasticbeanstalk/srv/hostmanager</code>. A file list can be found <a href="https://gist.github.com/791104">here</a>. <code>/opt/elasticbeanstalk/lib</code> also contains a full Ruby 1.9.1 installation.</p>
<p>Some log files can be found at <code>/opt/elasticbeanstalk/var/</code>:</p>
<p><code>/opt/elasticbeanstalk<br />
/opt/elasticbeanstalk/var<br />
/opt/elasticbeanstalk/var/state<br />
/opt/elasticbeanstalk/var/state/hostmanager.pid<br />
/opt/elasticbeanstalk/var/state/healthcheck<br />
/opt/elasticbeanstalk/var/tmp<br />
/opt/elasticbeanstalk/var/log<br />
/opt/elasticbeanstalk/var/log/LogDirectoryMonitor.log<br />
/opt/elasticbeanstalk/var/log/DaemonManager.log<br />
/opt/elasticbeanstalk/var/log/bluepill.log<br />
/opt/elasticbeanstalk/var/log/hostmanager.log<br />
/opt/elasticbeanstalk/var/log/ApplicationHealthcheck.log<br />
/opt/elasticbeanstalk/var/log/CatalinaLogMonitor.log<br />
</code></p>
<p><strong>Final words</strong><br />
That&#8217;s all for today&#8217;s blog post. Further posts will take a closer look at HostManager and deployment including the application setup sequence.</p>
<p>I&#8217;m looking forward to any feedback and additional information.</p>
<p>Maybe we can even hack HostManager to accept other application containers, e.g. for OSGi applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2011/01/dissecting-an-amazon-elastic-beanstalk-instance/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Web Application Infrastructure</title>
		<link>http://blog.jetztgrad.net/2008/02/web-application-infrastructure/</link>
		<comments>http://blog.jetztgrad.net/2008/02/web-application-infrastructure/#comments</comments>
		<pubDate>Sun, 10 Feb 2008 16:45:00 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[amazon]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[infrastructure]]></category>
		<category><![CDATA[jets3t]]></category>
		<category><![CDATA[s3]]></category>
		<category><![CDATA[simpledb]]></category>
		<category><![CDATA[sqs]]></category>
		<category><![CDATA[typica]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=4</guid>
		<description><![CDATA[Congratulations: after spending plenty of time on creating and polishing your perfect web application in your development environment, it is finally meant to be released for public consumption. If it proves to be popular (or simply gets slahdotted), the application is in for a first real-world stress test. A single server will be overloaded pretty [...]]]></description>
			<content:encoded><![CDATA[<p>Congratulations: after spending plenty of time on creating and polishing your perfect web application in your development environment, it is finally meant to be released for public consumption.</p>
<p>If it proves to be popular (or simply gets <a href="http://slashdot.org/">slahdotted</a>), the application is in for a first real-world stress test.  A single server will be overloaded pretty fast, but hosting the application on a server farm for traffic that might never come will get expensive very soon.</p>
<p>Amazons <a href="http://ec2.amazonaws.com/">Elastic Compute Cloud</a> (EC2) to the rescue. EC2 offers great flexibility for running web applications. Pre-created or custom application server images (so called AMI &#8211; Amazon Machine Images) based on Linux and Xen allow fine-grained control over available software. The web application might be running on a single server, but if the load is rising, the load may be dispersed by starting new server instances. If the load decreases, the number of servers may be reduced again.</p>
<p>The possibility to provide your own server images (AMIs) allows for server instances with different roles: one or more database servers might provide central storage services for your application servers while another server instance simply processes incoming and outgoing emails. Network security is ensured and can be specified with a fine-grained security policy.</p>
<p>Amazon bills by running instance per hour with three different hardware configurations available starting at 0.10 USD per hour.  A single server of the lowest category amounts to roughly 70 USD per month, which is probably more expensive than other hosters. But the flexibility to balance load by starting or stopping server instances is priceless.</p>
<p>Web applications need one or more servers to run on, but what about storage? Each server provided by EC2 offers 160 GB (or more, depending on your hardware configuration) of space, but that storage space is only available as long as the server instance is running. Again Amazon provides a solution: its <a href="http://s3.amazonaws.com/">Simple Storage Service</a> (S3). Space (almost) without limit at 0.15 USD per GB and month (+ data transfer, when accessed from outside Amazon&#8217;s network). About the only drawback is that the storage can not be accessed like a ordinary file system. This is due to the distributed architecture, which in turn provides high availability and safety for your precious data.</p>
<p>Communication between your servers may be performed using a third service offered by Amazon: its <a href="http://www.amazon.com/Simple-Queue-Service-home-page/b/ref=sc_fe_l_2?ie=UTF8&amp;node=13584001&amp;no=3435361&amp;me=A36L942TSJ2AJA">Simple Queue Service</a> (SQS) allows message to be sent using one or more queues, which provides for an elegant load balancing solution for distributed services.</p>
<p>A recently established service, Amazon <a href="http://www.amazon.com/b/ref=sc_fe_l_2?ie=UTF8&amp;node=342335011&amp;no=3435361&amp;me=A36L942TSJ2AJA">SimpleDB</a> offers structured data storage. The service is still in limited beta, but seems to cater for your basic database needs without using a full-blown database server of your own.</p>
<p>All these services can be controlled and accessed through web service APIs with a wide variety of clients available in all major programming languages. For Java, these libraries offer all functionality exposed by Amazon&#8217;s services:
<ul>
<li>The excellent <a href="https://jets3t.dev.java.net/">JetS3t</a> library (Apache license) provides access to Amazon S3</li>
<li><a href="http://code.google.com/p/typica/">Typica</a>  (Apache license) exposes the functionality of EC2, SQS and SimpleDB for Java developers</li>
</ul>
<p>Toolkits and support for other languages can be found on the Amazon <a href="http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=59">Resource Center</a> pages.</p>
<p>All in all, Amazons EC2, SQS, and S3 provide the perfect environment for<br />web applications: great flexibilty for a reasonable price with plenty of room to grow according to your needs.</p>
<p>For an example of deploying distributed J2EE Applications using Amazon EC2 see <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1084&amp;ref=featured">this</a><a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1084&amp;ref=featured"> article</a>, another example of using Amazon SQS, EC2, and S3 for distributed processing is described in <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=915&amp;categoryID=135">an article</a> by David Kavanagh, author of the excellent Java library <a href="http://code.google.com/p/typica/">Typica</a> (see above).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2008/02/web-application-infrastructure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

