Spring Boot & Cloud Deployment with Heroku 

Agenda

  • Spring Boot
  • Demo - Basic Spring Boot app.
  • Cloud Deployment + Heroku
  • Demo - Deploy our spring app in the cloud, make changes, roll back, heroku features

Spring Boot - What is it?

  • Framework to improve bootstrapping and dev of spring apps.
  • Takes an opinionated approach to configuration.
  • Doesn't add much functionality to the actual spring framework itself, but it looks to make spring more lightweight and portable and allow developers to get up and running quickly, while still leveraging the power of the framework.

Spring Boot - What problem does it solve?

  • Looks to eradicate bulky XML configs and complex dependency injection
  • Ideal for a microservice architecture.
  • Easy to deploy, no need to bundle .war and deploy to tomcat, jetty etc.
  • Reduces the need for the likes of chef to write deployment or boot scripts, this is all done through your build tool.
  • You can still use all this if you want, any configuration you make will override boots autoconfig.

Spring boot features

  • One executable .jar with embedded tomcat, jetty or undertow.
  • 'Starter poms'
  • Auto-configs configurable in application.properties
  • Application class is run as a main() method
  • CLI and GUI for bootstrapping
  • Zero XML Required, however supported.
    package com.springapp;
    
    @SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScan
    public class Application {
    
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    }

Cloud Deployment - Benefits

  • Elastic resources - Scale up and down quickly to meet demand
  • Pay only for the resources you use
  • Highly configurable and usable through GUI and APIs, create new instances and scale at the click of a button
  • Big companies using the cloud to deploy applications and store data - Facebook, Gmail, Dropbox, Paypal, Amazon.
  • Cost - No more on prem servers, maintenence fees, physical security
  • Centralize information and access it from anywhere in the world

What is Heroku?  

  • Scalable cloud platform as a service
  • No need to worry about infrastructure
  • Runs applications in lightweight Unix VM's known as 'dynos'
  • Deploys apps using git
  • Why not just use AWS EC2?

Heroku Features  

  • Free unlimited use of one dyno
  • Deploy with git commands
  • Multi-language support - Java, Scala, Node.js, Python, Ruby
  • CLI - Logs, release history, rollbacks + more
  • Native Postgres DB support
  • Many add-ons and 'buttons' available
  • Heroku environment variables
  • Scales easily
  • Clean and intuitive Web interface

Resources

  • https://devcenter.heroku.com/

  • https://devcenter.heroku.com/articles/how-heroku-works
  • http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features
  • https://www.heroku.com/features
  • http://www.infoq.com/articles/microframeworks1-spring-boot
  • https://www.youtube.com/watch?v=dxk8b9rSKOo

Cloud Deployment With Spring Boot and Heroku

By Martin McKeaveney

Cloud Deployment With Spring Boot and Heroku

  • 699