56
Running Java applications on the A El ti C t Cl d Amazon Elastic Compute Cloud Chris Richardson Chris Richardson Author of POJOs in Action Founder of Cloud Tools www.chrisrichardson.net www.chrisrichardson.net Slide 1 Copyright (c) 2008 Chris Richardson. All rights reserved.

Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Embed Size (px)

DESCRIPTION

Traditionally, computer hardware was a scarce, expensive resource. Running performance tests often meant scavenging for machines around the office. Today, however, things are different. With Amazon's EC2, a cluster of servers is now just a web service call away. In this presentation you will learn about design and implementation of Cloud Tools, which is a Groovy-based framework for deploying and testing Java EE applications on EC2. This framework provides a simple (internal) DSL for configuring a cluster (database + web container + apache), deploying a web application, and running performance tests using JMeter. You will learn about capabilities of EC2 and how to use it for development and deployment. We describe how we use Amazon S3 to work around EC2's lack of a persistent file system and avoid time-consuming uploads of WAR files.

Citation preview

Page 1: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Running Java applications on the A El ti C t Cl dAmazon Elastic Compute Cloud

Chris RichardsonChris RichardsonAuthor of POJOs in ActionFounder of Cloud Toolswww.chrisrichardson.netwww.chrisrichardson.net

Slide 1Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 2: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Overall presentation goalp g

Show how to useAmazon Elastic Compute CloudAmazon Elastic Compute Cloud

for developing and deploying Java applications

Slide 2Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 3: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

About Chris

Grew up in England and live in Oakland, CAp g ,Over twenty years of software development experience

Building object-oriented software since 1986Using Java since 1996Using J2EE since 1999Using J2EE since 1999

Author of POJOs in ActionSpeaker at JavaOne, SpringOne, NFJS, JavaPolis, Spring Experience, etc.Chair of the eBIG Java SIG in Oakland (www ebig org)(www.ebig.org)Run a consulting and training company that helps organizations build better software faster and deploy it on Amazon EC2Founder of Cloud Tools, an open-source project f d l i J li ti A EC2 for deploying Java applications on Amazon EC2: http://code.google.com/p/cloudtools

Slide 3Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 4: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Agendag

Cloud computing with Amazon EC2Using Amazon EC2Overview of Cloud ToolsDeveloping on Amazon EC2Deploying on Amazon EC2Deploying on Amazon EC2

Slide 4Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 5: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Computing has come a long wayp g g yPast

Present

www.computermuseum.org.uk

www.dell.com

Yet we rarely have enough

Slide 5Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 6: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Cloud computingp g

A pool of highly scalable, abstracted A pool of highly scalable, abstracted infrastructure that hosts your application, and is billed by

consumptionp

Slide 6

By James Staten of Forrester Research

Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 7: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Power generationgPast Present

Slide 7Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 8: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Amazon-Style Cloud Computingy p g

Elastic Compute Cloud (EC2)O d d tiOn-demand computing

Elastic Block Storage (EBS)"SAN on demand"SAN on demand

Simple Storage Service (S3)Stores blobs of data

Simple Queue Service (SQS)Hosted queue-based messaging system

SimpleDBStore data setsExecute queries

Pay per use services managed

by AmazonExecute queries

Slide 8

by Amazon

Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 9: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

What is Amazon EC2?

Virtualized computing environmentServer instances managed through a web service APIIP addresses and host names assigned dynamicallyPay by the hour ($0.10-0.80/hour) + external bandwidth ($0 10 0 18/Gbyte)bandwidth ($0.10-0.18/Gbyte)

https://ec2.amazonaws.com/?Action=RunInstances&ImageId=ami-398438493

<RunInstancesResponse>…

&MaxCount=3&MinCount=3

k

</RunInstancesResponse>

cer@arrakis ~$ ssh … [email protected] login: Sun Dec 30 18:54:43 2007 from 71.131.29.181[root@domU-12-31-36-00-38-23:~]

Slide 9Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 10: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Instance typesyp

Virtual Compute 32/ Memory Storage $/hrCores

pUnits /core*

/64Bit

y g $/

Small 1 1 32 bit 1.7G 160G 0.10

High-CPUMedium

2 2.5 32 bit 1.7G 350G 0.20

Large 2 2 64 bit 7.5G 850G 0.40

Extra Large

4 2 64 bit 15G 1690G 0.80

High-CPU XL

8 2.5 64 bit 7G 1690G 0.80

Slide 10

* EC2 Compute Unit = 1.0-1.2 GHz 2007 Opteron or 2007 Xeon processor

Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 11: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Operating systemsp g y

Use Amazon provided Machine Image (AMI)32 bit Fedora Core 432-bit Fedora Core 464-bit Fedora Core 6

Many 3rd parties have public AMIsy p pVarious Linux distributionsE.g. Redhat, RightScale

Sun provides OpenSolarisSun provides OpenSolarisWindows is private betaBuild your own Linux:Build your own Linux:

Install applications starting with someone else's AMI and save itCreate an AMI from scratchCreate an AMI from scratch

Slide 11Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 12: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

One minor thing…g

T i t i t Terminate your instance ⇒⇒

your local data is lost.y

Either very good or very bad

Slide 12Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 13: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Elastic Block Storageg

Mountable storage volumes"O d d SAN""On-demand SAN"Size: 1 GB to 1 TBMount on a single instanceMount on a single instance

Create snapshotsStored in S3Stored in S3Create new volumes from the snapshot

Cost:Cost:$0.10/GByte/month$0.10 per 1 million I/O requests$ p q

Slide 13Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 14: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Elastic IP addresses

Instance IP addresses are dynamically allocated on start-upallocated on start up

Does not work well for publicly accessible services, e.g. a website

Elastic IP addresses:Elastic IP addresses:Statically allocated addressesAssociated with your account (max. 5)Attached to an instance (e g public facing web Attached to an instance (e.g. public facing web server)You configure DNS to resolve to the elastic IP address

Pricing:Non-attached Elastic IP address - $0.01/hour$0 10 per remap (if > 100 in a month)$0.10 per remap (if > 100 in a month)

Slide 14Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 15: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Regions and availability zonesg y

By default, your database master and slave could run on the same physical host!could run on the same physical host!Regions:

Geographically dispersed locationsCurrently only oneCurrently only one

Availability zone:Part of a region

d b l d f f l hEngineered to be insulated from failure in other zones

Specify availability zone when launching i tinstances:

Same zone as other instances for free data transferDiff t f hi h il bilitDifferent zone for higher-availability

Slide 15Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 16: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

What is the Amazon Simple Storage Service (S3)?g ( )

Flat storage model consisting of buckets and objectsand objects

Bucket – has a name and contains objectsObjects – has a key, stores 1 byte - 5GObject key can look like a path ☺Object key can look like a path ☺

Cost:$0.15/GB-Month$0 10 0 18/GB of data transferred$0.10-0.18/GB of data transferred$0.00001-$0.000001/Web Service callData transfers between EC2 and S3 are free of bandwidth chargesbandwidth charges

Buckets and objects can be:Public – accessible by anyoneP i ibl l bPrivate – accessible to owner, acl member

Slide 16Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 17: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

S3 REST API

PUT / HTTP/1.1Host: <BucketName>.s3.amazonaws.com

Create a bucket

PUT /<ObjectName> HTTP/1.1Host: <BucketName>.s3.amazonaws.com

Authorization: AWS AWSAccessKeyId:Signature…

Host: <BucketName>.s3.amazonaws.com Authorization: AWS AWSAccessKeyId:Signature……Bytes…

Create an item in a bucket

GET /<ObjectName> HTTP/1.1Host: <BucketName>.s3.amazonaws.com Authorization: AWS AWSAccessKeyId:Signature…

Download an item

DELETE /<ObjectName> HTTP/1.1Host: <BucketName>.s3.amazonaws.com Authorization: AWS AWSAccessKeyId:Signature…

Delete an item

Slide 17

Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 18: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Using EC2 and S3 togetherg g

AMIs are stored in S3EC2 instances use S3:

Use REST APIStore database snapshots in S3Use 3rd party Linux file system that stores data in S3Store EBS volume snapshots in S3

Slide 18Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 19: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

So what does this mean?

For developersImmediate access to many serversSimplified setupGreat for testing

For deploymentEliminates capital expensesReduces risk of success catastrophe

Slide 19Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 20: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Agendag

Cloud computing with Amazon EC2Using Amazon EC2Overview of Cloud ToolsDeveloping on Amazon EC2Deploying on Amazon EC2Deploying on Amazon EC2

Slide 20Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 21: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Signing up for Amazon Web Services

AWS access identifiers:

Account IdAccount IdAccess IdSecret keyPrivate key Private key and certificate

Only takes a few minutesfew minutes

Slide 21Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 22: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

EC2 API and Tools

SOAP and Query APIsL h d i t tLaunch and manage instances etc

Amazon provided CLI toolsCLI equivalents of APIsCLI equivalents of APIsAMI creation tools

AWS CLI tools from Tim KayyCLI for S3 and EC2Alternatives to Amazon CLI tools

El i FElasticFoxAwesome Firefox pluginLaunch and manage instancesLaunch and manage instances

Slide 22Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 23: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Using the Query APIg Q y

https://ec2.amazonaws.com/?queryparameters...ters...Mandatory parameters:

Action – what to doAWSA K Id idAWSAccessKeyId – your access idVersion – API versionTimestamp – when request was madep qExpires – when it expiresSignature – digest of parameters and secret key key SignatureVersion – set to 1

Other parameters depend on ActionR t XML d tReturns an XML document

Slide 23Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 24: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Example EC2 requestsp q

Action ParametersAction Parameters

RunInstances MinCount, MaxCount, ImageId, InstanceType, …

TerminateInstances InstanceId nTerminateInstances InstanceId.n

DescribeInstances InstanceId.n

CreateSecurityGroup GroupName, GroupDescription

AuthorizeSecurityGroupIngress GroupName, SourceSecurityGroupName, IpProtocol

h S GDeauthorizeSecurityGroupIngress …

Slide 24Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 25: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

aws - simple access to EC2 and S3p

http://timkay.com/aws/Easy to use CLI for EC2 and S3Implemented in PerlAuthenticates using access id and secret Authenticates using access id and secret key stored in ~/.awssecret

Slide 25Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 26: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

ElasticFox– Firefox pluginp g

Slide 26Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 27: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Launching instancesg

TIP: launch with a key ypair or else you won't have access

Slide 27Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 28: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Creating your own imageg y g

Easier: Modify an existing AMIL h AMILaunch AMIConfigure: e.g. yum install …

Harder: Build one from scratchHarder: Build one from scratchLaunch AMICreate a file to contain OS installationCreate a file to contain OS installationMount as a loopback fileInstall OS: yum –-installrooty

Use AMI tools to bundle and upload to S3

Slide 28Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 29: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Agendag

Cloud computing with Amazon EC2Using Amazon EC2Overview of Cloud ToolsDeveloping on Amazon EC2Deploying on Amazon EC2Deploying on Amazon EC2

Slide 29Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 30: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Deploying a web application on EC2p y g pp

Slide 30

Not rocket science but there are many servers to configure and multiple files to upload

Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 31: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

What's Cloud Tools?

Open source project32 and 64 bit AMIs32 and 64 bit AMIs

CentOS 5.10Apache/Tomcat/MySQL/JMeter/JetS3t installedp y Q

EC2Deploy frameworkLaunches instancesConfigures Tomcat MySQL ApacheConfigures Tomcat, MySQL, ApacheDeploys web applicationsRuns Jmeter testsWritten in Groovy

Maven and Grails pluginsQuick and easy deployment to EC2Quick and easy deployment to EC2

Slide 31Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 32: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

EC2Deploy frameworkp y

Provides a DSL for describing a cluster:N b f T t M SQL lNumber of Tomcats, MySQL slavesDatabase scriptsLocation of web applicationsLocation of web applications

Launches EC2 instancesConfigures MySQLg y QConfigures Tomcat and deploys web applicationsConfigures Apache to proxy the Tomcat serversRuns JMeter testsRuns JMeter tests

Slide 32Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 33: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Example EC2Deploy Scriptp p y p

def ec2 = new EC2(…)

ClusterSpec clusterSpec = new ClusterSpec().tomcats(1).instanceType(EC2InstanceType.SMALL).slaves(1)

ebApp('/home/cer/ /ptrack' "ptrack").webApp('/home/cer/…/ptrack', "ptrack").catalinaOptsBuilder({optsBuilder, databaseHost, slaves ->

optsBuilder.arg("-Xmx500m")optsBuilder.prop("jdbc.db.server", databaseHost)})

.schema("ptrack", ["ptrack": "ptrack"], ["src/test/resources/testdml1.sql", [ s c/test/ esou ces/testd .sq ,"src/test/resources/testdml2.sql"])

SimpleCluster cluster = new SimpleCluster(ec2, clusterSpec)

cluster.start()

cluster.loadTest("/home/cer/…/jmeter/SimpleTest.jmx", [5, 10, 15])

cluster.stop()

Slide 33Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 34: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Domain model

stop()start()

<<façade>>SimpleCluster

namenumberOfTomcats

ClusterSpec

ApacheServerTomcatServer MySqlServer JmeterApplication

start()loadTest()numberOfMySqlSlaves

...

uploadToS3()updateTomcat()

contextexplodedWar

WebApp

<<abstract>>Application

updateTomcat()

startPolling()stopPolling()

EC2

waitUntilRunning()stop()

EC2Server

instanceIdstate

EC2InstanceState

newServers(n)...

EC2RequestExecutor

ssh(command)...

publicDnsNameprivateDnsName

Ssh

Uses Query API to run, terminate and describe instances

Executes ssh and scp commands

executeRequest(params)

Executorssh(dns, command, …)

Slide 34Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 35: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Configuration DSLg

class ApacheServer extends Application {

def configure() {writeFile fileName: "$apacheConfDir/cluster.conf",

templateName: "/templates/cluster.conf", templateArgs: [tomcats: tomcats]

exec "$apacheBinDir/apachectl restart"waitForHttp port:80, path: tomcats[0].contexts[0]

}…}

class MySqlServer extends Application {

d f fi A M t () {def configureAsMaster() {writeFile fileName: "/etc/my.cnf", templateName: "/templates/master.my.cnf"

restartService "mysqld"

exec command: "mysql -u root", templateName: "/templates/createSchema.sql", templateArgs: [schemaSpec: schemaSpec]

executeSchemaScripts()

Slide 35

}}

Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 36: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Efficiently uploading web applications, etc.pp ,

Non-durable disks = upload the entire web applicationpp

20+ MBs of jars, etc.Takes a long time (over a DSL connection)

Web application consists of:90% 3rd party libraries – rarely changing10% application code and content – only some of it changes

U J tS3t t l t l dUse JetS3t to accelerate uploadsIncremental upload of exploded web application to S3 bucketIncremental download to Tomcat webapps/ directoryIncremental download to Tomcat webapps/ directoryFirst upload is slow but subsequent uploads are fast

Slide 36Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 37: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Maven Pluging

<plugin><groupId>net chrisrichardson</groupId>

Goals:• deploy• redeploy• stop<groupId>net.chrisrichardson</groupId>

<artifactId>cloudtools-maven-plugin</artifactId><configuration><schemaName>ptrack</schemaName><schemaUsers>

stop• dbsave• dbrestore• jmeter

<schemaUsers><param>ptrack:ptrack</param>

</schemaUsers><catalinaOptsBuilder>{builder, databasePrivateDnsName ->{ ,

builder.arg("-Xmx1000m")builder.prop("jdbc.db.server", databasePrivateDnsName)}

</catalinaOptsBuilder></configuration>

</plugin>

mvn cloudtools:deploy

Slide 37Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 38: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Grails Pluging

Packages E2Deploy as a Grails g p yframework pluginDeploys a Grails application to EC2Deploys a Grails application to EC2

$ grails install-plugin <path to plugin>$ grails cloud-tools-deploy$ g p y

Slide 38Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 39: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Agendag

Cloud computing with Amazon EC2Using Amazon EC2Overview of Cloud ToolsDeveloping on Amazon EC2Deploying on Amazon EC2Deploying on Amazon EC2

Slide 39Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 40: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Collecting performance metricsg p

700070

4000

5000

6000

40

50

60

TPS

1000

2000

3000

10

20

30TPS

ART

R i 00

1 2 4 8 16 32 64Requires hardwareTime consuming

Measure transactions/second (TPS), average response time (ART), utilization, etc.

Multiple test runs with different loads, number of servers, etc.

Time consuming

Slide 40Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 41: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Load testing with Cloud Toolsg

Runs JMeter with <performanceReport><cpus>1</cpus><threads>10</threads>

specified number of threads

<host><name>database</name><cpuUtil>3.2757014224403784</cpuUtil>

</host><host><name>tomcat0</name>

Collects machine utilization stats

<name>tomcat0</name><cpuUtil>94.32473318917411</cpuUtil>

</host><host><name>apache</name><cpuUtil>0.12280614752518504</cpuUtil>

Generates reportsExecutes multiple

p / p</host><host><name>jmeter</name><cpuUtil>7.033683910704496</cpuUtil>

</host>

test runs simultaneously

…<duration>557.943</duration><tps>10.753786677133686</tps><art>916.6578333333</art>

</performanceReport>

Slide 41

mvn cloudtools:jmeter -Dcloudtools.thread.count=1,4,8

Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 42: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Other kinds of testingg

Testing failoverLaunch clusterTake down serversTest recovery scripts, e.g. MySQL slave->master

T ti d t b dTesting database upgradesLaunch clusterI ll h f d i dInstall snapshot of production dataApply database migration scriptV if th t it kVerify that it works

Slide 42Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 43: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Functional testingg

Tests can be slow, e.g.W b t tWeb testsDatabase intensive tests

Run tests in parallel on EC2Run tests in parallel on EC2Multiple test drivers, app servers, DBsRelatively cheap: >$75/hour developer vs. $ /h h$0.10/hour machine

Selenium Grid from ThoughtworksOpen Source frameworkOpen Source frameworkRuns Selenium web tests in parallel on EC2

Stay tuned for more general solutionsStay tuned for more general solutions

Slide 43Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 44: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Building on a fresh machineg

Debug builds that fail because of a missing dependency

Maven dependencyManually installed 3rd party library

Build on a fresh EC2 instance Great for open-source projects

Slide 44Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 45: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Agendag

Cloud computing with Amazon EC2Using Amazon EC2Overview of Cloud ToolsDeveloping on Amazon EC2Deploying on Amazon EC2Deploying on Amazon EC2

Slide 45Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 46: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Deploying applications on Amazon EC2

Great for startups (especially those without a business model)

Get up and running ready quicklyNo upfront hardware costsScale up/down with load

d h k fReduces the risk of a success catastrophe

Great for enterprisesGreat for enterprisesNo need to wait for corporate ITU f h t t j tUse for short-term projects

Slide 46Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 47: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Issues with AWS

Security:Lack of PCI complianceLack of PCI complianceDiscomfort with sending customer data to a 3rd party

TechnologTechnology:Not yet suitable for extremely large relational databasesLack of very large machines, e.g. 64G memoryLack of multicast

Financials:Cost of bandwidthSteady state costs > your own hardwareSteady state costs > your own hardware

Slide 47Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 48: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Starter website - $$

www.acme.com

EC2 Instance

Elastic IP A

Apache

Tomcat

MySQL

Slide 48

EBS Volume

Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 49: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Highly available - $$g y $$

www.acme.com

Availability Zone A Availability Zone B

Elastic IP A Elastic IP B

Apache Apache

TomcatTomcat Tomcat

Tomcat

MySQL(Master)

MySQL(slave)

Slide 49

EBS Volume

Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 50: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Batch processing architecturep g

e g media transcodinge.g. media transcoding

Slide 50Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 51: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Easy upgradesy pg

Clone production environmentApply upgradesTerminate old instances once you are ysure that everything works

Slide 51Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 52: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Cloud burstingg

Host application on your own hardware Use AWS for short-term spikes

e.g. use EC2 instances with slave DBs to handle read-only requests

Periodic batch jobsE.g. content rendering/transformation

Slide 52Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 53: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Using AWS in your applicationg y pp

Simple Storage Service (S3)Stores blobs of dataStores blobs of dataEg. Photo sharing websiteStore mediaH d URL S3 bjHand out URLs to S3 objects

Simple Queue Service (SQS)Hosted queue-based messaging systemHosted queue based messaging systemAlternative to JMSLoosely coupling between systems

Si l DBSimpleDBStore data setsExecute queriesq

Slide 53Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 54: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Java libraries for AWS

Generate the REST/SOAP requests manuallymanuallyJetS3t

Rich API for accessing S3Rich API for accessing S3https://jets3t.dev.java.net/

TypicaypAPI for SQS, EC2, SimpleDBhttp://code.google.com/p/typica/

Si l JPASimpleJPASubset of JPA on Simple DBhttp://code google com/p/simplejpa/http://code.google.com/p/simplejpa/

Slide 54Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 55: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Summaryy

Cloud ComputingImmediate access to many serversPay as you go – no upfront i t t/ it t i dinvestment/commitment requiredEasily scale up/down

Cl d T lCloud ToolsEasy deployment and testing from Maven and GrailsMaven and GrailsConfigure multiple clustersRun JMeter tests in parallelRun JMeter tests in parallel

Slide 55Copyright (c) 2008 Chris Richardson. All rights reserved.

Page 56: Developing and Deploying Java applications on the Amazon Elastic Compute Cloud (CloudCon East 08)

Final thoughtsg

Download Cloud Tools today:

http://code.google.com/p/cloudtools

Buy my book ☺Buy my book ☺

Send email:

[email protected]

Visit my website:

http://www.chrisrichardson.net

Talk to me about consulting and t i itraining

Slide 56Copyright (c) 2008 Chris Richardson. All rights reserved.