Living on the Edge
with Spring Cloud Gateway
By Ryan Baxter
@ryanjbaxter
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Gateway Basics
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
What Is An API Gateway?
Server Side
MVC App
Microservice A
JS or Mobile
App
Microservice B
Microservice C
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
What Is An API Gateway?
Server Side
MVC App
Microservice A
JS or Mobile
App
Microservice B
Microservice C
Gateway
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Gateway Responsibilities
● Routing
● Security
● Monitoring
● Canarying
● Monolith Strangling
● Resiliency
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Spring Cloud Gateway Basics
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Spring Cloud Gateway Foundations
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Reactive Gateway
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Gateway Flow
Client Predicates Pre-Filters Global Filters
Post-Filters
Downstream
Service
Gateway
Handler Mapping Web Handler
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Gateway
Gateway Flow
Client Predicates Pre-Filters Global Filters
Post-Filters
Downstream
Service
Handler Mapping Web Handler
Predicates
● Path
● Host
● Date/Time
● Method
● Headers
● Query Params
● Cookies
● Read Body
● Anything….
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Gateway
Gateway Flow
Client Predicates Pre-Filters Global Filters
Post-Filters
Downstream
Service
Handler Mapping Web Handler
Pre-Filters
● Headers
● Path
● Rate Limiting
● Cookies
● Hystrix
● Modify Body
● Anything
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Gateway
Gateway Flow
Client Predicates Pre-Filters Global Filters
Post-Filters
Downstream
Service
Handler Mapping Web Handler
Global Filters
● Netty Router
● Web Sockets
● Load Balancer
● Metrics
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Gateway
Gateway Flow
Client Predicates Pre-Filters Global Filters
Post-Filters
Downstream
Service
Handler Mapping Web Handler
Post Filters
● Set status
● Headers
● Cookies
● Anything...
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Design Decisions
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
App
Embedded
Gate
way
Sample Use Case
● When latency is essential - no added network hops
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Embedded
App
Sample Use Case
● Fine-grained access control for pay-per-use
service or fragile backing service
App
Gate
way App
Gate
way App
Gate
way
App
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Facade
Gateway AppClient
Sample Use Cases
● Prevent direct access to apps
● Polyglot compatible
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Facade
Gateway App BClient
Sample Use Cases
● Cross-cutting concerns
● Present common API to clients
● Shield clients from app refactoring
(monolith → microservices)
App C
App A
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Cross-Cutting + App-Specific
App-Specific
Gateway
App B
Client
Sample Use Cases
● Delegate cross-cutting concerns to a separate
common gateway (and a separate dev team!)
App C
App A
App-Specific
Gateway
App E
App F
App D
Common
Gateway
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Demo
Photo Credit: Aerosmith, Living On The Edge
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Demo Architecture
Gateway
Blue
Service
Green
Service
Frontend
App
Client
Service
Discovery
(Eureka)
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Demo Architecture
Gateway
Blue
Service
Green
Service
Frontend
App
Client
Service
Discovery
(Eureka)
Yellow
Service
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Demo Part II:
Gateway On Cloud Foundry
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
User Stories - Subscription SLA Management
● As a consumer, I want features in accordance with my subscription.
● As a developer, I want to focus on my app.
● As a product owner, I want to ensure a consistent and unified consumer experience.
● As an operator, I want the the solution to be resilient and scalable.
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
configs:
- name: trial
replenishRate: 2
burstCapacity: 2
- name: basic
replenishRate: 10
burstCapacity: 15
- name: premium
replenishRate: 50
burstCapacity: 100
Consumers… need subscriptions
Trial
Basic
Premium
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Developers want…
Aut t a n
Aut za
Rat i n
Req En i h t
Req For d
…as a service
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Product Owners want… consistency
Open Service
Broker API
Instances
Bindings
Catalog
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Operators want… resilience and scalability
3
0

Rate Limiters
(Redis)
Service
Instance Info
(MongoDB)
Service Broker + Gateway
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
To the demo...
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Thank You
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Feedback Please!
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Q&A
Spring Cloud Gateway: https://github.com/spring-cloud/spring-cloud-gateway
Session Code: https://github.com/MrBW/chaos-monkey-spring-boot-demo
Slides: https://speakerdeck.com/ryanjbaxter
> Stay Connected.
#springone@s1p
Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Cross-Cutting + App-Specific
App-Specific
Gateway
App B
Client
App C
App A
App-Specific
Gateway
App E
App F
App DCommon
Gateway
Service Broker
(OSBAPI)
Cloud
Foundry
Service
Instance Info
Rate
Limiters
Sessions

Spring Cloud Gateway - Ryan Baxter

  • 1.
    Living on theEdge with Spring Cloud Gateway By Ryan Baxter @ryanjbaxter
  • 2.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
  • 3.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
  • 4.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Gateway Basics
  • 5.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ What Is An API Gateway? Server Side MVC App Microservice A JS or Mobile App Microservice B Microservice C
  • 6.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ What Is An API Gateway? Server Side MVC App Microservice A JS or Mobile App Microservice B Microservice C Gateway
  • 7.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Gateway Responsibilities ● Routing ● Security ● Monitoring ● Canarying ● Monolith Strangling ● Resiliency
  • 8.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Cloud Gateway Basics
  • 9.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Cloud Gateway Foundations
  • 10.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Reactive Gateway
  • 11.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Gateway Flow Client Predicates Pre-Filters Global Filters Post-Filters Downstream Service Gateway Handler Mapping Web Handler
  • 12.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Gateway Gateway Flow Client Predicates Pre-Filters Global Filters Post-Filters Downstream Service Handler Mapping Web Handler Predicates ● Path ● Host ● Date/Time ● Method ● Headers ● Query Params ● Cookies ● Read Body ● Anything….
  • 13.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Gateway Gateway Flow Client Predicates Pre-Filters Global Filters Post-Filters Downstream Service Handler Mapping Web Handler Pre-Filters ● Headers ● Path ● Rate Limiting ● Cookies ● Hystrix ● Modify Body ● Anything
  • 14.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Gateway Gateway Flow Client Predicates Pre-Filters Global Filters Post-Filters Downstream Service Handler Mapping Web Handler Global Filters ● Netty Router ● Web Sockets ● Load Balancer ● Metrics
  • 15.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Gateway Gateway Flow Client Predicates Pre-Filters Global Filters Post-Filters Downstream Service Handler Mapping Web Handler Post Filters ● Set status ● Headers ● Cookies ● Anything...
  • 16.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Design Decisions
  • 17.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ App Embedded Gate way Sample Use Case ● When latency is essential - no added network hops
  • 18.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Embedded App Sample Use Case ● Fine-grained access control for pay-per-use service or fragile backing service App Gate way App Gate way App Gate way App
  • 19.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Facade Gateway AppClient Sample Use Cases ● Prevent direct access to apps ● Polyglot compatible
  • 20.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Facade Gateway App BClient Sample Use Cases ● Cross-cutting concerns ● Present common API to clients ● Shield clients from app refactoring (monolith → microservices) App C App A
  • 21.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Cross-Cutting + App-Specific App-Specific Gateway App B Client Sample Use Cases ● Delegate cross-cutting concerns to a separate common gateway (and a separate dev team!) App C App A App-Specific Gateway App E App F App D Common Gateway
  • 22.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo Photo Credit: Aerosmith, Living On The Edge
  • 23.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo Architecture Gateway Blue Service Green Service Frontend App Client Service Discovery (Eureka)
  • 24.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo Architecture Gateway Blue Service Green Service Frontend App Client Service Discovery (Eureka) Yellow Service
  • 25.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo Part II: Gateway On Cloud Foundry
  • 26.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ User Stories - Subscription SLA Management ● As a consumer, I want features in accordance with my subscription. ● As a developer, I want to focus on my app. ● As a product owner, I want to ensure a consistent and unified consumer experience. ● As an operator, I want the the solution to be resilient and scalable.
  • 27.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ configs: - name: trial replenishRate: 2 burstCapacity: 2 - name: basic replenishRate: 10 burstCapacity: 15 - name: premium replenishRate: 50 burstCapacity: 100 Consumers… need subscriptions Trial Basic Premium
  • 28.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Developers want… Aut t a n Aut za Rat i n Req En i h t Req For d …as a service
  • 29.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Product Owners want… consistency Open Service Broker API Instances Bindings Catalog
  • 30.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Operators want… resilience and scalability 3 0  Rate Limiters (Redis) Service Instance Info (MongoDB) Service Broker + Gateway
  • 31.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ To the demo...
  • 32.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Thank You
  • 33.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Feedback Please!
  • 34.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Q&A Spring Cloud Gateway: https://github.com/spring-cloud/spring-cloud-gateway Session Code: https://github.com/MrBW/chaos-monkey-spring-boot-demo Slides: https://speakerdeck.com/ryanjbaxter
  • 35.
  • 36.
    Unless otherwise indicated,these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Cross-Cutting + App-Specific App-Specific Gateway App B Client App C App A App-Specific Gateway App E App F App DCommon Gateway Service Broker (OSBAPI) Cloud Foundry Service Instance Info Rate Limiters Sessions