46
© 2016 Pivotal Software, Inc. All rights reserved. Cloud Native Java Microservices Kenny Bastani Spring Developer Advocate 1

Cloud Native Java Microservices

Embed Size (px)

Citation preview

Page 1: Cloud Native Java Microservices

© 2016 Pivotal Software, Inc. All rights reserved.

Cloud Native Java MicroservicesKenny Bastani Spring Developer Advocate

1

Page 2: Cloud Native Java Microservices

Kenny Bastani

@kennybastani

Spring Developer Advocate

Page 3: Cloud Native Java Microservices

Agenda

Agenda

1 Microservices & Cloud Native

2 Spring Boot

3 Spring Cloud

4 RESTful Microservices

5 Push to Cloud Foundry

Page 4: Cloud Native Java Microservices

© 2016 Pivotal Software, Inc. All rights reserved.

Microservices

4

Page 5: Cloud Native Java Microservices

Monolithic Architecture

Page 6: Cloud Native Java Microservices

SOA - Service Oriented Architecture

Page 7: Cloud Native Java Microservices

Microservice Architecture• Each team gets one database and one service

• Shared caches are platform provided services that are shared for consistency

Page 8: Cloud Native Java Microservices

Monolithic Architecture

Page 9: Cloud Native Java Microservices

Monolith to Microservice

Page 10: Cloud Native Java Microservices

Monolith to Microservice

Page 11: Cloud Native Java Microservices

© 2016 Pivotal Software, Inc. All rights reserved.

Cloud Native Apps

11

Page 12: Cloud Native Java Microservices

Cloud Native & Microservices

• Microservices are only a small part of a larger picture

Cloud

Microservices

Page 13: Cloud Native Java Microservices

Twelve-factor Application Configuration

Page 14: Cloud Native Java Microservices

Twelve-factor Application Deployment

Page 15: Cloud Native Java Microservices

© 2016 Pivotal Software, Inc. All rights reserved.

Cloud Native Ops

15

Page 16: Cloud Native Java Microservices

Application Server Deployment - Monolith

• Load balancing requires provisioning of new VMs and app server installations

• Poor resource isolation; memory leaks can cause other applications to become unavailable

• Runtime environment is driven by the operator

Virtual Machine

App

Linux Kernel

App App

Hardware Infrastructure

Page 17: Cloud Native Java Microservices

Linux Container Deployment - Microservice

• Development team drives the application runtime of a container

• Containers are resource isolated, allowing efficient scheduling onto a grid of VMs

• Containers take seconds to start, VMs take minutes

• It’s not a rule that there is one microservice per container

Virtual Machine

Container

Linux Kernel

App App

App App

ContainerApp App

App App

ContainerApp App

App App

Hardware Infrastructure

Page 18: Cloud Native Java Microservices

Microservices - Container Deployment• Each microservice can be containerized with their application dependencies

• Containers get scheduled on virtual machines with an allotted resource policy

Page 19: Cloud Native Java Microservices

Auto-scaling

• Minutes to start a VM, but seconds to start a container

• An elastic runtime handles auto-scaling of VMs with cloud providers

Page 20: Cloud Native Java Microservices

Orchestration• Each microservice needs to communicate outside containers

• Service discovery provides an automatic method for finding other service dependencies

Page 21: Cloud Native Java Microservices

© 2016 Pivotal Software, Inc. All rights reserved.

Cloud Native Java

21

Page 22: Cloud Native Java Microservices

© 2016 Pivotal Software, Inc. All rights reserved.

Spring BootA JVM micro-framework for building microservices

22

Page 23: Cloud Native Java Microservices

What is Spring Boot?

Page 24: Cloud Native Java Microservices

spring boot

Spring Initializr for boostraping your applications

supports rapid development of production-ready applications and services

Page 25: Cloud Native Java Microservices

Spring Boot Roles

Page 26: Cloud Native Java Microservices

Automatic Configuration• An application class is annotated with @SpringBootApplication

• Additional annotations are added to indicate the role of the Spring Boot application

Page 27: Cloud Native Java Microservices

Spring Boot for Microservices

Page 28: Cloud Native Java Microservices

© 2016 Pivotal Software, Inc. All rights reserved.

Spring CloudA toolset designed for building distributed systems

28

Page 29: Cloud Native Java Microservices

spring cloud

Apache Zookeeper

these logos are all trademark/copyright their respective owners (T-B, L-R): Netflix, amazon.com, Apache Software Foundation, Cloud Foundry, Hashicorp they are ALL great organizations and we love their open-source and their APIs!!

*

Page 30: Cloud Native Java Microservices

What is Spring Cloud?✴ Service Discovery

✴ API Gateway

✴ Config Server

✴ Circuit Breakers

✴ Distributed Tracing

Page 31: Cloud Native Java Microservices

What is Spring Cloud?• Spring Cloud provides a way to turn Spring Boot microservices into distributed

applications

Page 32: Cloud Native Java Microservices

Service Discovery & Intelligent Routing

Page 33: Cloud Native Java Microservices

Client-side load balancing

Page 34: Cloud Native Java Microservices

Configuration Service

Page 35: Cloud Native Java Microservices

API Gateway

Page 36: Cloud Native Java Microservices

© 2016 Pivotal Software, Inc. All rights reserved.

RESTful Microservices

36

Page 37: Cloud Native Java Microservices

© 2016 Pivotal Software, Inc. All rights reserved.

HATEOASHypermedia as the Engine of Application State (REST APIs that self-describe)

37

Page 38: Cloud Native Java Microservices

It’s pronounced hawt-ee-oh-as

Page 39: Cloud Native Java Microservices

Richardson Maturity Model

Photo credit: Packt Publishing

Page 40: Cloud Native Java Microservices

REST API Gateway

• API gateway downloads routes from services exposing REST APIs

• Each route of other microservices will be hosted on the API gateway

• API gateway will automatically reverse proxy to backend services

• Hypermedia allows traversing entire REST API description of microservices

Page 41: Cloud Native Java Microservices

Browsing REST APIs

Page 42: Cloud Native Java Microservices

©2015 Apigee. All Rights Reserved.

Each API call provides links

Page 43: Cloud Native Java Microservices

© 2016 Pivotal Software, Inc. All rights reserved.

Cloud Foundry“To always be shipping, you need a shipyard.”

43

Page 44: Cloud Native Java Microservices

© 2016 Pivotal Software, Inc. All rights reserved.

Application-centric opinionated platform

Cloud Foundry

44

Page 45: Cloud Native Java Microservices

Push to Cloud Foundry• http://run.pivotal.io •Go to Spring Initializr, select Web •Name the artifactId hello-world • Add a @RestController named Hello •Return “Hello World” at the root endpoint •mvn clean install & cf push

Page 46: Cloud Native Java Microservices

© 2016 Pivotal Software, Inc. All rights reserved.

Thanks! @kennybastani

46