© Copyright 2015 Pivotal. All rights reserved.© Copyright 2015 Pivotal. All rights reserved.
To Microservices and Beyond!
SV Microservices/Cloud Native Meetup
May 13, 2015
1
Matt Stine (@mstine)
Principal Engineer and Senior Product Manager
© Copyright 2015 Pivotal. All rights reserved. 2
IT SEEMS THERE’S SOME HYPE…
M!CR0S3RV!C3$!!!!!
© Copyright 2015 Pivotal. All rights reserved. 3
https://twitter.com/mstine/status/557763539101032448
© Copyright 2015 Pivotal. All rights reserved.
DEFINE: Microservice
4
Loosely coupled service oriented
architecture with bounded contexts
Adrian Cockcroft
Technology Fellow, Battery Ventures
Former Netflix Chief Cloud Architect
© Copyright 2015 Pivotal. All rights reserved.
DEFINE: Microservice
5
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.
© Copyright 2015 Pivotal. All rights reserved.
Not Monoliths
6
Relational Database
Data Access
Service
HTML JavaScript MVC
Service
Monolithic ApplicationBrowser
© Copyright 2015 Pivotal. All rights reserved. 7
Not Traditional (ESB-centric) SOA
Enterprise Service Bus
Service Service Service Service
Service Service Service Service
UI UI
© Copyright 2015 Pivotal. All rights reserved. 8
But Microservices!
From: http://www.slideshare.net/adriancockcroft/goto-berlin
© Copyright 2015 Pivotal. All rights reserved. 9
But why?
© Copyright 2015 Pivotal. All rights reserved. 10
Issues We’ll Confront
• Microservices are not an inherently superior architecture.
• We’re still building big systems from smaller things.
• Just like Docker won’t save the world, neither will
microservices. They’re not free.
• You absolutely cannot forget about data.
• Let’s begin!
© Copyright 2015 Pivotal. All rights reserved. 11
Not an end in themselves…
It’s about Continuous Delivery!
© Copyright 2015 Pivotal. All rights reserved.
What is Continuous Delivery?
12
$
Business
DevelopmentQA
Operations
Customer
© Copyright 2015 Pivotal. All rights reserved.
What is Continuous Delivery?
13
$
© Copyright 2015 Pivotal. All rights reserved. 14
Keep the Wheel Spinning!
Design
Develop
Test
Customer
Feedback
Customer
Delivery
Analytics
© Copyright 2015 Pivotal. All rights reserved. 15
Prod
Release
#1
Prod
Release
#2
Prod
Release
#3
AgileDevelopm
ent
Waterfall
Organization!
© Copyright 2015 Pivotal. All rights reserved.
Silo Delivery
16
Project
Mgmt
UX Dev QA DBA
Sys
Admin
Net
Admin
Storage
Admin
Adapted from: http://www.slideshare.net/adriancockcroft/goto-berlin
MONOLITHIC DELIVERY
© Copyright 2015 Pivotal. All rights reserved.
Continuous Delivery
17
Product
Mgr
UX Dev QA DBA
Sys
Admin
Net
Admin
Storage
Admin
BUSINESS CAPABILITY TEAMS
USING MICROSERVICES
PLATFORM OPERATIONS
TEAM
Adapted from: http://www.slideshare.net/adriancockcroft/goto-berlin
© Copyright 2015 Pivotal. All rights reserved.
Continuous Delivery
18
Product
Mgr
UX Dev QA DBA
Sys
Admin
Net
Admin
Storage
Admin
BUSINESS CAPABILITY TEAMS
USING MICROSERVICES
PLATFORM OPERATIONS
TEAM
Adapted from: http://www.slideshare.net/adriancockcroft/goto-berlin
Self
Service
API
© Copyright 2015 Pivotal. All rights reserved. 19
INVENTORY
Prod Release
Prod Release
Prod Release
CATALOG
Prod Release
Prod Release
Prod Release
REVIEWS
Prod Release
Prod Release
Prod Release
SHIPPING
Prod Release
Prod Release
Prod Release
© Copyright 2015 Pivotal. All rights reserved. 20
Microservices Enabling Continuous Delivery
• Decoupling Capabilities -> Decoupling Change Cycles
• Product Ownership: Tip to Tail
• We Build and Operate What We Understand BEST
• We Collaborate via API Contracts
• Microservice to Microservice
• Microservice to Platform
https://github.com/realestate-com-au/pact
© Copyright 2015 Pivotal. All rights reserved. 21
Systems over Services
Composition over Components
© Copyright 2015 Pivotal. All rights reserved.
Microframeworks for Microservices
22
Spring Boot
http://projects.spring.io/spring-boot
Dropwizard
http://dropwizard.io
http://12factor.net
© Copyright 2015 Pivotal. All rights reserved.
It can get pretty small…
23
@RestController
class ThisWillActuallyRun {
@RequestMapping("/")
String home() {
"Hello World!"
}
}
© Copyright 2015 Pivotal. All rights reserved.
With Spring Data REST!
24
http://projects.spring.io/spring-data-rest
@Entity
@Table(name = "city")
public class City implements Serializable {
!
@Id
@GeneratedValue
private Long id;
!
@Column(nullable = false)
private String name;
!
@Column(nullable = false)
private String county;
!
//...
!
}
© Copyright 2015 Pivotal. All rights reserved.
With Spring Data REST!
25
http://projects.spring.io/spring-data-rest
@RepositoryRestResource(collectionResourceRel = "cities", path = "cities")
public interface CityRepository extends PagingAndSortingRepository<City, Long> {}
@SpringBootApplication
@EnableJpaRepositories
@Import(RepositoryRestMvcConfiguration.class)
public class Application {
!
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
© Copyright 2015 Pivotal. All rights reserved.
With Spring Data REST!
26
http://projects.spring.io/spring-data-rest
{
"_links" : {
"next" : {
"href" : "http://localhost:8080/cities?page=1&size=20"
},
"self" : {
"href" : "http://localhost:8080/cities{?page,size,sort}",
"templated" : true
}
},
"_embedded" : {
"cities" : [ {
"name" : "HOLTSVILLE",
"county" : "SUFFOLK",
"stateCode" : "NY",
"postalCode" : "00501",
"latitude" : "+40.922326",
"longitude" : "-072.637078",
© Copyright 2015 Pivotal. All rights reserved.
But No Microservice is an Island…
27
© Copyright 2015 Pivotal. All rights reserved.
Example Distributed System: Minified
28
© Copyright 2015 Pivotal. All rights reserved. 29
Some emergent challenges of microservices
systems…
• Distributed/Versioned Configuration
• Service Registration/Discovery
• Routing/Load Balancing
• Fault Tolerance (Circuit Breakers!)
© Copyright 2015 Pivotal. All rights reserved.
Example: Coordination Boiler Plate
30
© Copyright 2015 Pivotal. All rights reserved. 31
• Eureka
• Hystrix + Turbine
• Ribbon
• Feign
• Zuul
http://netflix.github.io
© Copyright 2015 Pivotal. All rights reserved. 32
http://projects.spring.io/spring-cloud
@SpringCloudOSS
© Copyright 2015 Pivotal. All rights reserved.
Example: Spring Cloud + Netflix OSS
33
© Copyright 2015 Pivotal. All rights reserved. 34
Config Server
© Copyright 2015 Pivotal. All rights reserved. 35
Config Server + Cloud Bus
© Copyright 2015 Pivotal. All rights reserved.
Running a Config Server
36
@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
!
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
!
}
© Copyright 2015 Pivotal. All rights reserved. 37
Service Registration/Discovery
© Copyright 2015 Pivotal. All rights reserved.
Running a Eureka Server
38
@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {
!
public static void main(String[] args) {
SpringApplication.run(EurekaApplication.class, args);
}
!
}
© Copyright 2015 Pivotal. All rights reserved.
Service Registration/Discovery
39
@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);
}
!
}
© Copyright 2015 Pivotal. All rights reserved.
Service Registration/Discovery
40
© Copyright 2015 Pivotal. All rights reserved.
Fault Tolerance - Circuit Breakers
41
© Copyright 2015 Pivotal. All rights reserved.
Fault Tolerance - Circuit Breakers
42
@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);
}
!
}
© Copyright 2015 Pivotal. All rights reserved.
Enabling a Circuit Breaker
43
@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;
}
Client-Side Load Balancing
© Copyright 2015 Pivotal. All rights reserved. 44
{
"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"
}
}
}
© Copyright 2015 Pivotal. All rights reserved. 45
© Copyright 2015 Pivotal. All rights reserved.
Circuit Breaker Fallback
46
public Link defaultLink(Map<String, Object> parameters) {
return null;
}
@HystrixCommand(fallbackMethod = "defaultLink")
public Link getStoresByLocationLink(Map<String, Object> parameters) {
//...
}
© Copyright 2015 Pivotal. All rights reserved. 47
{
"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 is gone!!!
© Copyright 2015 Pivotal. All rights reserved. 48
© Copyright 2015 Pivotal. All rights reserved. 49
Operationalized
Architecture
You have to pay for your lunch!
© Copyright 2015 Pivotal. All rights reserved.© Copyright 2015 Pivotal. All rights reserved. 50
http://highscalability.com/blog/2014/4/8/microservices-not-a-free-lunch.html
© Copyright 2015 Pivotal. All rights reserved. 51
Paying for your lunch…
• Significant Operations Overhead
• Substantial DevOps Skills Required
• Implicit Interfaces
• Duplication of Effort
• Distributed System Complexity
• Asynchronicity is Difficult!
• Testability Challenges
© Copyright 2015 Pivotal. All rights reserved.
You must be this tall
to use
Microservices…
52
http://martinfowler.com/bliki/MicroservicePrerequisites.html
https://www.flickr.com/photos/gusset/3723961589
• RAPID PROVISIONING
• BASIC MONITORING
• RAPID APPLICATION DEPLOYMENT
• DEVOPS CULTURE
© Copyright 2015 Pivotal. All rights reserved.
It takes a platform…
53
http://techblog.netflix.com/2013/01/optimizing-netflix-api.html
http://techblog.netflix.com/2014/03/the-netflix-dynamic-scripting-platform.html
© Copyright 2015 Pivotal. All rights reserved.
It takes a platform…
54
Cloud Foundry Spring Cloud
© Copyright 2015 Pivotal. All rights reserved. 55
Platform Features
• Environment Provisioning
• On-Demand/Automatic Scaling
• Failover/Resilience
• Routing/Load Balancing
• Data Service Operations
• Monitoring
© Copyright 2015 Pivotal. All rights reserved.
Environment Provisioning/App Deployment
56
Router
Cloud Controller
Service Broker
Node(s)
DEA
DEA
DEA
DEA
Blobstore DB
Runtime
1. Upload bits/metadata
2. Create/bind services
3. Stage via Buildpack
4. Deploy via Container
push app
+ app MD
SC
+ =
http://docs.cloudfoundry.org/devguide/deploy-apps/
© Copyright 2015 Pivotal. All rights reserved.
Environment Provisioning/App Deployment
57
Router
Cloud Controller
DEA
Blobstore DB
Runtime
Detect Compile Upload
No
System
Buildpacks
+ =
Yes
http://docs.cloudfoundry.org/buildpacks/
© Copyright 2015 Pivotal. All rights reserved.
Deployment/Load Balancing/Scaling
58
Blobstore
Router
Cloud Controller
DEA
Messaging (NATS)
DEA DEA
Runtime
Access
App
http://docs.cloudfoundry.org/concepts/architecture/warden.html
Container Container
© Copyright 2015 Pivotal. All rights reserved.
Failover/Resilience
59
Blobstore
Router
Cloud Controller
DEA
Messaging (NATS)
DEA DEA
Runtime
Health Manager
Actual StateDesired State
http://docs.cloudfoundry.org/concepts/architecture/#hm9k
Container Container Container
© Copyright 2015 Pivotal. All rights reserved. 60
Diego
https://github.com/cloudfoundry-incubator/diego-design-notes
© Copyright 2015 Pivotal. All rights reserved. 61
http://lattice.cf/
© Copyright 2015 Pivotal. All rights reserved.
Data Service Operations: Cluster Provisioning
62
Blobstore
BOSH
Health Monitor
DB
Deploy my
Services
IaaS
Worker VMsBOSH Director
NATS
Cassandra Node
Target VM
Cassandra Node
Target VM
Cassandra Node
Target VM
http://bosh.cloudfoundry.org/
© Copyright 2015 Pivotal. All rights reserved.
DB
Router
Data Service Operations: Application Binding
63
Service
credentials
reserve resources
obtain connection data
CLI Cloud
Controller
Service
Broker
Data
Service
Runtime
create service (HTTP)
bind service (HTTP)
create service (HTTP)
bind service (HTTP)
http://docs.cloudfoundry.org/services/api.html
© Copyright 2015 Pivotal. All rights reserved.
Monitoring
64
© Copyright 2015 Pivotal. All rights reserved. 65
It’s All About the Data
What about the BIG QUESTIONS?
© Copyright 2015 Pivotal. All rights reserved.
This won’t work…
66
© Copyright 2015 Pivotal. All rights reserved. 67
Instead!
© Copyright 2015 Pivotal. All rights reserved.
Bounded Contexts
68
Movie Movie
Actor
Genre
Media
Type
Media
Type
Kiosk
Location
Media
Product
Catalog
Inventory
© Copyright 2015 Pivotal. All rights reserved.
Polyglot Persistence
69
REST XYou shall not pass…
© Copyright 2015 Pivotal. All rights reserved.
But I have a question!
70
REST XYou shall not pass…
?
?
? ?
?
?
© Copyright 2015 Pivotal. All rights reserved.
Lambda Architecture
71
© Copyright 2015 Pivotal. All rights reserved.
Join via Events!
72
© Copyright 2015 Pivotal. All rights reserved. 73
http://projects.spring.io/spring-xd/
© Copyright 2015 Pivotal. All rights reserved. 74
© Copyright 2015 Pivotal. All rights reserved.
Redbox Conceptual Workflow
75
© Copyright 2015 Pivotal. All rights reserved.
SpringBox Microservices
76
Catalog Service
Inventory Service
Kiosk
Kiosk
Kiosk
Reservation
Service
https://github.com/cf-platform-eng/springbox-datacloud
© Copyright 2015 Pivotal. All rights reserved.
…and if you have a question:
77
Kiosk
Kiosk
Kiosk
Speed Layer
Batch Layer
Serving Layer
Event
Ingest
https://github.com/cf-platform-eng/springbox-datacloud
“What movie genres are most popular in what geographic locations?”
© Copyright 2015 Pivotal. All rights reserved.
“What movie genres are most popular in
what geographic locations?”
78
// Aggregate preferences across all kiosks:
stream create --name kiosk_agg_prefs --definition "rabbit --
queues=lambda.kiosk.events | field-value-counter --fieldName=genreIds"
!
// Tap aggregate preferences, filter for kiosk #1:
stream create --name kiosk_1_prefs --definition "tap:stream:kiosk_agg_prefs > filter
--expression=#jsonPath(payload,'$.locationId').equals(1) | field-value-counter --
fieldName=genreIds"
© Copyright 2015 Pivotal. All rights reserved.
“What movie genres are most popular in
what geographic locations?”
79
field-value-counter display --name kiosk_agg_prefs
field-value-counter display=kiosk_agg_prefs
------------------------------------------- - -----
VALUE - COUNT
Action | 14
Adventure | 6
Comedy | 27
Sci-Fi | 18
© Copyright 2015 Pivotal. All rights reserved. 80
Where We’ve Been…
• Microservices are an enabler to Continuous Delivery.
• Less about services, more about composed distributed
systems. Patterns can help.
• You’re going to need a platform.
• Decomposed data governance -> recomposed data
discovery.
• Thank You!
© Copyright 2015 Pivotal. All rights reserved. 81
I wrote a little cloud book…
Available to you
compliments of Pivotal!
!
!
Get the FREE e-book
at http://bit.ly/cloud-native-book!
A NEW PLATFORM FOR A NEW ERA

To Microservices and Beyond

  • 1.
    © Copyright 2015Pivotal. All rights reserved.© Copyright 2015 Pivotal. All rights reserved. To Microservices and Beyond! SV Microservices/Cloud Native Meetup May 13, 2015 1 Matt Stine (@mstine) Principal Engineer and Senior Product Manager
  • 2.
    © Copyright 2015Pivotal. All rights reserved. 2 IT SEEMS THERE’S SOME HYPE… M!CR0S3RV!C3$!!!!!
  • 3.
    © Copyright 2015Pivotal. All rights reserved. 3 https://twitter.com/mstine/status/557763539101032448
  • 4.
    © Copyright 2015Pivotal. All rights reserved. DEFINE: Microservice 4 Loosely coupled service oriented architecture with bounded contexts Adrian Cockcroft Technology Fellow, Battery Ventures Former Netflix Chief Cloud Architect
  • 5.
    © Copyright 2015Pivotal. All rights reserved. DEFINE: Microservice 5 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.
  • 6.
    © Copyright 2015Pivotal. All rights reserved. Not Monoliths 6 Relational Database Data Access Service HTML JavaScript MVC Service Monolithic ApplicationBrowser
  • 7.
    © Copyright 2015Pivotal. All rights reserved. 7 Not Traditional (ESB-centric) SOA Enterprise Service Bus Service Service Service Service Service Service Service Service UI UI
  • 8.
    © Copyright 2015Pivotal. All rights reserved. 8 But Microservices! From: http://www.slideshare.net/adriancockcroft/goto-berlin
  • 9.
    © Copyright 2015Pivotal. All rights reserved. 9 But why?
  • 10.
    © Copyright 2015Pivotal. All rights reserved. 10 Issues We’ll Confront • Microservices are not an inherently superior architecture. • We’re still building big systems from smaller things. • Just like Docker won’t save the world, neither will microservices. They’re not free. • You absolutely cannot forget about data. • Let’s begin!
  • 11.
    © Copyright 2015Pivotal. All rights reserved. 11 Not an end in themselves… It’s about Continuous Delivery!
  • 12.
    © Copyright 2015Pivotal. All rights reserved. What is Continuous Delivery? 12 $ Business DevelopmentQA Operations Customer
  • 13.
    © Copyright 2015Pivotal. All rights reserved. What is Continuous Delivery? 13 $
  • 14.
    © Copyright 2015Pivotal. All rights reserved. 14 Keep the Wheel Spinning! Design Develop Test Customer Feedback Customer Delivery Analytics
  • 15.
    © Copyright 2015Pivotal. All rights reserved. 15 Prod Release #1 Prod Release #2 Prod Release #3 AgileDevelopm ent Waterfall Organization!
  • 16.
    © Copyright 2015Pivotal. All rights reserved. Silo Delivery 16 Project Mgmt UX Dev QA DBA Sys Admin Net Admin Storage Admin Adapted from: http://www.slideshare.net/adriancockcroft/goto-berlin MONOLITHIC DELIVERY
  • 17.
    © Copyright 2015Pivotal. All rights reserved. Continuous Delivery 17 Product Mgr UX Dev QA DBA Sys Admin Net Admin Storage Admin BUSINESS CAPABILITY TEAMS USING MICROSERVICES PLATFORM OPERATIONS TEAM Adapted from: http://www.slideshare.net/adriancockcroft/goto-berlin
  • 18.
    © Copyright 2015Pivotal. All rights reserved. Continuous Delivery 18 Product Mgr UX Dev QA DBA Sys Admin Net Admin Storage Admin BUSINESS CAPABILITY TEAMS USING MICROSERVICES PLATFORM OPERATIONS TEAM Adapted from: http://www.slideshare.net/adriancockcroft/goto-berlin Self Service API
  • 19.
    © Copyright 2015Pivotal. All rights reserved. 19 INVENTORY Prod Release Prod Release Prod Release CATALOG Prod Release Prod Release Prod Release REVIEWS Prod Release Prod Release Prod Release SHIPPING Prod Release Prod Release Prod Release
  • 20.
    © Copyright 2015Pivotal. All rights reserved. 20 Microservices Enabling Continuous Delivery • Decoupling Capabilities -> Decoupling Change Cycles • Product Ownership: Tip to Tail • We Build and Operate What We Understand BEST • We Collaborate via API Contracts • Microservice to Microservice • Microservice to Platform https://github.com/realestate-com-au/pact
  • 21.
    © Copyright 2015Pivotal. All rights reserved. 21 Systems over Services Composition over Components
  • 22.
    © Copyright 2015Pivotal. All rights reserved. Microframeworks for Microservices 22 Spring Boot http://projects.spring.io/spring-boot Dropwizard http://dropwizard.io http://12factor.net
  • 23.
    © Copyright 2015Pivotal. All rights reserved. It can get pretty small… 23 @RestController class ThisWillActuallyRun { @RequestMapping("/") String home() { "Hello World!" } }
  • 24.
    © Copyright 2015Pivotal. All rights reserved. With Spring Data REST! 24 http://projects.spring.io/spring-data-rest @Entity @Table(name = "city") public class City implements Serializable { ! @Id @GeneratedValue private Long id; ! @Column(nullable = false) private String name; ! @Column(nullable = false) private String county; ! //... ! }
  • 25.
    © Copyright 2015Pivotal. All rights reserved. With Spring Data REST! 25 http://projects.spring.io/spring-data-rest @RepositoryRestResource(collectionResourceRel = "cities", path = "cities") public interface CityRepository extends PagingAndSortingRepository<City, Long> {} @SpringBootApplication @EnableJpaRepositories @Import(RepositoryRestMvcConfiguration.class) public class Application { ! public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
  • 26.
    © Copyright 2015Pivotal. All rights reserved. With Spring Data REST! 26 http://projects.spring.io/spring-data-rest { "_links" : { "next" : { "href" : "http://localhost:8080/cities?page=1&size=20" }, "self" : { "href" : "http://localhost:8080/cities{?page,size,sort}", "templated" : true } }, "_embedded" : { "cities" : [ { "name" : "HOLTSVILLE", "county" : "SUFFOLK", "stateCode" : "NY", "postalCode" : "00501", "latitude" : "+40.922326", "longitude" : "-072.637078",
  • 27.
    © Copyright 2015Pivotal. All rights reserved. But No Microservice is an Island… 27
  • 28.
    © Copyright 2015Pivotal. All rights reserved. Example Distributed System: Minified 28
  • 29.
    © Copyright 2015Pivotal. All rights reserved. 29 Some emergent challenges of microservices systems… • Distributed/Versioned Configuration • Service Registration/Discovery • Routing/Load Balancing • Fault Tolerance (Circuit Breakers!)
  • 30.
    © Copyright 2015Pivotal. All rights reserved. Example: Coordination Boiler Plate 30
  • 31.
    © Copyright 2015Pivotal. All rights reserved. 31 • Eureka • Hystrix + Turbine • Ribbon • Feign • Zuul http://netflix.github.io
  • 32.
    © Copyright 2015Pivotal. All rights reserved. 32 http://projects.spring.io/spring-cloud @SpringCloudOSS
  • 33.
    © Copyright 2015Pivotal. All rights reserved. Example: Spring Cloud + Netflix OSS 33
  • 34.
    © Copyright 2015Pivotal. All rights reserved. 34 Config Server
  • 35.
    © Copyright 2015Pivotal. All rights reserved. 35 Config Server + Cloud Bus
  • 36.
    © Copyright 2015Pivotal. All rights reserved. Running a Config Server 36 @SpringBootApplication @EnableConfigServer public class ConfigServerApplication { ! public static void main(String[] args) { SpringApplication.run(ConfigServerApplication.class, args); } ! }
  • 37.
    © Copyright 2015Pivotal. All rights reserved. 37 Service Registration/Discovery
  • 38.
    © Copyright 2015Pivotal. All rights reserved. Running a Eureka Server 38 @SpringBootApplication @EnableEurekaServer public class EurekaApplication { ! public static void main(String[] args) { SpringApplication.run(EurekaApplication.class, args); } ! }
  • 39.
    © Copyright 2015Pivotal. All rights reserved. Service Registration/Discovery 39 @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); } ! }
  • 40.
    © Copyright 2015Pivotal. All rights reserved. Service Registration/Discovery 40
  • 41.
    © Copyright 2015Pivotal. All rights reserved. Fault Tolerance - Circuit Breakers 41
  • 42.
    © Copyright 2015Pivotal. All rights reserved. Fault Tolerance - Circuit Breakers 42 @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); } ! }
  • 43.
    © Copyright 2015Pivotal. All rights reserved. Enabling a Circuit Breaker 43 @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; } Client-Side Load Balancing
  • 44.
    © Copyright 2015Pivotal. All rights reserved. 44 { "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" } } }
  • 45.
    © Copyright 2015Pivotal. All rights reserved. 45
  • 46.
    © Copyright 2015Pivotal. All rights reserved. Circuit Breaker Fallback 46 public Link defaultLink(Map<String, Object> parameters) { return null; } @HystrixCommand(fallbackMethod = "defaultLink") public Link getStoresByLocationLink(Map<String, Object> parameters) { //... }
  • 47.
    © Copyright 2015Pivotal. All rights reserved. 47 { "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 is gone!!!
  • 48.
    © Copyright 2015Pivotal. All rights reserved. 48
  • 49.
    © Copyright 2015Pivotal. All rights reserved. 49 Operationalized Architecture You have to pay for your lunch!
  • 50.
    © Copyright 2015Pivotal. All rights reserved.© Copyright 2015 Pivotal. All rights reserved. 50 http://highscalability.com/blog/2014/4/8/microservices-not-a-free-lunch.html
  • 51.
    © Copyright 2015Pivotal. All rights reserved. 51 Paying for your lunch… • Significant Operations Overhead • Substantial DevOps Skills Required • Implicit Interfaces • Duplication of Effort • Distributed System Complexity • Asynchronicity is Difficult! • Testability Challenges
  • 52.
    © Copyright 2015Pivotal. All rights reserved. You must be this tall to use Microservices… 52 http://martinfowler.com/bliki/MicroservicePrerequisites.html https://www.flickr.com/photos/gusset/3723961589 • RAPID PROVISIONING • BASIC MONITORING • RAPID APPLICATION DEPLOYMENT • DEVOPS CULTURE
  • 53.
    © Copyright 2015Pivotal. All rights reserved. It takes a platform… 53 http://techblog.netflix.com/2013/01/optimizing-netflix-api.html http://techblog.netflix.com/2014/03/the-netflix-dynamic-scripting-platform.html
  • 54.
    © Copyright 2015Pivotal. All rights reserved. It takes a platform… 54 Cloud Foundry Spring Cloud
  • 55.
    © Copyright 2015Pivotal. All rights reserved. 55 Platform Features • Environment Provisioning • On-Demand/Automatic Scaling • Failover/Resilience • Routing/Load Balancing • Data Service Operations • Monitoring
  • 56.
    © Copyright 2015Pivotal. All rights reserved. Environment Provisioning/App Deployment 56 Router Cloud Controller Service Broker Node(s) DEA DEA DEA DEA Blobstore DB Runtime 1. Upload bits/metadata 2. Create/bind services 3. Stage via Buildpack 4. Deploy via Container push app + app MD SC + = http://docs.cloudfoundry.org/devguide/deploy-apps/
  • 57.
    © Copyright 2015Pivotal. All rights reserved. Environment Provisioning/App Deployment 57 Router Cloud Controller DEA Blobstore DB Runtime Detect Compile Upload No System Buildpacks + = Yes http://docs.cloudfoundry.org/buildpacks/
  • 58.
    © Copyright 2015Pivotal. All rights reserved. Deployment/Load Balancing/Scaling 58 Blobstore Router Cloud Controller DEA Messaging (NATS) DEA DEA Runtime Access App http://docs.cloudfoundry.org/concepts/architecture/warden.html Container Container
  • 59.
    © Copyright 2015Pivotal. All rights reserved. Failover/Resilience 59 Blobstore Router Cloud Controller DEA Messaging (NATS) DEA DEA Runtime Health Manager Actual StateDesired State http://docs.cloudfoundry.org/concepts/architecture/#hm9k Container Container Container
  • 60.
    © Copyright 2015Pivotal. All rights reserved. 60 Diego https://github.com/cloudfoundry-incubator/diego-design-notes
  • 61.
    © Copyright 2015Pivotal. All rights reserved. 61 http://lattice.cf/
  • 62.
    © Copyright 2015Pivotal. All rights reserved. Data Service Operations: Cluster Provisioning 62 Blobstore BOSH Health Monitor DB Deploy my Services IaaS Worker VMsBOSH Director NATS Cassandra Node Target VM Cassandra Node Target VM Cassandra Node Target VM http://bosh.cloudfoundry.org/
  • 63.
    © Copyright 2015Pivotal. All rights reserved. DB Router Data Service Operations: Application Binding 63 Service credentials reserve resources obtain connection data CLI Cloud Controller Service Broker Data Service Runtime create service (HTTP) bind service (HTTP) create service (HTTP) bind service (HTTP) http://docs.cloudfoundry.org/services/api.html
  • 64.
    © Copyright 2015Pivotal. All rights reserved. Monitoring 64
  • 65.
    © Copyright 2015Pivotal. All rights reserved. 65 It’s All About the Data What about the BIG QUESTIONS?
  • 66.
    © Copyright 2015Pivotal. All rights reserved. This won’t work… 66
  • 67.
    © Copyright 2015Pivotal. All rights reserved. 67 Instead!
  • 68.
    © Copyright 2015Pivotal. All rights reserved. Bounded Contexts 68 Movie Movie Actor Genre Media Type Media Type Kiosk Location Media Product Catalog Inventory
  • 69.
    © Copyright 2015Pivotal. All rights reserved. Polyglot Persistence 69 REST XYou shall not pass…
  • 70.
    © Copyright 2015Pivotal. All rights reserved. But I have a question! 70 REST XYou shall not pass… ? ? ? ? ? ?
  • 71.
    © Copyright 2015Pivotal. All rights reserved. Lambda Architecture 71
  • 72.
    © Copyright 2015Pivotal. All rights reserved. Join via Events! 72
  • 73.
    © Copyright 2015Pivotal. All rights reserved. 73 http://projects.spring.io/spring-xd/
  • 74.
    © Copyright 2015Pivotal. All rights reserved. 74
  • 75.
    © Copyright 2015Pivotal. All rights reserved. Redbox Conceptual Workflow 75
  • 76.
    © Copyright 2015Pivotal. All rights reserved. SpringBox Microservices 76 Catalog Service Inventory Service Kiosk Kiosk Kiosk Reservation Service https://github.com/cf-platform-eng/springbox-datacloud
  • 77.
    © Copyright 2015Pivotal. All rights reserved. …and if you have a question: 77 Kiosk Kiosk Kiosk Speed Layer Batch Layer Serving Layer Event Ingest https://github.com/cf-platform-eng/springbox-datacloud “What movie genres are most popular in what geographic locations?”
  • 78.
    © Copyright 2015Pivotal. All rights reserved. “What movie genres are most popular in what geographic locations?” 78 // Aggregate preferences across all kiosks: stream create --name kiosk_agg_prefs --definition "rabbit -- queues=lambda.kiosk.events | field-value-counter --fieldName=genreIds" ! // Tap aggregate preferences, filter for kiosk #1: stream create --name kiosk_1_prefs --definition "tap:stream:kiosk_agg_prefs > filter --expression=#jsonPath(payload,'$.locationId').equals(1) | field-value-counter -- fieldName=genreIds"
  • 79.
    © Copyright 2015Pivotal. All rights reserved. “What movie genres are most popular in what geographic locations?” 79 field-value-counter display --name kiosk_agg_prefs field-value-counter display=kiosk_agg_prefs ------------------------------------------- - ----- VALUE - COUNT Action | 14 Adventure | 6 Comedy | 27 Sci-Fi | 18
  • 80.
    © Copyright 2015Pivotal. All rights reserved. 80 Where We’ve Been… • Microservices are an enabler to Continuous Delivery. • Less about services, more about composed distributed systems. Patterns can help. • You’re going to need a platform. • Decomposed data governance -> recomposed data discovery. • Thank You!
  • 81.
    © Copyright 2015Pivotal. All rights reserved. 81 I wrote a little cloud book… Available to you compliments of Pivotal! ! ! Get the FREE e-book at http://bit.ly/cloud-native-book!
  • 82.
    A NEW PLATFORMFOR A NEW ERA