pivotal microservices spring_pcf_skillsmatter.pptx

45
1 © 2015 Pivotal Software, Inc. All rights reserved. 1 © 2015 Pivotal Software, Inc. All rights reserved. Microservices: Why and How? Netflix OSS/Spring Cloud & Pivotal Cloud Foundry Matt Stine (@mstine) Principal Engineer & Senior Product Manager August 2015

Upload: sufyaan-kazi

Post on 15-Apr-2017

293 views

Category:

Technology


0 download

TRANSCRIPT

1 © 2015 Pivotal Software, Inc. All rights reserved. 1 © 2015 Pivotal Software, Inc. All rights reserved.

Microservices: Why and How? Netflix OSS/Spring Cloud & Pivotal Cloud Foundry

Matt Stine (@mstine) Principal Engineer & Senior Product Manager August 2015

2 © 2015 Pivotal Software, Inc. All rights reserved.

DEFINE: Microservice

Loosely coupled service oriented architecture with bounded contexts

If every service has to be updated in concert, it’s not loosely coupled!

If you have to know about surrounding services you don’t have a bounded context.

3 © 2015 Pivotal Software, Inc. All rights reserved.

Not Monoliths

Relational Database

Data Access

Service

HTML JavaScript MVC

Service

Monolithic Application Browser

4 © 2015 Pivotal Software, Inc. All rights reserved.

Not Traditional (ESB-centric) SOA

Enterprise Service Bus

Service Service Service Service

Service Service Service Service

UI UI

5 © 2015 Pivotal Software, Inc. All rights reserved.

But Microservices!

6 © 2015 Pivotal Software, Inc. All rights reserved.

7 © 2015 Pivotal Software, Inc. All rights reserved.

8 © 2015 Pivotal Software, Inc. All rights reserved.

But no Microservice is an Island…

9 © 2015 Pivotal Software, Inc. All rights reserved.

Example Distributed System: Minified

10 © 2015 Pivotal Software, Inc. All rights reserved.

Some emergent challenges of microservices systems… � Configuration Management

� Service Registration & Discovery

� Routing & Load Balancing

� Fault Tolerance (Circuit Breakers!)

� Monitoring

11 © 2015 Pivotal Software, Inc. All rights reserved.

Example: Coordination Boiler Plate

12 © 2015 Pivotal Software, Inc. All rights reserved.

•  Eureka •  Hystrix + Turbine

•  Ribbon

•  Feign

•  Zuul

http://netflix.github.io

13 © 2015 Pivotal Software, Inc. All rights reserved.

http://projects.spring.io/spring-cloud

14 © 2015 Pivotal Software, Inc. All rights reserved.

Example: Spring Cloud + Netflix OSS

15 © 2015 Pivotal Software, Inc. All rights reserved.

Config Server

16 © 2015 Pivotal Software, Inc. All rights reserved.

Config Server + Cloud Bus

17 © 2015 Pivotal Software, Inc. All rights reserved.

Service Registration/Discovery

18 © 2015 Pivotal Software, Inc. All rights reserved.

Service Registration/Discovery @SpringBootApplication @EnableCircuitBreaker @EnableDiscoveryClient public class CustomerApp extends RepositoryRestMvcConfiguration {

@Override protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration

config) { config.exposeIdsFor(Customer.class); }

public static void main(String[] args) { SpringApplication.run(CustomerApp.class, args); }

}

19 © 2015 Pivotal Software, Inc. All rights reserved.

Fault Tolerance – Circuit Breakers

20 © 2015 Pivotal Software, Inc. All rights reserved.

Fault Tolerance – Circuit Breakers @SpringBootApplication @EnableCircuitBreaker @EnableDiscoveryClient public class CustomerApp extends RepositoryRestMvcConfiguration {

@Override protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration

config) { config.exposeIdsFor(Customer.class); }

public static void main(String[] args) { SpringApplication.run(CustomerApp.class, args); }

}

21 © 2015 Pivotal Software, Inc. All rights reserved.

@HystrixCommand(fallbackMethod = "defaultLink") public Link getStoresByLocationLink(Map<String, Object> parameters) { URI storesUri = URI.create(uri); try {

ServiceInstance instance = loadBalancer.choose("stores"); storesUri = URI.create(String.format("http://%s:%s",

instance.getHost(), instance.getPort())); } catch (RuntimeException e) { // Eureka not available }

Traverson traverson = new Traverson(storesUri, MediaTypes.HAL_JSON); Link link = traverson.follow("stores", "search", "by-location") .withTemplateParameters(parameters).asLink();

return link; }

Enabling a Circuit Breaker

Client-Side Load Balancing

22 © 2015 Pivotal Software, Inc. All rights reserved.

{ "id" : 3, "firstname" : "Matt", "lastname" : "Stine", "address" : { "street" : "9195 East Mineral Circle", "zipCode" : "80112", "city" : "Centennial", "location" : { "latitude" : 39.5738106, "longitude" : -104.8816934 } }, "_links" : { "self" : { "href" : "http://pivotalcustomers.cfapps.io/customers/3" }, "stores-nearby" : { "href" : "http://pivotalstores.cfapps.io/stores/search/findByAddressLocationNear?location=39.5738106,-104.8816934&distance=50" } } }

23 © 2015 Pivotal Software, Inc. All rights reserved.

24 © 2015 Pivotal Software, Inc. All rights reserved.

Circuit Breaker Fallback

public Link defaultLink(Map<String, Object> parameters) { return null;

}

@HystrixCommand(fallbackMethod = "defaultLink") public Link getStoresByLocationLink(Map<String, Object> parameters) {

//... }

25 © 2015 Pivotal Software, Inc. All rights reserved.

{ "id" : 3, "firstname" : "Matt", "lastname" : "Stine", "address" : { "street" : "9195 East Mineral Circle", "zipCode" : "80112", "city" : "Centennial", "location" : { "latitude" : 39.5738106, "longitude" : -104.8816934 } }, "_links" : { "self" : { "href" : "http://pivotalcustomers.cfapps.io/customers/3" } } }

26 © 2015 Pivotal Software, Inc. All rights reserved.

27 © 2015 Pivotal Software, Inc. All rights reserved. 27 © Copyright 2015 Pivotal. All rights reserved.

http://highscalability.com/blog/2014/4/8/microservices-not-a-free-lunch.html

28 © 2015 Pivotal Software, Inc. All rights reserved.

Paying for your lunch… �  Significant Operations Overhead

�  Substantial DevOps Skills Required

�  Implicit Interfaces

�  Duplication of Effort

�  Distributed System Complexity

�  Asynchronicity is Difficult!

�  Testability Challenges

29 © 2015 Pivotal Software, Inc. All rights reserved.

You must be this tall to use Microservices…

https://www.flickr.com/photos/gusset/3723961589

•  RAPID PROVISIONING •  BASIC MONITORING •  RAPID APPLICATION DEPLOYMENT •  DEVOPS CULTURE

http://martinfowler.com/bliki/MicroservicePrerequisites.html

30 © 2015 Pivotal Software, Inc. All rights reserved.

It takes a platform…

Cloud Foundry Spring Cloud Services

31 © 2015 Pivotal Software, Inc. All rights reserved.

Cloud Foundry Features �  Environment Provisioning

�  On-Demand/Automatic Scaling

�  Failover/Resilience

�  Routing/Load Balancing

�  Data Service Operations

�  Monitoring

32 © 2015 Pivotal Software, Inc. All rights reserved.

Spring Cloud Services Suite

Spring Cloud Services

Config Server Service Registry Circuit Breaker Dashboard

33 © 2015 Pivotal Software, Inc. All rights reserved.

Datastore

Mes

sage

Bu

s

Circuit Breaker

Load Balancer

Mes

sage

Bu

s

REST Workload (Customer)

Circuit Breaker

Load Balancer

REST Workload (Stores)

Datastore

Mes

sage

Bu

s

UI (Angular)

Circuit Breaker

Load Balancer

Production R

eady

Proxy

Service Discovery

Config Server

Messaging

Circuit Breaker Dashboard

Circuit Breaker Metric

Aggregation

BindProduction R

eady

Production R

eady

PCF Applications

PCF Services

Spring Cloud Services Suite – Logical View

34 © 2015 Pivotal Software, Inc. All rights reserved.

Spring Cloud Services Suite

•  Installed via Pivotal Ops Manager •  Adds all services to Pivotal Cloud Foundry

Marketplace

•  Dependencies: •  MySQL for PCF •  RabbitMQ for PCF

Spring Cloud Services

35 © 2015 Pivotal Software, Inc. All rights reserved.

App Manager Marketplace

36 © 2015 Pivotal Software, Inc. All rights reserved.

Spring Cloud Config Server

Config Server

•  Spring Cloud Config Server •  Service Binding via Spring Cloud

Connector •  Git/SVN URL for Config Repo provided

via Service Dashboard (post-provisioning)

•  Single tenant, scoped to CF space (nothing prevents shared Git repo)

37 © 2015 Pivotal Software, Inc. All rights reserved.

Spring Cloud Config Server Dashboard

38 © 2015 Pivotal Software, Inc. All rights reserved.

Spring Cloud Service Registry

Service Registry

•  Service Registration and Discovery via Netflix OSS Eureka

•  Service Binding via Spring Cloud Connector

•  Single-tenant, scoped to CF space

•  Registration via CF Route or DEA/Cell IP:Port (must enable cross-container traffic)

39 © 2015 Pivotal Software, Inc. All rights reserved.

Spring Cloud Service Registry Dashboard

40 © 2015 Pivotal Software, Inc. All rights reserved.

Spring Cloud Services Suite

Circuit Breaker Dashboard

•  Netflix OSS Turbine + Hystrix Dashboard •  Aggregation via AMQP (RabbitMQ) •  Binding via Spring Cloud Connector •  Single-tenant, scoped to CF space

41 © 2015 Pivotal Software, Inc. All rights reserved.

Spring Cloud Services Roadmap � Opinionated RBAC via OAuth2 / Integration with PCF UAA

� Spring Cloud Bus Refresh/Restart (as a Service)

� Spring Cloud Config Server Encryption/Decryption

� Policy-based Inter-org/space Service Discovery

� Distributed Tracing

� Spring Cloud Dataflow (Spring XD 2.0)

� API Gateway / Management (as a Service)

� Polyglot Language Support (via Sidecar)

�  .NET Support (Native Bindings)

42 © 2015 Pivotal Software, Inc. All rights reserved.

Policy-based Inter-org/space Service Discovery

43 © 2015 Pivotal Software, Inc. All rights reserved.

μServiceswith

Bindable Services

In-App Support Libraries

BETAMAY 2015

44 © 2015 Pivotal Software, Inc. All rights reserved.

Published March 16, 2015 Available to you compliments of Pivotal! http://bit.ly/cloud-native-book