deploying and running grails in the cloud

31
Deploying and running Grails applications in the cloud Prepared for SF Grails Café Centro Feb 2011 Meetup by Philip Stehlik and Michael Salera Thanks to Taulia for hosting and food!!

Upload: philip-stehlik

Post on 29-Aug-2014

8.168 views

Category:

Technology


7 download

DESCRIPTION

Taking a look at different cloud providers and how easy it is to deploy a basic Grails application to them. Created for the http://sfgrails.com meetup Feb 2011.

TRANSCRIPT

Page 1: Deploying and running Grails in the cloud

Deploying and running Grails applications in the cloud

Prepared for SF Grails Café Centro Feb 2011 Meetupby Philip Stehlik 

and Michael Salera

Thanks to Taulia for hosting and food!!

Page 2: Deploying and running Grails in the cloud
Page 3: Deploying and running Grails in the cloud

Agenda

• Promise of the cloud• Different options for deploying and running Grails apps• Deploying to AWS via CloudFoundry• Deploying to Google App Engine• Deploying to AWS via Elastic Beanstalk (Mike)• Challenges/Bottom line

Page 4: Deploying and running Grails in the cloud

"Cloud computing is location-independent computing, whereby shared servers provide resources, software, and data to computers and other devices on demand, as with the electricity grid." - wikipedia

• Shared resources• Not bound to physical resources• On-demand

• And guys; its nothing like the electricity grid!

Page 5: Deploying and running Grails in the cloud

The different clouds

Page 6: Deploying and running Grails in the cloud

The different clouds

• Google App Engine• Rackspace Cloud• IBM Cloud• VMware vCloud• Microsoft Azure• Amazon Web Services• Virtual Private Cloud• Private Cloud• ...

Page 7: Deploying and running Grails in the cloud

'Virtual Hardware' VS 'Virtual Runtime'

Virtual Hardware• Complete stack (hardware,

OS, servers, apps etc)• Some limitations in

hardware• Any OS, any JDK, python,

PHP etc• Any app-server• Take care of scaling single

machines yourself• Pay as you go and hard

'root servers'

Virtual Runtime• Runtime/Platform oriented• Shared runtime

environment• Limitations in runtime

features (security etc)• Specific runtime

environment• Scalable runtime

environment• Pay as you go 

Page 8: Deploying and running Grails in the cloud

Categories of providers

"shared servers provide resources, software, and data"Platform as a service different from infrastructure as a service

Virtual hardware - Infrastructure as a service• vCloud• EC2• RackSpace Cloud

Virtual 'runtime' - Platform as a service• Google App Engine• Elastic Bean Stalk (hybrid, kind of)• Microsoft Azure

Page 9: Deploying and running Grails in the cloud

So let's get started!

Page 10: Deploying and running Grails in the cloud

Two domains with scaffolded controllers• User • Post

Nothing fancy!!Deploy this to different 'cloud providers'

https://github.com/pstehlik/sfgrails0802-base

Basic app example

Page 11: Deploying and running Grails in the cloud

Basic app example

Page 12: Deploying and running Grails in the cloud

Amazon EC2 via Cloud Foundry

Intro:• Wrapper around EC2• Cloud Foundry acquired by SpringSource acquired by

VMware• CloudFoundry uses cloud-tools Apache2 licensed cloud

management tools (https://www.cloudfoundry.com/cloudtools.html)

• Deploys to EC2/EBS with their own AMIs• Grails plugin

Prerequisites:• AWS account (CloudFoundry deploys to EC2 & EBS)• CloudFoundry account (www.cloudfoundry.com)

Page 13: Deploying and running Grails in the cloud

Details Cloud Foundry

• Deploys to EC2• Files (.war etc) are stored on your S3 storage• Pre-packaged AMIs from Cloud Foundry• Tomcat 5.5, tcServer, eXoECM, Liferay• MySQL• Initialization scripts - script to execute upon startup• Grails plugin uses their API to deploy

Page 14: Deploying and running Grails in the cloud

Deploying via Cloud Foundry

• grails install-plugin cloud-foundry• configure mysql automatically? - yes• Add CloudFoundry credentials• grails war• grails cloud-foundry-deploy

https://github.com/pstehlik/sfgrails0802-base/tree/cloudfoundry

Page 15: Deploying and running Grails in the cloud

Deploying via Cloud Foundry

Page 16: Deploying and running Grails in the cloud

Deploying via Cloud Foundry

Page 17: Deploying and running Grails in the cloud

Deploying via Cloud Foundry

showtime

Page 18: Deploying and running Grails in the cloud

Cloud Foundry gotchas

• It does not automatically set your DataSource.groovy (even though it tells you it does)o Solution: Look at the plugin directory and copy over the

details. user: <appname>-user, password: <appname>-password etc.

• MySQL user names can be up to 16 characters long (that's not what the Cloud Foundry error message says...)o If your <appname> is too long the MySQL deployment will

not work with the '-user' added. o Solution: Change the app's name in the

CloudFoundry.groovy and change in DataSource.groovy

Page 19: Deploying and running Grails in the cloud

Google App Engine

Intro:• Platform as a Service• Started for python, Java support since 2009• BigTable (No MySQL)• Run by ... Google

Prerequisites:• GAE account• Have GAE SDK installed

(http://code.google.com/appengine/downloads.html)

Page 20: Deploying and running Grails in the cloud

Deploy on Google App Engine

• grails uninstall-plugin tomcat• grails install-plugin app-engine• choose 'jpa' for persistence

GORM no more... but gorm-jpa plugin helps a bit• grails install-plugin gorm-jpa • Annotate Domains • Make sure all queries, transactions etc are working

o For the example app -> fix bootstrap

https://github.com/pstehlik/sfgrails0802-base/tree/gae-jpa

Page 21: Deploying and running Grails in the cloud

Deploy on Google App Engine

Page 22: Deploying and running Grails in the cloud

Deploy on Google App Engine

Page 23: Deploying and running Grails in the cloud

Deploy on Google App Engine

showtime

Page 24: Deploying and running Grails in the cloud

Google App Engine Gotchas

• No more hibernate• No more gorm (gorm-jpa maybe)• No file system access• No full J2EE runtime• No more than 10 apps (i heard)• No renaming of your app• No ...• http://code.google.com/appengine/docs/java/jrewhitelist.html• Scaffolding that comes with Grails plugin doesn't work• I am not smart enough for JPA on GAE• But: Lots of automatic scale stuff

Page 25: Deploying and running Grails in the cloud

Amazon Elastic Beanstalk

Intro• Console style front-end to Amazon WS• Standard Java - Apache / MySQL / Tomcat on 64-bit Linux• Eclipse Integration

Benefits• Users can think in 'versions' 

       as opposed to EBS snapshots, EC2 instances and AMIs, etc.• Simplifies choices, management• Advanced Users can customize low-level services• Automagic DNS assignment - a la AppEngine

    http://myapp.elasticbeanstalk.com/

Page 26: Deploying and running Grails in the cloud

Amazon Elastic Beanstalk   - V2    App example - Blogger     

Page 27: Deploying and running Grails in the cloud

Elastic Beanstalk    App example - Travel Log     

Page 28: Deploying and running Grails in the cloud

Deploy Custom AMI on Amazon EC2  

Alternative for 'Cloud SysAdmin' types (IaaS)• Deploy WAR files using scp or EC2 plug-in for Firefox• Management console, SSH Access, Snapshots for backup

'Canonical' Java Stack:• Ubuntu 10 Server (32)• Tomcat 6.0.29• MySQL• Apache 2.2.x

EC2 Dashboard - Manage Instances, IPs, Load balancers

Page 29: Deploying and running Grails in the cloud

Challenges Opportunities

• New and unknown environments• What to choose?

o Which provider?o Platform as a Service or Infrastructure as a Service?

• Support for all features not 100% there• Watch out for cost! Make sure to scale down!• No unified method of cloud computing available -> You

might get locked in if you are not careful• Especially platform as a service binds you to the platform

specifics

Page 30: Deploying and running Grails in the cloud

Bottom Line

• Deploying your app in the cloud is easy• Throwing your app into the clouds can be lots of effort• It's OK to only port parts of your applications as a trial• Easy to get started with green-field projects• Different providers have different target groups• It's so easy to scale up• It's free to get started

Page 31: Deploying and running Grails in the cloud

ContactPhilip Stehlikhttp://pstehlik.com - [email protected] 

Michael Salerahttp://www.linkedin.com/pub/michael-salera/7/374/779 [email protected]

http://sfgrails.com@sfgrails

Thanks to Taulia for hosting and food!!