SlideShare une entreprise Scribd logo
1  sur  67
From on-premises monolith to
cloud microservices using a
stateless API Gateway
Albert Lombarte
@alombarte
2019 KrakenD API Gateway2
MONOLITHInternet
2019 KrakenD API Gateway3
MONOLITH
Database
?
Catalog
Promotions
Basket
Payments
Orders
Pricing
Stock
Authentication
2019 KrakenD API Gateway4
Internal communication
Direct, synchronous
Queues
Polling
Pub/Sub
Service Mesh
2019 KrakenD API Gateway5
Catalog
Promotions
Basket
Payments
Orders
Pricing
Stock
Authentication
Android
iOS
SPA
?
External consumption
2019 KrakenD API Gateway6 Photo by @voyagefervor, Instagram
Service Mesh
API Gateways
Proxies with GW
GraphQL
API Managers
2019 KrakenD API Gateway7
Proxy with GW 1:1 mapping endpoint-backends - No business logic - Offload cross-cutting
concerns. No aggregation
Products with overlapping features
GraphQL HTTP only - Single Endpoint - Allows the client to choose exactly the data in
the response. E.g: you provide an API to developers out of your organization
API Gateway Services aggregation - Business logic - API Contract - No coupling to
backend - Offload cross-cutting concerns. Can implement the BFF pattern.
Service Mesh Internal communication between services (not for the end-user). No business
logic
API Managers Access management (generate API Keys), billing, developer portal, usage
statistics
Stateless vs
Stateful
2019 KrakenD API Gateway9
Stateful
2019 KrakenD API Gateway10
Stateless
2019 KrakenD API Gateway11
A gateway is not the new monolith
★ Coordination required
★ Data synchronization
★ Datastore as source of truth
★ Complexity
★ Multi-region lag
★ Mutable configuration
NON-LINEAR SCALABILITY
Stateless Stateful
★ No node coordination
★ No synchronization
★ Zero complexity
★ No challenges for Multi-region
★ Declarative configuration
★ Immutable infrastructure
LINEAR SCALABILITY
2019 KrakenD API Gateway12
API GW
APIGW:North-southtraffic
Mesh: east-west traffic
Choosing a stateless API gateway
2019 KrakenD API Gateway14
Proxy with API Gateway capabilities
Catalog
Promotions
Basket
Payments
Orders
Pricing
Stock
Authentication
Android
iOS
SPA PROXY
2019 KrakenD API Gateway15
KrakenD API gateway to transition to microservices
Catalog
Promotions
Basket
Payments
Orders
Pricing
Stock
Authentication
/frontpage
{
"catalog": {},
"promos": {},
"pricing": {}
}
2019 KrakenD API Gateway16
Offloading shared needs
Catalog
Promotions
Basket
Payments
Orders
Pricing
Stock
Authentication
Manipulation
Filtering
Circuit Breaker
Metrics/Tracing
Aggregation
Security
Authorization
Service Discovery
Encoding
Logging Rate Limit Monitoring
Load Balancer Pub/Sub Transport adapter
Stub Data Traffic Mirroring Queues
Migration by
example
Step by step
2019 KrakenD API Gateway18
Migration strategies
NEW
functionality
INCREMENTAL
Migration
(piece by piece, new and old)
ALL IN
Swap
2019 KrakenD API Gateway19
Incremental move to µservices
Database
Catalog
Promotions
Basket
Payments
Orders
Pricing
Stock
Authentication
2019 KrakenD API Gateway20
Migration
steps
TL;DR
2 Move authorization to the GW
1 Add the gateway
3 Break a piece of the monolith
4 Aggregate the microservice
5 Deployment and Observability
Add the gateway
Keep the API contract
2019 KrakenD API Gateway22
Add the gateway, as a proxy
Web + API
MONOLITH
/foo
/bar
/foo
/bar
Proxy
1
Keep the existing API contract
Forward cookies
2019 KrakenD API Gateway23
{
"version": 2,
"host": ["http://monolith"],
"endpoints": [{
"endpoint": "/login",
"output_encoding": "no-op",
"headers_to_pass": ["Cookie"],
"backend": [{
"url_pattern": "/login",
"encoding": "no-op"
}]
},
{...}
]
}
Configuration
Client -> Gateway -> Monolith
(proxy)
krakend.json
❯ krakend run -c krakend.json
Start the server:
2019 KrakenD API Gateway24
2019 KrakenD API Gateway25
Unified interface
Service 1
v1.1 XML
Service 2
v3.2 JSON
Service 3
v2.9 RSS
你好
Hello
Привет
KrakenD
/v1/hello-world
➔ Automatic API generation
and integration
➔ Consumers (iOS, Android,
Web, Server devs) in control
of the API
➔ Homogeneous consumption
of data formats and
encodings
➔ Reduced bandwidth and
errors
➔ Increased speed
➔ Better quality of service
2019 KrakenD API Gateway26
Gateway added
At this point...
- The gateway is in the cloud
- Plugged to the onprem
monolith (VPN?)
- It’s hybrid (cloud+onprem)
- We defined all endpoints
- Transparent for the client
- Session Cookies still allowed
API contract kept
1
2019 KrakenD API Gateway27
The weakest punishes the stronger
When weakly typed languages harm the strongly typed ones
{
"id_user": 2,
"alias": "bob"
}
Output from weakly typed lang
Strongly
typed
{
"id_user": "2",
"alias": "bob"
}
😱
HORROR
STORIES
😱
Move the authorization to the Gateway
From session cookies to JWT
2019 KrakenD API Gateway29
Add JWT-based authentication 2
MONOLITH
/foo /foo
2019 KrakenD API Gateway30
Add JWT-based authentication 2
/token /login?token=1
POST
MONOLITH
/foo /foo
signer
{ "id_user": "89990",
"username": "jimmy" }
<token>
JWT
Authorization:
Bearer <token>
2019 KrakenD API Gateway31
Login controller in the monolith (BEFORE)
if ($user_data = $this->login($username, $password)) {
// Start the session (COOKIE)
startUserSession($user_data);
// Set the “remind me” cookie:
setRemindMeCookie($user_data['auto_login']);
...
}
2
2019 KrakenD API Gateway32
Login controller in the monolith (AFTER)
if ($user_data = $this->login($username, $password)) {
if ($request->has('token')) { // ?token=1
return json_encode([
"access_token" => [
"aud" => "https://api.company.com",
"iss" => "https://monoli.th",
"sub" => $user_data->id_user,
"jti" => uniqid('', true),
"roles" => [$user_data->role],
"exp" => time() + 1800, // 30 minutes
"other_data" => $user_data->other
]
]);
} else {
startUserSession($user_data);
setRemindMeCookie($user_data['auto_login']); //... }
}
2
2019 KrakenD API Gateway33
"endpoint": "/basket",
"extra_config": {
"github.com/devopsfaith/krakend-jose/validator": {
"alg": "HS256",
"audience": ["http://api.example.com"],
"roles_key": "roles",
"roles": ["user", "admin"],
"jwk-url": "https://monolith/jwk/symmetric.json"
}
},
"output_encoding": "no-op",
"headers_to_pass": ["Authentication"],
"backend": [{
"url_pattern": "/bar",
"encoding": "no-op"
}]
Authorization
granularity
krakend.json
2019 KrakenD API Gateway34
<?php
$jwt =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiw
ibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT
4fwpMeJf36POk6yJV_adQssw5c';
$token_parts = explode('.', $jwt);
$user_data = json_decode(base64_decode($token_parts[1]));
Retrieve “session” data from token 2
object(stdClass)#1 (3) {
["sub"]=>
string(10) "1234567890"
["name"]=>
string(8) "John Doe"
["iat"]=>
int(1516239022)
}
2019 KrakenD API Gateway35
At this point...
- All desired endpoints are
protected by the gateway
(sign + validation)
- “Authentication” header is
the only needed header,
but not cookies.
- The monolith gets session
data from token
JWT tokens
implemented
No more sessions
2
Start chopping the monolith
2019 KrakenD API Gateway37
Where to cut the monolith?
Social Tech
2019 KrakenD API Gateway38Chop your way Photo by Jason Abdilla
2019 KrakenD API Gateway39
Avoid dependencies over the network
N times
Cascading requests
HORROR
STORIES
😱
2019 KrakenD API Gateway40
Size!
4GBDocker image
HORROR
STORIES
😱
2019 KrakenD API Gateway41
Pick a first service to extract
Catalog
Promotions
Basket
Payments
Orders
Pricing
Stock
/login
Authentication
MONOLITH
3
2019 KrakenD API Gateway42
Idempotent and safe services?
Gateway
It’s a read operation but….
Service
GET
DB
Read data
UPDATE
HORROR
STORIES
😱
Aggregating and merging services
2019 KrakenD API Gateway44
Aggregation
<id_product>2</id_product>
<name>Devops Barcelona</name>
<date fmt="Y-m-d">2019-06-04</date>
{
"code": "DEVOPS19",
"discount": 0.15,
"products": [1,2,15]
}
+
{
"id_product": 2,
"name": "Devops Barcelona",
"date": "2019-06-04",
"code": "DEVOPS19",
"discount": 0.15,
"products": [1,2,15]
}
Aggregated
}
Catalog
Promotions
2019 KrakenD API Gateway45
Authentication
/checkout
JWT token
Catalog
Promotions
Basket
Payments
Orders
Pricing
Stock
MONOLITH
4
2019 KrakenD API Gateway46
Catalog
Promotions
Basket
Payments
Orders
Pricing
Stock
MONOLITH
4
/splash
2019 KrakenD API Gateway47
Aggregating the hard way
Backends
/splash
x68
Screen Calls
First App Launch 68
Onboarding Tour 178
Wake-up after background 208
Front Page (w/ scroll) 39
Select Category 21
Apply a Filter 30
Product detail 22
Go to basket 51
My account 92
Help 42
To Checkout 57
TOTAL DURING THE SESSION
808
HORROR
STORIES
😱
2019 KrakenD API Gateway48
Manipulation/Filtering/Grouping
<id_product>2</id_product>
<name>Devops Barcelona</name>
<date fmt="Y-m-d">2019-06-04</date>
Catalog
{
"code": "DEVOPS19",
"discount": 0.15,
"products": [1,2,15]
}
Promotions
+
{
"catalog": {
"id_product": 2,
"name": "Devops Barcelona",
"date": "2019-06-04",
},
"promotions": {
"code": "DEVOPS19",
"savediscount": 0.15,
"products": [1,2,15],
}
}
Aggregated
}
2019 KrakenD API Gateway49
Avoid the “take it all” pattern
Client
Providing a lot of data to the client, just in case it’s needed
Gateway
Your 10MB, thank you
HORROR
STORIES
😱
2019 KrakenD API Gateway50
Directly connect to message brokers
Catalog
/notify
Notifications
QUEUE
Azure Service
Bus Topic
4
Deployment
2019 KrakenD API Gateway52
Simple deployment (stateless)
FROM devopsfaith/krakend
COPY krakend.json 
/etc/krakend/krakend.json
+ ≃
40MB
Dockerfile
2019 KrakenD API Gateway53
Deploy anywhere
Orchestration
Platforms
2019 KrakenD API Gateway54
Assign a KrakenD to each team (client type)
Catalog
Promotions
Basket
Payments
Orders
Pricing
Stock
Authentication
Android
iOS
SPA
2019 KrakenD API Gateway55
Assign a KrakenD to each team (micro frontends)
}
}
}
2019 KrakenD API Gateway56
Not necessarily the single point of entry
Catalog
Promotions
Payments
Orders
Pricing
Stock
Authentication
Observability
Visualize the entire ecosystem from a central place
2019 KrakenD API Gateway58
Enable monitoring
2019 KrakenD API Gateway59
1-click export of logging, metrics and traces
2019 KrakenD API Gateway60
Metrics and Tracer exporters for every taste
2019 KrakenD API Gateway61
2019 KrakenD API Gateway62
Repeat x N services
3 Break a piece of the monolith
4 Aggregate the microservice
5 Deployment and Observability
2019 KrakenD API Gateway63
MONOLITH
Orders
Pricing
Stock
Basket
Payments
Promotions
Catalog MONOLITH
🎉
2019 KrakenD API Gateway64
2019 KrakenD API Gateway65
Special thanks to...
2019 KrakenD API Gateway66
2019 KrakenD API Gateway67
Questions?
Let’s have a beer!
@devopsfaith | @alombarte
Email: albert@krakend.io
Photo by Patrick Fore

Contenu connexe

Tendances

Microservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitectureMicroservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitecturePaul Mooney
 
Monitor Apache Spark 3 on Kubernetes using Metrics and Plugins
Monitor Apache Spark 3 on Kubernetes using Metrics and PluginsMonitor Apache Spark 3 on Kubernetes using Metrics and Plugins
Monitor Apache Spark 3 on Kubernetes using Metrics and PluginsDatabricks
 
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin Huai
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin HuaiA Deep Dive into Spark SQL's Catalyst Optimizer with Yin Huai
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin HuaiDatabricks
 
No data loss pipeline with apache kafka
No data loss pipeline with apache kafkaNo data loss pipeline with apache kafka
No data loss pipeline with apache kafkaJiangjie Qin
 
Large Scale Graph Analytics with JanusGraph
Large Scale Graph Analytics with JanusGraphLarge Scale Graph Analytics with JanusGraph
Large Scale Graph Analytics with JanusGraphDataWorks Summit
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architectureThe Software House
 
Redis and Kafka - Advanced Microservices Design Patterns Simplified
Redis and Kafka - Advanced Microservices Design Patterns SimplifiedRedis and Kafka - Advanced Microservices Design Patterns Simplified
Redis and Kafka - Advanced Microservices Design Patterns SimplifiedAllen Terleto
 
Monitoring Spark Applications
Monitoring Spark ApplicationsMonitoring Spark Applications
Monitoring Spark ApplicationsTzach Zohar
 
Overview of Zookeeper, Helix and Kafka (Oakjug)
Overview of Zookeeper, Helix and Kafka (Oakjug)Overview of Zookeeper, Helix and Kafka (Oakjug)
Overview of Zookeeper, Helix and Kafka (Oakjug)Chris Richardson
 
HBaseCon2017 Community-Driven Graphs with JanusGraph
HBaseCon2017 Community-Driven Graphs with JanusGraphHBaseCon2017 Community-Driven Graphs with JanusGraph
HBaseCon2017 Community-Driven Graphs with JanusGraphHBaseCon
 
Apache Spark overview
Apache Spark overviewApache Spark overview
Apache Spark overviewDataArt
 
Apache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals ExplainedApache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals Explainedconfluent
 
Disaster Recovery and High Availability with Kafka, SRM and MM2
Disaster Recovery and High Availability with Kafka, SRM and MM2Disaster Recovery and High Availability with Kafka, SRM and MM2
Disaster Recovery and High Availability with Kafka, SRM and MM2Abdelkrim Hadjidj
 
Processing Large Data with Apache Spark -- HasGeek
Processing Large Data with Apache Spark -- HasGeekProcessing Large Data with Apache Spark -- HasGeek
Processing Large Data with Apache Spark -- HasGeekVenkata Naga Ravi
 
Kafka replication apachecon_2013
Kafka replication apachecon_2013Kafka replication apachecon_2013
Kafka replication apachecon_2013Jun Rao
 
Introduction to Storm
Introduction to Storm Introduction to Storm
Introduction to Storm Chandler Huang
 
Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...
Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...
Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...VMware Tanzu
 
Understanding InfluxDB Basics: Tags, Fields and Measurements
Understanding InfluxDB Basics: Tags, Fields and MeasurementsUnderstanding InfluxDB Basics: Tags, Fields and Measurements
Understanding InfluxDB Basics: Tags, Fields and MeasurementsInfluxData
 
Understanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksUnderstanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksJignesh Shah
 

Tendances (20)

Microservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitectureMicroservice vs. Monolithic Architecture
Microservice vs. Monolithic Architecture
 
Monitor Apache Spark 3 on Kubernetes using Metrics and Plugins
Monitor Apache Spark 3 on Kubernetes using Metrics and PluginsMonitor Apache Spark 3 on Kubernetes using Metrics and Plugins
Monitor Apache Spark 3 on Kubernetes using Metrics and Plugins
 
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin Huai
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin HuaiA Deep Dive into Spark SQL's Catalyst Optimizer with Yin Huai
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin Huai
 
No data loss pipeline with apache kafka
No data loss pipeline with apache kafkaNo data loss pipeline with apache kafka
No data loss pipeline with apache kafka
 
Large Scale Graph Analytics with JanusGraph
Large Scale Graph Analytics with JanusGraphLarge Scale Graph Analytics with JanusGraph
Large Scale Graph Analytics with JanusGraph
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
 
Redis and Kafka - Advanced Microservices Design Patterns Simplified
Redis and Kafka - Advanced Microservices Design Patterns SimplifiedRedis and Kafka - Advanced Microservices Design Patterns Simplified
Redis and Kafka - Advanced Microservices Design Patterns Simplified
 
Monitoring Spark Applications
Monitoring Spark ApplicationsMonitoring Spark Applications
Monitoring Spark Applications
 
Overview of Zookeeper, Helix and Kafka (Oakjug)
Overview of Zookeeper, Helix and Kafka (Oakjug)Overview of Zookeeper, Helix and Kafka (Oakjug)
Overview of Zookeeper, Helix and Kafka (Oakjug)
 
HBaseCon2017 Community-Driven Graphs with JanusGraph
HBaseCon2017 Community-Driven Graphs with JanusGraphHBaseCon2017 Community-Driven Graphs with JanusGraph
HBaseCon2017 Community-Driven Graphs with JanusGraph
 
Apache Spark overview
Apache Spark overviewApache Spark overview
Apache Spark overview
 
Apache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals ExplainedApache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals Explained
 
Disaster Recovery and High Availability with Kafka, SRM and MM2
Disaster Recovery and High Availability with Kafka, SRM and MM2Disaster Recovery and High Availability with Kafka, SRM and MM2
Disaster Recovery and High Availability with Kafka, SRM and MM2
 
Processing Large Data with Apache Spark -- HasGeek
Processing Large Data with Apache Spark -- HasGeekProcessing Large Data with Apache Spark -- HasGeek
Processing Large Data with Apache Spark -- HasGeek
 
Kafka replication apachecon_2013
Kafka replication apachecon_2013Kafka replication apachecon_2013
Kafka replication apachecon_2013
 
Introduction to Storm
Introduction to Storm Introduction to Storm
Introduction to Storm
 
Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...
Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...
Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...
 
Understanding InfluxDB Basics: Tags, Fields and Measurements
Understanding InfluxDB Basics: Tags, Fields and MeasurementsUnderstanding InfluxDB Basics: Tags, Fields and Measurements
Understanding InfluxDB Basics: Tags, Fields and Measurements
 
Understanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksUnderstanding PostgreSQL LW Locks
Understanding PostgreSQL LW Locks
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
 

Similaire à From on premises monolith to cloud microservices

apidays LIVE Australia 2020 - From micro to macro-coordination through domain...
apidays LIVE Australia 2020 - From micro to macro-coordination through domain...apidays LIVE Australia 2020 - From micro to macro-coordination through domain...
apidays LIVE Australia 2020 - From micro to macro-coordination through domain...apidays
 
The Current And Future State Of Service Mesh
The Current And Future State Of Service MeshThe Current And Future State Of Service Mesh
The Current And Future State Of Service MeshRam Vennam
 
Contribution day guide. MLEU 2019
Contribution day guide. MLEU 2019Contribution day guide. MLEU 2019
Contribution day guide. MLEU 2019Oleksii Korshenko
 
NDC London 2017 - The Data Dichotomy- Rethinking Data and Services with Streams
NDC London 2017  - The Data Dichotomy- Rethinking Data and Services with StreamsNDC London 2017  - The Data Dichotomy- Rethinking Data and Services with Streams
NDC London 2017 - The Data Dichotomy- Rethinking Data and Services with StreamsBen Stopford
 
EDA Meets Data Engineering – What's the Big Deal?
EDA Meets Data Engineering – What's the Big Deal?EDA Meets Data Engineering – What's the Big Deal?
EDA Meets Data Engineering – What's the Big Deal?confluent
 
Resilient and Adaptable Systems with Cloud Native APIs
Resilient and Adaptable Systems with Cloud Native APIsResilient and Adaptable Systems with Cloud Native APIs
Resilient and Adaptable Systems with Cloud Native APIsVMware Tanzu
 
Breizhcamp - Application update in a Kubernetes World
Breizhcamp - Application update in a Kubernetes WorldBreizhcamp - Application update in a Kubernetes World
Breizhcamp - Application update in a Kubernetes WorldMathieu Herbert
 
[WSO2 Integration Summit Stuttgart 2019] Decentralizing APIs for Agile Busine...
[WSO2 Integration Summit Stuttgart 2019] Decentralizing APIs for Agile Busine...[WSO2 Integration Summit Stuttgart 2019] Decentralizing APIs for Agile Busine...
[WSO2 Integration Summit Stuttgart 2019] Decentralizing APIs for Agile Busine...WSO2
 
[WSO2 Integration Summit Madrid 2019] Identity and Access Management in an AP...
[WSO2 Integration Summit Madrid 2019] Identity and Access Management in an AP...[WSO2 Integration Summit Madrid 2019] Identity and Access Management in an AP...
[WSO2 Integration Summit Madrid 2019] Identity and Access Management in an AP...WSO2
 
New Approaches for Fraud Detection on Apache Kafka and KSQL
New Approaches for Fraud Detection on Apache Kafka and KSQLNew Approaches for Fraud Detection on Apache Kafka and KSQL
New Approaches for Fraud Detection on Apache Kafka and KSQLconfluent
 
Consuming GRIN GLOBAL Webservices
Consuming GRIN GLOBAL WebservicesConsuming GRIN GLOBAL Webservices
Consuming GRIN GLOBAL WebservicesEdwin Rojas
 
IoT Sensor Sensibility - Hull Digital - C4Di - Feb 2016
IoT Sensor Sensibility - Hull Digital - C4Di - Feb 2016IoT Sensor Sensibility - Hull Digital - C4Di - Feb 2016
IoT Sensor Sensibility - Hull Digital - C4Di - Feb 2016Glynn Bird
 
WSO2 - Yenlo Integration Summit Stuttgart 15 May 2019 - Decentralizing APIs f...
WSO2 - Yenlo Integration Summit Stuttgart 15 May 2019 - Decentralizing APIs f...WSO2 - Yenlo Integration Summit Stuttgart 15 May 2019 - Decentralizing APIs f...
WSO2 - Yenlo Integration Summit Stuttgart 15 May 2019 - Decentralizing APIs f...Yenlo
 
5 Things I Wish I'd Known about Microservices
5 Things I Wish I'd Known about Microservices5 Things I Wish I'd Known about Microservices
5 Things I Wish I'd Known about MicroservicesAtlassian
 
Automatic Ingress in Kubernetes
Automatic Ingress in KubernetesAutomatic Ingress in Kubernetes
Automatic Ingress in KubernetesRodrigo Reis
 
Web Authentication API
Web Authentication APIWeb Authentication API
Web Authentication APIFIDO Alliance
 
BIG IoT Marketplace & API
BIG IoT Marketplace & APIBIG IoT Marketplace & API
BIG IoT Marketplace & APIBIG IoT Project
 

Similaire à From on premises monolith to cloud microservices (20)

apidays LIVE Australia 2020 - From micro to macro-coordination through domain...
apidays LIVE Australia 2020 - From micro to macro-coordination through domain...apidays LIVE Australia 2020 - From micro to macro-coordination through domain...
apidays LIVE Australia 2020 - From micro to macro-coordination through domain...
 
The Current And Future State Of Service Mesh
The Current And Future State Of Service MeshThe Current And Future State Of Service Mesh
The Current And Future State Of Service Mesh
 
Contribution day guide. MLEU 2019
Contribution day guide. MLEU 2019Contribution day guide. MLEU 2019
Contribution day guide. MLEU 2019
 
NDC London 2017 - The Data Dichotomy- Rethinking Data and Services with Streams
NDC London 2017  - The Data Dichotomy- Rethinking Data and Services with StreamsNDC London 2017  - The Data Dichotomy- Rethinking Data and Services with Streams
NDC London 2017 - The Data Dichotomy- Rethinking Data and Services with Streams
 
EDA Meets Data Engineering – What's the Big Deal?
EDA Meets Data Engineering – What's the Big Deal?EDA Meets Data Engineering – What's the Big Deal?
EDA Meets Data Engineering – What's the Big Deal?
 
Resilient and Adaptable Systems with Cloud Native APIs
Resilient and Adaptable Systems with Cloud Native APIsResilient and Adaptable Systems with Cloud Native APIs
Resilient and Adaptable Systems with Cloud Native APIs
 
testupload
testuploadtestupload
testupload
 
Breizhcamp - Application update in a Kubernetes World
Breizhcamp - Application update in a Kubernetes WorldBreizhcamp - Application update in a Kubernetes World
Breizhcamp - Application update in a Kubernetes World
 
[WSO2 Integration Summit Stuttgart 2019] Decentralizing APIs for Agile Busine...
[WSO2 Integration Summit Stuttgart 2019] Decentralizing APIs for Agile Busine...[WSO2 Integration Summit Stuttgart 2019] Decentralizing APIs for Agile Busine...
[WSO2 Integration Summit Stuttgart 2019] Decentralizing APIs for Agile Busine...
 
[WSO2 Integration Summit Madrid 2019] Identity and Access Management in an AP...
[WSO2 Integration Summit Madrid 2019] Identity and Access Management in an AP...[WSO2 Integration Summit Madrid 2019] Identity and Access Management in an AP...
[WSO2 Integration Summit Madrid 2019] Identity and Access Management in an AP...
 
New Approaches for Fraud Detection on Apache Kafka and KSQL
New Approaches for Fraud Detection on Apache Kafka and KSQLNew Approaches for Fraud Detection on Apache Kafka and KSQL
New Approaches for Fraud Detection on Apache Kafka and KSQL
 
Consuming GRIN GLOBAL Webservices
Consuming GRIN GLOBAL WebservicesConsuming GRIN GLOBAL Webservices
Consuming GRIN GLOBAL Webservices
 
Psd2 challenges
Psd2 challenges Psd2 challenges
Psd2 challenges
 
IoT Sensor Sensibility - Hull Digital - C4Di - Feb 2016
IoT Sensor Sensibility - Hull Digital - C4Di - Feb 2016IoT Sensor Sensibility - Hull Digital - C4Di - Feb 2016
IoT Sensor Sensibility - Hull Digital - C4Di - Feb 2016
 
WSO2 - Yenlo Integration Summit Stuttgart 15 May 2019 - Decentralizing APIs f...
WSO2 - Yenlo Integration Summit Stuttgart 15 May 2019 - Decentralizing APIs f...WSO2 - Yenlo Integration Summit Stuttgart 15 May 2019 - Decentralizing APIs f...
WSO2 - Yenlo Integration Summit Stuttgart 15 May 2019 - Decentralizing APIs f...
 
5 Things I Wish I'd Known about Microservices
5 Things I Wish I'd Known about Microservices5 Things I Wish I'd Known about Microservices
5 Things I Wish I'd Known about Microservices
 
Using the GSMA OneAPI Gateway
Using the GSMA OneAPI GatewayUsing the GSMA OneAPI Gateway
Using the GSMA OneAPI Gateway
 
Automatic Ingress in Kubernetes
Automatic Ingress in KubernetesAutomatic Ingress in Kubernetes
Automatic Ingress in Kubernetes
 
Web Authentication API
Web Authentication APIWeb Authentication API
Web Authentication API
 
BIG IoT Marketplace & API
BIG IoT Marketplace & APIBIG IoT Marketplace & API
BIG IoT Marketplace & API
 

Dernier

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 

Dernier (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

From on premises monolith to cloud microservices

  • 1. From on-premises monolith to cloud microservices using a stateless API Gateway Albert Lombarte @alombarte
  • 2. 2019 KrakenD API Gateway2 MONOLITHInternet
  • 3. 2019 KrakenD API Gateway3 MONOLITH Database ? Catalog Promotions Basket Payments Orders Pricing Stock Authentication
  • 4. 2019 KrakenD API Gateway4 Internal communication Direct, synchronous Queues Polling Pub/Sub Service Mesh
  • 5. 2019 KrakenD API Gateway5 Catalog Promotions Basket Payments Orders Pricing Stock Authentication Android iOS SPA ? External consumption
  • 6. 2019 KrakenD API Gateway6 Photo by @voyagefervor, Instagram Service Mesh API Gateways Proxies with GW GraphQL API Managers
  • 7. 2019 KrakenD API Gateway7 Proxy with GW 1:1 mapping endpoint-backends - No business logic - Offload cross-cutting concerns. No aggregation Products with overlapping features GraphQL HTTP only - Single Endpoint - Allows the client to choose exactly the data in the response. E.g: you provide an API to developers out of your organization API Gateway Services aggregation - Business logic - API Contract - No coupling to backend - Offload cross-cutting concerns. Can implement the BFF pattern. Service Mesh Internal communication between services (not for the end-user). No business logic API Managers Access management (generate API Keys), billing, developer portal, usage statistics
  • 9. 2019 KrakenD API Gateway9 Stateful
  • 10. 2019 KrakenD API Gateway10 Stateless
  • 11. 2019 KrakenD API Gateway11 A gateway is not the new monolith ★ Coordination required ★ Data synchronization ★ Datastore as source of truth ★ Complexity ★ Multi-region lag ★ Mutable configuration NON-LINEAR SCALABILITY Stateless Stateful ★ No node coordination ★ No synchronization ★ Zero complexity ★ No challenges for Multi-region ★ Declarative configuration ★ Immutable infrastructure LINEAR SCALABILITY
  • 12. 2019 KrakenD API Gateway12 API GW APIGW:North-southtraffic Mesh: east-west traffic
  • 13. Choosing a stateless API gateway
  • 14. 2019 KrakenD API Gateway14 Proxy with API Gateway capabilities Catalog Promotions Basket Payments Orders Pricing Stock Authentication Android iOS SPA PROXY
  • 15. 2019 KrakenD API Gateway15 KrakenD API gateway to transition to microservices Catalog Promotions Basket Payments Orders Pricing Stock Authentication /frontpage { "catalog": {}, "promos": {}, "pricing": {} }
  • 16. 2019 KrakenD API Gateway16 Offloading shared needs Catalog Promotions Basket Payments Orders Pricing Stock Authentication Manipulation Filtering Circuit Breaker Metrics/Tracing Aggregation Security Authorization Service Discovery Encoding Logging Rate Limit Monitoring Load Balancer Pub/Sub Transport adapter Stub Data Traffic Mirroring Queues
  • 18. 2019 KrakenD API Gateway18 Migration strategies NEW functionality INCREMENTAL Migration (piece by piece, new and old) ALL IN Swap
  • 19. 2019 KrakenD API Gateway19 Incremental move to µservices Database Catalog Promotions Basket Payments Orders Pricing Stock Authentication
  • 20. 2019 KrakenD API Gateway20 Migration steps TL;DR 2 Move authorization to the GW 1 Add the gateway 3 Break a piece of the monolith 4 Aggregate the microservice 5 Deployment and Observability
  • 21. Add the gateway Keep the API contract
  • 22. 2019 KrakenD API Gateway22 Add the gateway, as a proxy Web + API MONOLITH /foo /bar /foo /bar Proxy 1 Keep the existing API contract Forward cookies
  • 23. 2019 KrakenD API Gateway23 { "version": 2, "host": ["http://monolith"], "endpoints": [{ "endpoint": "/login", "output_encoding": "no-op", "headers_to_pass": ["Cookie"], "backend": [{ "url_pattern": "/login", "encoding": "no-op" }] }, {...} ] } Configuration Client -> Gateway -> Monolith (proxy) krakend.json ❯ krakend run -c krakend.json Start the server:
  • 24. 2019 KrakenD API Gateway24
  • 25. 2019 KrakenD API Gateway25 Unified interface Service 1 v1.1 XML Service 2 v3.2 JSON Service 3 v2.9 RSS 你好 Hello Привет KrakenD /v1/hello-world ➔ Automatic API generation and integration ➔ Consumers (iOS, Android, Web, Server devs) in control of the API ➔ Homogeneous consumption of data formats and encodings ➔ Reduced bandwidth and errors ➔ Increased speed ➔ Better quality of service
  • 26. 2019 KrakenD API Gateway26 Gateway added At this point... - The gateway is in the cloud - Plugged to the onprem monolith (VPN?) - It’s hybrid (cloud+onprem) - We defined all endpoints - Transparent for the client - Session Cookies still allowed API contract kept 1
  • 27. 2019 KrakenD API Gateway27 The weakest punishes the stronger When weakly typed languages harm the strongly typed ones { "id_user": 2, "alias": "bob" } Output from weakly typed lang Strongly typed { "id_user": "2", "alias": "bob" } 😱 HORROR STORIES 😱
  • 28. Move the authorization to the Gateway From session cookies to JWT
  • 29. 2019 KrakenD API Gateway29 Add JWT-based authentication 2 MONOLITH /foo /foo
  • 30. 2019 KrakenD API Gateway30 Add JWT-based authentication 2 /token /login?token=1 POST MONOLITH /foo /foo signer { "id_user": "89990", "username": "jimmy" } <token> JWT Authorization: Bearer <token>
  • 31. 2019 KrakenD API Gateway31 Login controller in the monolith (BEFORE) if ($user_data = $this->login($username, $password)) { // Start the session (COOKIE) startUserSession($user_data); // Set the “remind me” cookie: setRemindMeCookie($user_data['auto_login']); ... } 2
  • 32. 2019 KrakenD API Gateway32 Login controller in the monolith (AFTER) if ($user_data = $this->login($username, $password)) { if ($request->has('token')) { // ?token=1 return json_encode([ "access_token" => [ "aud" => "https://api.company.com", "iss" => "https://monoli.th", "sub" => $user_data->id_user, "jti" => uniqid('', true), "roles" => [$user_data->role], "exp" => time() + 1800, // 30 minutes "other_data" => $user_data->other ] ]); } else { startUserSession($user_data); setRemindMeCookie($user_data['auto_login']); //... } } 2
  • 33. 2019 KrakenD API Gateway33 "endpoint": "/basket", "extra_config": { "github.com/devopsfaith/krakend-jose/validator": { "alg": "HS256", "audience": ["http://api.example.com"], "roles_key": "roles", "roles": ["user", "admin"], "jwk-url": "https://monolith/jwk/symmetric.json" } }, "output_encoding": "no-op", "headers_to_pass": ["Authentication"], "backend": [{ "url_pattern": "/bar", "encoding": "no-op" }] Authorization granularity krakend.json
  • 34. 2019 KrakenD API Gateway34 <?php $jwt = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiw ibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT 4fwpMeJf36POk6yJV_adQssw5c'; $token_parts = explode('.', $jwt); $user_data = json_decode(base64_decode($token_parts[1])); Retrieve “session” data from token 2 object(stdClass)#1 (3) { ["sub"]=> string(10) "1234567890" ["name"]=> string(8) "John Doe" ["iat"]=> int(1516239022) }
  • 35. 2019 KrakenD API Gateway35 At this point... - All desired endpoints are protected by the gateway (sign + validation) - “Authentication” header is the only needed header, but not cookies. - The monolith gets session data from token JWT tokens implemented No more sessions 2
  • 36. Start chopping the monolith
  • 37. 2019 KrakenD API Gateway37 Where to cut the monolith? Social Tech
  • 38. 2019 KrakenD API Gateway38Chop your way Photo by Jason Abdilla
  • 39. 2019 KrakenD API Gateway39 Avoid dependencies over the network N times Cascading requests HORROR STORIES 😱
  • 40. 2019 KrakenD API Gateway40 Size! 4GBDocker image HORROR STORIES 😱
  • 41. 2019 KrakenD API Gateway41 Pick a first service to extract Catalog Promotions Basket Payments Orders Pricing Stock /login Authentication MONOLITH 3
  • 42. 2019 KrakenD API Gateway42 Idempotent and safe services? Gateway It’s a read operation but…. Service GET DB Read data UPDATE HORROR STORIES 😱
  • 44. 2019 KrakenD API Gateway44 Aggregation <id_product>2</id_product> <name>Devops Barcelona</name> <date fmt="Y-m-d">2019-06-04</date> { "code": "DEVOPS19", "discount": 0.15, "products": [1,2,15] } + { "id_product": 2, "name": "Devops Barcelona", "date": "2019-06-04", "code": "DEVOPS19", "discount": 0.15, "products": [1,2,15] } Aggregated } Catalog Promotions
  • 45. 2019 KrakenD API Gateway45 Authentication /checkout JWT token Catalog Promotions Basket Payments Orders Pricing Stock MONOLITH 4
  • 46. 2019 KrakenD API Gateway46 Catalog Promotions Basket Payments Orders Pricing Stock MONOLITH 4 /splash
  • 47. 2019 KrakenD API Gateway47 Aggregating the hard way Backends /splash x68 Screen Calls First App Launch 68 Onboarding Tour 178 Wake-up after background 208 Front Page (w/ scroll) 39 Select Category 21 Apply a Filter 30 Product detail 22 Go to basket 51 My account 92 Help 42 To Checkout 57 TOTAL DURING THE SESSION 808 HORROR STORIES 😱
  • 48. 2019 KrakenD API Gateway48 Manipulation/Filtering/Grouping <id_product>2</id_product> <name>Devops Barcelona</name> <date fmt="Y-m-d">2019-06-04</date> Catalog { "code": "DEVOPS19", "discount": 0.15, "products": [1,2,15] } Promotions + { "catalog": { "id_product": 2, "name": "Devops Barcelona", "date": "2019-06-04", }, "promotions": { "code": "DEVOPS19", "savediscount": 0.15, "products": [1,2,15], } } Aggregated }
  • 49. 2019 KrakenD API Gateway49 Avoid the “take it all” pattern Client Providing a lot of data to the client, just in case it’s needed Gateway Your 10MB, thank you HORROR STORIES 😱
  • 50. 2019 KrakenD API Gateway50 Directly connect to message brokers Catalog /notify Notifications QUEUE Azure Service Bus Topic 4
  • 52. 2019 KrakenD API Gateway52 Simple deployment (stateless) FROM devopsfaith/krakend COPY krakend.json /etc/krakend/krakend.json + ≃ 40MB Dockerfile
  • 53. 2019 KrakenD API Gateway53 Deploy anywhere Orchestration Platforms
  • 54. 2019 KrakenD API Gateway54 Assign a KrakenD to each team (client type) Catalog Promotions Basket Payments Orders Pricing Stock Authentication Android iOS SPA
  • 55. 2019 KrakenD API Gateway55 Assign a KrakenD to each team (micro frontends) } } }
  • 56. 2019 KrakenD API Gateway56 Not necessarily the single point of entry Catalog Promotions Payments Orders Pricing Stock Authentication
  • 57. Observability Visualize the entire ecosystem from a central place
  • 58. 2019 KrakenD API Gateway58 Enable monitoring
  • 59. 2019 KrakenD API Gateway59 1-click export of logging, metrics and traces
  • 60. 2019 KrakenD API Gateway60 Metrics and Tracer exporters for every taste
  • 61. 2019 KrakenD API Gateway61
  • 62. 2019 KrakenD API Gateway62 Repeat x N services 3 Break a piece of the monolith 4 Aggregate the microservice 5 Deployment and Observability
  • 63. 2019 KrakenD API Gateway63 MONOLITH Orders Pricing Stock Basket Payments Promotions Catalog MONOLITH 🎉
  • 64. 2019 KrakenD API Gateway64
  • 65. 2019 KrakenD API Gateway65 Special thanks to...
  • 66. 2019 KrakenD API Gateway66
  • 67. 2019 KrakenD API Gateway67 Questions? Let’s have a beer! @devopsfaith | @alombarte Email: albert@krakend.io Photo by Patrick Fore

Notes de l'éditeur

  1. From on-premises monolith to cloud microservices BEST VIEWED IN PRESENTATION MODE TO UNDERSTAND TRANSITIONS SLACK: https://invite.slack.golangbridge.org/ → #krakend channel
  2. The LOGIC needs to persist its state in an external DATA, that is queried by all nodes. It’s the SOURCE OF TRUTH Scaling the Gateway means scaling a database. WHEN we go to multiple regions, this data needs to be synchronized. The gateway does not work without a DB
  3. In a STATELESS gateway everything needed to provide the service, lives inside the configuration of the application and there is no need of centralization and shared state (database). Every node only knows about its own state and it does not need to know about the other nodes
  4. Because a GW is a piece usually in the middle of your backend consumption is too tempting to do certain stuff. We think that a gateway cannot be the new monolith and shouldn’t have centralization.
  5. API GATEWAY -> Connects EXTERNAL TRAFFIC with INTERNAL SERVICES. As it can provide AGGREGATED consumption of services for the client is also associated to the BACKEND FOR FRONTEND SERVICE MESH → Internal communication
  6. A proxy might solve some of these SHARED problems (cross-cutting concerns), like security, rate limiting or circuit breaking. (HAPROXY, NGINX PLUS) ** A Proxy ADDS ROUTING capabilities. We can have a group of URLs pointint to a specific service But the problem of this approach is this is a 1 to 1 . ONE-SERVICE-CONSUMED-AT-A-TIME The clients are totally COUPLED to the Backend. Specially inconvenient for Mobile apps that cannot change the contract at wil once they are published in the AppStore or GooglePlay All these proxies call themselves API GATEWAYS or even API Managers! There is a lot of controversy on the term, thanks to marketing
  7. BUT A PROXY IS NOT SUITABLE FOR A MICROSERVICES MIGRATION, AS IT IS UNABLE TO AGGREGATE SOURCES The term “traditional api gw” is sometimes used to stateful api gw. The API Gateway can implement the BFF because you build it while thinking about the needs of the client app.
  8. Add the gateway keeping the API contract, as proxy - backward compatibility Microservices do not need to implement security - Replace cookies, use JWT Chop the monolith and create a microservice Use the gateway to aggreagate the services. The client won’t notice anything Traces, loging and metrics Go to 3 until monolith disappears
  9. Put the krakend in the cloud, to face problems for being in a different network from the beginning (connection) We put the gateway as proxy (not a GW yet) We make sure we forward all cookies, as our example monolith uses them We replicate all the endpoints of the monolith in the GW. Backwards compatibility: Keep the contract Test and Change DNS When we have this, the client doesn’t know that we added a GW
  10. KEEP SHORT TOKENS REFRESH TOKEN can be handled automatically, many libraries do it already.
  11. The Social aspect usually weights more than the technical Social = What is the size of your team, and their experience with MS? Growing plans (x4)? Responsibilities? Tech = Domain of the components, dependencies BTW components, latency constraints, persistence model
  12. When designing the microservices and how to extract them is very important to not create dependencies over the network
  13. Heavy artifacts!
  14. A good first candidate is usually the authentication service
  15. A request method is considered "idempotent" when multiple identical requests have the same effect. Request methods should be "safe" when theri semantics are essentially read-only; i.e., the client does not request, and does not expect, any state change
  16. DEVELOPER FOCUSES ON FUNCTIONALITY
  17. A lot of this calls are due to drag and drop SDKs
  18. More with: Flatmap DSL Language, Martian Lua Scripts
  19. Aggregation is done automatically but filter out those attributes that you don’t need The gateway can be very fast, but if you pack the entire Internet in the response it won’t be a good experience.
  20. Deploying a stateless GW is very easy as there is no persistence associated. As there is only a configuration file, all you need to do is to COPY the file in your immutable container. Doing a Blue/green deployment is very easy and superfast as the artifact is so small, and the nodes start without coordination.
  21. It’s very important that such a complicated Grafana
  22. Zipkin example
  23. Instana (enteprise subscription) and Zipkin
  24. REPEAT THE OPERATION WITH ANOTHER SERVICE: Move to a microservice Aggregate in the gateway with its corresponding use cases
  25. IN MANY CASES, the effort of going fully to microservices is too high. You can keep your REDUCED MONOLITH as another service, preferably now inside the cloud
  26. 2'5 YEARS AGO we built from scratch an extensible API Gateway. We LEARNED the hard way. Doing consultancy all this time helped us improve and grow our product with the real problems of the companies, at a crazy rythm. - We provide today an open source project that brings all the Enterprise features at no cost. - We are provably the only company in Barcelona developing 100% in Go. In late 2016 we decided to repeat to create a Gateway for the public audience and started running in production
  27. Numbers from 1st June 2019