KrakenD API Gateway
Product overview
@devopsfaith
KrakenD API Gateway Product overview @devopsfaith Microservices - - PowerPoint PPT Presentation
KrakenD API Gateway Product overview @devopsfaith Microservices are challenging The need for agility and scalability has driven Microservices adoption, but: 91% of Internet businesses are using or have plans to use microservices 86% expect
KrakenD API Gateway
Product overview
@devopsfaith
Microservices are challenging
The need for agility and scalability has driven Microservices adoption, but: 91% of Internet businesses are using or have plans to use microservices 86% expect microservices to be the default architecture within five years
* Independent research study conducted by Dimensional Research, April 2018
99% report challenges in using microservices
What problem do we solve?
Consume use-cases in a microservice-based ecosystem
Catalog Promotions Basket Payments Orders Pricing Stock Authentication
Android iOS SPAKrakenD offloads shared needs
Catalog Basket Orders Promotions Stock Payments Pricing 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 Serverless functions Lambda Bot detection I/O validation
Common scenarios for KrakenD
MONOLITH
Database
Catalog Promotions Basket Payments Orders Pricing Stock Authentication
Transition to microservices
1 2
JWT
Authentication
3
Service 1
Aggregate
Service 2
"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
Authentication
/checkout JWT token
Catalog Promotions Basket Payments Orders Pricing Stock
MONOLITH
MONOLITH
Orders Pricing Stock Basket Payments Promotions Catalog
MONOLITH
Event-driven architecture
Notifications
/notify
QUEUE
Azure Service Bus Topic4
Client Apps (consume a use-case)
Catalog Promotions Basket Payments Orders Pricing Stock Authentication
/frontpage { "catalog": {}, "promos": {}, "pricing": {} }
Aggregation
<id_product>2</id_product> <name>Wireless Headset</name> <date fmt="Y-m-d">2019-06-04</date> { "code": "PromoChristmas", "discount": 0.15, "products": [1,2,15] }
+
{ "id_product": 2, "name": "Wireless Headset", "date": "2019-06-04", "code": "PromoChristmas", "discount": 0.15, "products": [1,2,15] }
Aggregated
Catalog Promotions
KrakenD as a 3rd party provider
{ "3dparty": {}, "internal": {} } 3rd party services Company services
Transformation API
rename id_user => user_id rename alias => username remove password add static_data Services
Manipulation/Filtering/Grouping/Transformation
<id_product>2</id_product> <name>Wireless Headset</name> <date fmt="Y-m-d">2019-06-04</date>
Catalog
{ "code": "PromoChristmas", "discount": 0.15, "products": [1,2,15] }
Promotions +
{ "catalog": { "id_product": 2, "name": "Wireless Headset", "date": "2019-06-04", }, "promotions": { "code": "PromoChristmas", "savediscount": 0.15, "products": [1,2,15], } }
Aggregated
TL;DR - Instant creation of high-performance API
through a configuration file
More components and features⦠(open source)
https://github.com/devopsfaith/krakend-contrib
Enterprise components
With similar products
Photo by @voyagefervor, Instagram
Service Mesh API Gateways Proxies with GW GraphQL API Managers
Proxy with GW 1:1 mapping endpoint-backends - No business logic - Offload cross-cutting
Products with overlapping features
GraphQL HTTP only - Single Endpoint - Allows the client to choose exactly the data in the response. ~BFF. E.g: you provide an API to developers out of your
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
API GW API GW: North-south traffic Mesh: east-west traffic
Proxy with API Gateway capabilities
Catalog Promotions Basket Payments Orders Pricing Stock Authentication
Android iOS SPAPROXY
Stateful
Stateless
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
DB-LESS != stateless
Simple deployment (stateless)
FROM devopsfaith/krakend COPY krakend.json \ /etc/krakend/krakend.json
+ β
70MB
DockerfileDeploy anywhere
Orchestration Platforms
Assign a KrakenD to each team (client type)
Catalog Promotions Basket Payments Orders Pricing Stock Authentication
Android iOS SPAAssign a KrakenD to each team (micro frontends)
Not necessarily the single point of entry
Catalog Promotions Payments Orders Pricing Stock Authentication
Benchmarks
Benchmark Overview
# Hardware specs Requests second Average response 1. Amazon EC2 (c4.2xlarge) 10126.1613 reqs/s 9.8ms 2. Amazon EC2 (c4.xlarge) 8465.4012 reqs/s 11.7ms 3. Amazon EC2 (m4.large) 3634.1247 reqs/s 27.3ms 4. Amazon EC2 (t2.medium) 2781.8611 reqs/s 351.3ms 5. Amazon EC2 (t2.micro) 2757.6407 reqs/s 35.8ms 6. MacBook Pro (Aug 2015) 2,2 GHz Intel Core i7 18157.4274 reqs/s 5.5ms
On a raspberry 2
Without KrakenD
With KrakenD (concurrence=3)
Visualize the entire ecosystem from a central place
1-click export of logging, metrics and traces
Enable monitoring
Metrics and Tracer exporters for every taste
KrakenD Users
Open-source adoption
120,000 KrakenD sessions (12mo)
1 session = 1 cluster with at least 12 hours uptime
Takeaways
β Automatic API generation and integration β Consumers (iOS, Android, Web, Server devs) in control
β Homogeneous consumption
encodings β Reduced bandwidth and errors β Increased speed β Better quality of service
Letβs have a beer!
@devopsfaith | @alombarte
Photo by Patrick Fore