deploying and running grails in the cloud
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
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!!
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
"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!
The different clouds
The different clouds
• Google App Engine• Rackspace Cloud• IBM Cloud• VMware vCloud• Microsoft Azure• Amazon Web Services• Virtual Private Cloud• Private 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
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
So let's get started!
Two domains with scaffolded controllers• User • Post
Nothing fancy!!Deploy this to different 'cloud providers'
https://github.com/pstehlik/sfgrails0802-base
Basic app example
Basic app example
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)
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
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
Deploying via Cloud Foundry
Deploying via Cloud Foundry
Deploying via Cloud Foundry
showtime
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
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)
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
Deploy on Google App Engine
Deploy on Google App Engine
Deploy on Google App Engine
showtime
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
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/
Amazon Elastic Beanstalk - V2 App example - Blogger
Elastic Beanstalk App example - Travel Log
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
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
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
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!!