Tags

, ,

Amazon AWS Elastic Beanstalk enables you to quickly deploy and manage applications in the AWS cloud. What you need to do is just uploading your application. Capacity provisioning, load balancing, auto-scaling, and application health monitoring etc. are handled by AWS.

http://bit.ly/1021oDr gives you an instruction about how to deploy an Application Using AWS Elastic Beanstalk. I do not want to re-invent the wheel in this post. I will  talk about my experience.

1. The sample, TravelLog application, is basically a Spring MVC web based application (We can see the power of Spring. Many SaaS vendor uses Spring). But AWS’s spring implementation is obsolete, I think it is 2.6. thus it does not provide some Spring 3.0 new features.

2. The application itself is impressive. I can use it as my travel memorial.

3. The deployment is extremely slow (This is what I do not like AWS). It cost me approx 15 minutes to do both the deployment and launching of the Apache Tomcat v7. If you do not want to deploy the whole thing into AWS, you can use maven instead to generate a war file and then put it under your favorite  application server.

4.It gives us a good sample of how to use the SimpleDB NO SQL database.

private static Map<String, String> properties = new HashMap<String, String>();
static {
properties.put(“lobBucketName”,S3StorageManager.getKey().toLowerCase() + “-travellog-lob”+ StageUtils.getResourceSuffixForCurrentStage());
Configuration config = Configuration.getInstance();
if ( config.getServiceEndpoint(Configuration.S3_ENDPOINT_KEY) != null ) {
properties.put(“s3endpoint”, config.getServiceEndpoint(Configuration.S3_ENDPOINT_KEY));
}
if ( config.getServiceEndpoint(Configuration.SIMPLE_DB_ENDPOINT_KEY) != null ) {
properties.put(“sdbEndpoint”, config.getServiceEndpoint(Configuration.SIMPLE_DB_ENDPOINT_KEY));
}
}

private static EntityManagerFactoryImpl factory = new EntityManagerFactoryImpl(“TravelLog”
+ StageUtils.getResourceSuffixForCurrentStage(), properties);

public Journal getJournal(String journalId) {
EntityManager em = null;

try {
em = factory.createEntityManager();
Journal journal = em.find(Journal.class, journalId);
return journal;
}
finally {
if (em!=null) {
em.close();
}
}
}

5. It also shows us how to use the AWS S3 service, which provides storage through web services interfaces (REST, SOAP, and BitTorrent)

Let us take a look how s3 service is used to store a TravelLogStorageObject object.

// Make sure the bucket exists before we try to use it

//Every file you upload to Amazon S3 is stored in a container called a bucket
checkForAndCreateBucket(obj.getBucketName());

ObjectMetadata omd = new ObjectMetadata();

//ObjectMetadata represents the object metadata that is stored with Amazon S3

omd.setContentType(obj.getMimeType());
omd.setContentLength(obj.getData().length);

ByteArrayInputStream is = new ByteArrayInputStream(obj.getData());
PutObjectRequest request = new PutObjectRequest(obj.getBucketName(), obj.getStoragePath(), is, omd);

//PutObjectRequest uploads a new object to the specified Amazon S3 bucket. The //PutObjectRequest optionally uploads object metadata and applies a canned //access control policy to the new object.

s3Client.putObject(request);

Advertisements