<?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; s3</title>
	<atom:link href="http://blog.jetztgrad.net/category/s3/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>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>

