Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Deploying Grails in the Cloud

Deploying Grails in the Cloud

Deploying Grails applications in Java PaaS providers
GR8Conf US 2013

Ken Liu

July 22, 2013
Tweet

More Decks by Ken Liu

Other Decks in Programming

Transcript

  1. Deploying Grails in the Cloud
    Ken Liu
    GR8Conf US 2013

    View full-size slide

  2. About me
    Web development with Java since JDK 1.0.2 (applets,
    anyone?)
    Groovy and Grails since 2009
    Lead developer for IEEE Spectrum
    Always been a closet fan of dynamic languages
    (starting with Perl)

    View full-size slide

  3. About IEEE / IEEE Spectrum
    Institute of Electrical and Electronics Engineers
    Widely known for standards - 802.3, 802.11
    World’s largest technology professional association -
    400,000 engineers in 160 countries
    Publishes nearly a third of the world’s technical
    literature in EE/CS
    IEEE Spectrum http://spectrum.ieee.org - 100% Grails

    View full-size slide

  4. Agenda
    Cloud hosting and PaaS
    Overview of JVM PaaS providers
    Deploying Grails in the cloud
    Demo: AWS Elastic Beanstalk
    Cloud application architecture

    View full-size slide

  5. Agenda
    Cloud hosting and PaaS
    Overview of JVM PaaS providers
    Deploying Grails in the cloud
    Demo: AWS Elastic Beanstalk
    Cloud application architecture

    View full-size slide

  6. Why deploy in the Cloud?
    Quick startup
    Elastic scalability
    Financial benefits
    Pay per use for one-off / periodic loads
    Reduced long-term financial commitment
    CapEx vs. OpEx

    View full-size slide

  7. Why deploy in the Cloud?
    Data center reliability / uptime
    Global data centers
    Treat hardware / infrastructure resources like software
    Consolidated service provisioning - using APIs
    Empowered business units / bypass traditional IT

    View full-size slide

  8. Cloud service models
    SaaS - Software as a Service
    PaaS - Platform as a Service
    IaaS - Infrastructure as a Service
    More automated, delegated,
    managed, inflexible
    Salesforce, Google Apps, iCloud
    Amazon EC2, Rackspace, Joyent
    GAE, Heroku, Amazon Beanstalk

    View full-size slide

  9. Cloud service models
    Source: http://shlomoswidler.com/2012/07/
    the-missing-layer.html
    Used with permission.

    View full-size slide

  10. What is PaaS?
    Pre-configured application stack(s)
    Middleware layer running on top of IaaS
    Infrastructure automation, rapid deployment
    Abstraction layer for cloud interoperability
    Platform-specific APIs / services

    View full-size slide

  11. Why PaaS?
    Focus on application development, not infrastructure
    Much simpler process for provisioning services /
    resources (compared to IaaS)
    One-off use cases
    Experiment with services without upfront commitment
    Pre-configured integration with other services

    View full-size slide

  12. Typical PaaS features
    Ease of use
    Easily/quickly create new
    environments from
    scratch
    Automated DNS
    Load balancing
    Scaling/autoscaling
    Application monitoring
    Hosted DB
    SSL support
    Support for multiple
    stacks/languages
    Log file management
    Limited customization

    View full-size slide

  13. Why developers love PaaS
    Bypass IT headaches
    Deployment / app
    version management
    Remote log viewing and
    debugging
    Multiple environment
    creation / configuration
    Command-line tools and
    API access
    Integrated CI / build
    Integrated monitoring

    View full-size slide

  14. Evaluating PaaS providers:
    key differentiators
    Ease of use / web
    console
    Developer tools
    Billing / pricing model
    Choice of IaaS providers
    Business maturity
    Breadth of additional
    services
    Support / prof. svcs
    ALM / source control
    SLAs
    Backups / storage mgt.

    View full-size slide

  15. Agenda
    Cloud hosting and PaaS
    Overview of JVM PaaS providers
    Deploying Grails in the cloud
    Demo: AWS Elastic Beanstalk
    Cloud application architecture

    View full-size slide

  16. Selected Java PaaS
    Providers

    View full-size slide

  17. Overview of PaaS providers
    Java support (JDK + Tomcat / Jetty)
    Grails support?
    Compare / contrast different approaches to PaaS

    View full-size slide

  18. Google App Engine
    First well-known Java PaaS offering
    Nice tooling - Eclipse integration
    Useful set of proprietary APIs (image processing, email,
    memcache, task queue)
    Integration with other Google services - Google
    Accounts, Cloud SQL, Cloud Storage, App Engine
    Datastore (NoSQL)

    View full-size slide

  19. Google App Engine
    Explicit constraints for scalability
    restricted Java API, slow startup limitations
    standard Java Threads not allowed, prevents use of
    libraries like Quartz
    Grails app-engine plugin abandoned, doesn't support
    Grails 2.0 (broken)
    Gaelyk - lightweight alternative

    View full-size slide

  20. Pivotal Cloud Foundry
    Open source PaaS platform, run your own cloud
    Multi language, multi-cloud
    Pivotal backing, and of course SpringSource
    Eclipse / STS integration
    v2 recently launched with paid service
    Platform implemented / extended by other vendors

    View full-size slide

  21. Heroku
    Best known for Ruby on Rails hosting
    Beta support for Grails
    Customization via buildpacks
    Only 2 container types: “Dyno” and “2X Dyno”
    Runs on top of Amazon EC2
    Git-based deployment mechanism

    View full-size slide

  22. Heroku Add-ons

    View full-size slide

  23. CloudBees
    Most Java friendly - veterans of Sun/Oracle and JBoss
    Focused solely on Java platform/JVM languages and
    frameworks
    Can target multiple IaaS, but AWS is primary
    First-class support for Grails
    DEV@cloud (hosted Jenkins), Continuous Deployment?
    Add-on marketplace, like Heroku

    View full-size slide

  24. AWS
    Elastic Beanstalk
    Still technically in “beta”, meaning no specific SLAs
    No additional cost
    All other AWS services are available to application (e.g.
    RDS, SES, CloudFront, etc.)
    Integrates with AWS security infrastructure (IAM,
    Security Groups, etc.) and other services (e.g. VPC,
    CloudWatch)

    View full-size slide

  25. AWS
    Elastic Beanstalk
    Can “hack” image used to create instances
    AWS may already be in use at your company
    Big AWS ecosystem - such as Rightscale, Scalr
    Default, “easy” choice - “no one ever got fired for
    buying IBM”

    View full-size slide

  26. Agenda
    Cloud hosting and PaaS
    Overview of JVM PaaS providers
    Deploying Grails in the cloud
    Demo: AWS Elastic Beanstalk
    Cloud application architecture

    View full-size slide

  27. Supporting Grails
    Most environments that will support Java should work
    Supports Java and a web container (Tomcat or Jetty)
    Which JDK implementation? (OpenJDK vs. Oracle JDK)
    Application memory footprint
    Grails build support (maven/Gradle/grails wrapper)

    View full-size slide

  28. General steps for deploying
    Grails
    Create “application” target in cloud provider
    Provision services (e.g. DB) & bind to “application”
    Configure JVM parameters (heap, permgen)
    Configure Grails application: Datasource, logging, etc.
    Build WAR locally, push to cloud via API (or upload)
    Profit!

    View full-size slide

  29. Example: AWS Elastic
    Beanstalk configuration
    DataSource.groovy:
    Pick up environment-specific configuration

    View full-size slide

  30. Grails cloud plugins
    cloud-support plugin (base plugin)
    AWS (not Elastic Beanstalk) - wraps AWS APIs
    Heroku
    Cloud Foundry
    CloudBees
    Google App Engine (deprecated)

    View full-size slide

  31. Grails cloud plugins
    Automate / simplify Grails application configuration -
    automatic binding of service details
    Wrap or provide Grails equivalent CLI commands
    Wrap / simplify API layer with groovy

    View full-size slide

  32. Agenda
    Cloud hosting and PaaS
    Overview of JVM PaaS providers
    Deploying Grails in the cloud
    Demo: AWS Elastic Beanstalk
    Cloud application architecture

    View full-size slide

  33. Demo:
    AWS Elastic Beanstalk

    View full-size slide

  34. Elastic Beanstalk
    Architecture
    Source: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.concepts.architecture.html
    Route 53 DNS
    RDS
    (not part of
    EB)
    EB “Application”
    Host Manager per instance

    View full-size slide

  35. EB Host Manager
    Update application package (e.g. WAR)
    Aggregate events and metrics for later retrieval
    Generate instance-level events
    Monitor the application log files for critical errors
    Monitor the application server
    Rotate your application’s log files and publish them to
    Amazon S3

    View full-size slide

  36. Agenda
    Cloud hosting and PaaS
    Overview of JVM PaaS providers
    Deploying Grails in the cloud
    Demo: AWS Elastic Beanstalk
    Cloud application architecture

    View full-size slide

  37. Cloud application
    architecture
    Design to scale horizontally and with autoscaling
    Local storage is “ephemeral” - don't store to local disk,
    use “cloud storage”, ala S3
    Don't treat cloud servers like data center - make your
    servers “disposable”
    Expect / plan for variations in service quality (e.g. Netflix
    Chaos Monkey)

    View full-size slide

  38. Non-technical challenges
    IT acceptance / FUD
    Ops support - take for granted IT datacenter support
    May actually be more costly than traditional colocation
    How to handle billing / managing costs?
    Learning curve - many new unfamiliar services with
    different characteristics
    Need for governance / auditing

    View full-size slide

  39. Final Recommendations
    Avoid / minimize vendor lock-in
    Set up automatic deployment from your CI
    Consider using PaaS only for Dev/QA but keep
    deploying to existing PROD environments
    Be aware of application architecture differences
    Carefully select cloud provider and run pilot project
    before migrating critical applications

    View full-size slide

  40. Additional Resources
    Java Paas Shootout http://ibm.co/gxWXSF
    Which Freaking PaaS Should I Use? http://bit.ly/
    Rp53UF
    Why Platform as a Service will rule the world http://
    ibm.co/gxWXSF

    View full-size slide

  41. Thank you!
    Ken Liu
    @kenliu (Twitter)
    [email protected]

    View full-size slide