Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Deploying and running Grails in the cloud


Published on

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

Published in: Technology
  • Be the first to comment

Deploying and running Grails in the cloud

  1. 1. 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!!
  2. 3. Agenda <ul><ul><li>Promise of the cloud </li></ul></ul><ul><ul><li>Different options for deploying and running Grails apps </li></ul></ul><ul><ul><li>Deploying to AWS via CloudFoundry </li></ul></ul><ul><ul><li>Deploying to Google App Engine </li></ul></ul><ul><ul><li>Deploying to AWS via Elastic Beanstalk (Mike) </li></ul></ul><ul><ul><li>Challenges/Bottom line </li></ul></ul>
  3. 4. <ul><li>&quot;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.&quot; - wikipedia </li></ul><ul><ul><li>Shared resources </li></ul></ul><ul><ul><li>Not bound to physical resources </li></ul></ul><ul><ul><li>On-demand </li></ul></ul><ul><ul><li>And guys; its nothing like the electricity grid! </li></ul></ul>
  4. 5. The different clouds
  5. 6. The different clouds <ul><ul><li>Google App Engine </li></ul></ul><ul><ul><li>Rackspace Cloud </li></ul></ul><ul><ul><li>IBM Cloud </li></ul></ul><ul><ul><li>VMware vCloud </li></ul></ul><ul><ul><li>Microsoft Azure </li></ul></ul><ul><ul><li>Amazon Web Services </li></ul></ul><ul><ul><li>Virtual Private Cloud </li></ul></ul><ul><ul><li>Private Cloud </li></ul></ul><ul><ul><li>... </li></ul></ul>
  6. 7. 'Virtual Hardware' VS 'Virtual Runtime' <ul><li>Virtual Hardware </li></ul><ul><ul><li>Complete stack (hardware, OS, servers, apps etc) </li></ul></ul><ul><ul><li>Some limitations in hardware </li></ul></ul><ul><ul><li>Any OS, any JDK, python, PHP etc </li></ul></ul><ul><ul><li>Any app-server </li></ul></ul><ul><ul><li>Take care of scaling single machines yourself </li></ul></ul><ul><ul><li>Pay as you go and hard 'root servers' </li></ul></ul><ul><li>Virtual Runtime </li></ul><ul><ul><li>Runtime/Platform oriented </li></ul></ul><ul><ul><li>Shared runtime environment </li></ul></ul><ul><ul><li>Limitations in runtime features (security etc) </li></ul></ul><ul><ul><li>Specific runtime environment </li></ul></ul><ul><ul><li>Scalable runtime environment </li></ul></ul><ul><ul><li>Pay as you go  </li></ul></ul>
  7. 8. Categories of providers <ul><li>&quot;shared servers provide resources, software, and data&quot; </li></ul><ul><li>Platform as a service different from infrastructure as a service </li></ul><ul><li>Virtual hardware - Infrastructure as a service </li></ul><ul><ul><li>vCloud </li></ul></ul><ul><ul><li>EC2 </li></ul></ul><ul><ul><li>RackSpace Cloud </li></ul></ul><ul><li>Virtual 'runtime' - Platform as a service </li></ul><ul><ul><li>Google App Engine </li></ul></ul><ul><ul><li>Elastic Bean Stalk (hybrid, kind of) </li></ul></ul><ul><ul><li>Microsoft Azure </li></ul></ul>
  8. 9. So let's get started!
  9. 10. <ul><li>Two domains with scaffolded controllers </li></ul><ul><ul><li>User  </li></ul></ul><ul><ul><li>Post </li></ul></ul><ul><li>Nothing fancy!! </li></ul><ul><li>Deploy this to different 'cloud providers' </li></ul><ul><li> </li></ul>Basic app example
  10. 11. Basic app example
  11. 12. Amazon EC2 via Cloud Foundry <ul><li>Intro: </li></ul><ul><ul><li>Wrapper around EC2 </li></ul></ul><ul><ul><li>Cloud Foundry acquired by SpringSource acquired by VMware </li></ul></ul><ul><ul><li>CloudFoundry uses cloud-tools Apache2 licensed cloud management tools ( </li></ul></ul><ul><ul><li>Deploys to EC2/EBS with their own AMIs </li></ul></ul><ul><ul><li>Grails plugin </li></ul></ul><ul><li>Prerequisites: </li></ul><ul><ul><li>AWS account (CloudFoundry deploys to EC2 & EBS) </li></ul></ul><ul><ul><li>CloudFoundry account ( </li></ul></ul>
  12. 13. Details Cloud Foundry <ul><ul><li>Deploys to EC2 </li></ul></ul><ul><ul><li>Files (.war etc) are stored on your S3 storage </li></ul></ul><ul><ul><li>Pre-packaged AMIs from Cloud Foundry </li></ul></ul><ul><ul><li>Tomcat 5.5, tcServer, eXoECM, Liferay </li></ul></ul><ul><ul><li>MySQL </li></ul></ul><ul><ul><li>Initialization scripts - script to execute upon startup </li></ul></ul><ul><ul><li>Grails plugin uses their API to deploy </li></ul></ul>
  13. 14. Deploying via Cloud Foundry <ul><ul><li>grails install-plugin cloud-foundry </li></ul></ul><ul><ul><li>configure mysql automatically? - yes </li></ul></ul><ul><ul><li>Add CloudFoundry credentials </li></ul></ul><ul><ul><li>grails war </li></ul></ul><ul><ul><li>grails cloud-foundry-deploy </li></ul></ul><ul><li> </li></ul>
  14. 15. Deploying via Cloud Foundry
  15. 16. Deploying via Cloud Foundry
  16. 17. Deploying via Cloud Foundry <ul><li>showtime </li></ul>
  17. 18. Cloud Foundry gotchas <ul><ul><li>It does not automatically set your DataSource.groovy (even though it tells you it does) </li></ul></ul><ul><ul><ul><li>Solution: Look at the plugin directory and copy over the details. user: <appname>-user, password: <appname>-password etc. </li></ul></ul></ul><ul><ul><li>MySQL user names can be up to 16 characters long  (that's not what the Cloud Foundry error message says...) </li></ul></ul><ul><ul><ul><li>If your <appname> is too long the MySQL deployment will not work with the '-user' added.  </li></ul></ul></ul><ul><ul><ul><li>Solution: Change the app's name in the CloudFoundry.groovy and change in DataSource.groovy </li></ul></ul></ul>
  18. 19. Google App Engine <ul><li>Intro: </li></ul><ul><ul><li>Platform as a Service </li></ul></ul><ul><ul><li>Started for python, Java support since 2009 </li></ul></ul><ul><ul><li>BigTable (No MySQL) </li></ul></ul><ul><ul><li>Run by ... Google </li></ul></ul><ul><li>Prerequisites: </li></ul><ul><ul><li>GAE account </li></ul></ul><ul><ul><li>Have GAE SDK installed ( </li></ul></ul>
  19. 20. Deploy on Google App Engine <ul><ul><li>grails uninstall-plugin tomcat </li></ul></ul><ul><ul><li>grails install-plugin app-engine </li></ul></ul><ul><ul><li>choose 'jpa' for persistence </li></ul></ul><ul><li>GORM no more... but gorm-jpa plugin helps a bit </li></ul><ul><ul><li>g rails install-plugin gorm-jpa   </li></ul></ul><ul><ul><li>Annotate Domains  </li></ul></ul><ul><ul><li>Make sure all queries, transactions etc are working </li></ul></ul><ul><ul><ul><li>For the example app -> fix bootstrap </li></ul></ul></ul><ul><li> </li></ul>
  20. 21. Deploy on Google App Engine
  21. 22. Deploy on Google App Engine
  22. 23. Deploy on Google App Engine <ul><li>showtime </li></ul>
  23. 24. Google App Engine Gotchas <ul><ul><li>No more hibernate </li></ul></ul><ul><ul><li>No more gorm (gorm-jpa maybe) </li></ul></ul><ul><ul><li>No file system access </li></ul></ul><ul><ul><li>No full J2EE runtime </li></ul></ul><ul><ul><li>No more than 10 apps (i heard) </li></ul></ul><ul><ul><li>No renaming of your app </li></ul></ul><ul><ul><li>No ... </li></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><li>Scaffolding that comes with Grails plugin doesn't work </li></ul></ul><ul><ul><li>I am not smart enough for JPA on GAE </li></ul></ul><ul><ul><li>But: Lots of automatic scale stuff </li></ul></ul>
  24. 25. Amazon Elastic Beanstalk <ul><li>Intro </li></ul><ul><ul><li>Console style front-end to Amazon WS </li></ul></ul><ul><ul><li>Standard Java - Apache / MySQL / Tomcat on 64-bit Linux </li></ul></ul><ul><ul><li>Eclipse Integration </li></ul></ul><ul><li>Benefits </li></ul><ul><ul><li>Users can think in 'versions'  </li></ul></ul><ul><li>       as opposed to EBS snapshots, EC2 instances and AMIs, etc. </li></ul><ul><ul><li>Simplifies choices, management </li></ul></ul><ul><ul><li>Advanced Users can customize low-level services </li></ul></ul><ul><ul><li>Automagic DNS assignment - a la AppEngine </li></ul></ul><ul><li> </li></ul>
  25. 26. Amazon Elastic Beanstalk   - V2     App example - Blogger      <ul><li>  </li></ul>
  26. 27. Elastic Beanstalk     App example - Travel Log      <ul><li>  </li></ul>
  27. 28. Deploy Custom AMI on Amazon EC2   <ul><li>Alternative for 'Cloud SysAdmin' types (IaaS) </li></ul><ul><ul><li>Deploy WAR files using scp or EC2 plug-in for Firefox </li></ul></ul><ul><ul><li>Management console, SSH Access, Snapshots for backup </li></ul></ul><ul><li>'Canonical' Java Stack : </li></ul><ul><ul><li>Ubuntu 10 Server (32) </li></ul></ul><ul><ul><li>Tomcat 6.0.29 </li></ul></ul><ul><ul><li>MySQL </li></ul></ul><ul><ul><li>Apache 2.2.x </li></ul></ul><ul><li>EC2 Dashboard - Manage Instances, IPs, Load balancers </li></ul>
  28. 29. Challenges Opportunities <ul><ul><li>New and unknown environments </li></ul></ul><ul><ul><li>What to choose? </li></ul></ul><ul><ul><ul><li>Which provider? </li></ul></ul></ul><ul><ul><ul><li>Platform as a Service or Infrastructure as a Service? </li></ul></ul></ul><ul><ul><li>Support for all features not 100% there </li></ul></ul><ul><ul><li>Watch out for cost! Make sure to scale down! </li></ul></ul><ul><ul><li>No unified method of cloud computing available -> You might get locked in if you are not careful </li></ul></ul><ul><ul><li>Especially platform as a service binds you to the platform specifics </li></ul></ul>
  29. 30. Bottom Line <ul><ul><li>Deploying your app in the cloud is easy </li></ul></ul><ul><ul><li>Throwing your app into the clouds can be lots of effort </li></ul></ul><ul><ul><li>It's OK to only port parts of your applications as a trial </li></ul></ul><ul><ul><li>Easy to get started with green-field projects </li></ul></ul><ul><ul><li>Different providers have different target groups </li></ul></ul><ul><ul><li>It's so easy to scale up </li></ul></ul><ul><ul><li>It's free to get started </li></ul></ul>
  30. 31. Contact <ul><li>Philip Stehlik </li></ul><ul><li> - p   </li></ul><ul><li>Michael Salera </li></ul><ul><li>  - </li></ul><ul><li>[email_address] </li></ul> @sfgrails Thanks to Taulia for hosting and food!!