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!!
 
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) 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...) If your <appname> is too long the MySQL deployment will not work with the '-user' added.  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 g rails install-plugin gorm-jpa   Annotate Domains  Make sure all queries, transactions etc are working 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? Which provider? 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
Contact Philip Stehlik http://pstehlik.com  -  p @pstehlik.com   Michael Salera http://www.linkedin.com/pub/michael-salera/7/374/779  - [email_address] http://sfgrails.com @sfgrails Thanks to  Taulia  for hosting and food!!

Deploying and running Grails in the cloud

  • 1.
    Deploying and runningGrails 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!!
  • 2.
  • 3.
    Agenda Promise ofthe 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
  • 4.
    &quot;Cloud computing islocation-independent computing, whereby shared servers provide resources, software, and data to computers and other devices on demand, as with the electricity grid.&quot; - wikipedia Shared resources Not bound to physical resources On-demand And guys; its nothing like the electricity grid!
  • 5.
  • 6.
    The different cloudsGoogle App Engine Rackspace Cloud IBM Cloud VMware vCloud Microsoft Azure Amazon Web Services Virtual Private Cloud Private Cloud ...
  • 7.
    '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 
  • 8.
    Categories of providers&quot;shared servers provide resources, software, and data&quot; 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
  • 9.
    So let's getstarted!
  • 10.
    Two domains withscaffolded controllers User  Post Nothing fancy!! Deploy this to different 'cloud providers' https://github.com/pstehlik/sfgrails0802-base Basic app example
  • 11.
  • 12.
    Amazon EC2 viaCloud 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)
  • 13.
    Details Cloud FoundryDeploys 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
  • 14.
    Deploying via CloudFoundry 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
  • 15.
  • 16.
  • 17.
    Deploying via CloudFoundry showtime
  • 18.
    Cloud Foundry gotchasIt does not automatically set your DataSource.groovy (even though it tells you it does) 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...) If your <appname> is too long the MySQL deployment will not work with the '-user' added.  Solution: Change the app's name in the CloudFoundry.groovy and change in DataSource.groovy
  • 19.
    Google App EngineIntro: 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)
  • 20.
    Deploy on GoogleApp Engine grails uninstall-plugin tomcat grails install-plugin app-engine choose 'jpa' for persistence GORM no more... but gorm-jpa plugin helps a bit g rails install-plugin gorm-jpa   Annotate Domains  Make sure all queries, transactions etc are working For the example app -> fix bootstrap https://github.com/pstehlik/sfgrails0802-base/tree/gae-jpa
  • 21.
    Deploy on GoogleApp Engine
  • 22.
    Deploy on GoogleApp Engine
  • 23.
    Deploy on GoogleApp Engine showtime
  • 24.
    Google App EngineGotchas 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
  • 25.
    Amazon Elastic BeanstalkIntro 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/
  • 26.
    Amazon Elastic Beanstalk  - V2     App example - Blogger       
  • 27.
    Elastic Beanstalk    App example - Travel Log       
  • 28.
    Deploy Custom AMIon 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
  • 29.
    Challenges Opportunities Newand unknown environments What to choose? Which provider? 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
  • 30.
    Bottom Line Deployingyour 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
  • 31.
    Contact Philip Stehlikhttp://pstehlik.com - p @pstehlik.com   Michael Salera http://www.linkedin.com/pub/michael-salera/7/374/779  - [email_address] http://sfgrails.com @sfgrails Thanks to Taulia for hosting and food!!