The ultra-high
performance API
Gateway with
middlewares
What is an API
Gateway?
TL;DR
A REST service that exposes
endpoints with use cases
What is an API
Gateway?
TL;DR
It’s also an entry point for clients to
your microservices
What is and what
is not an API GW
Extended version
https://medium.com/devops-faith/an-
api-gateway-is-not-the-new-unicorn-
303a3863f2a6
And a
Middleware?
TL;DR
An application that wraps the
original application, adding more
functionality
Introducing KrakenD
Project overview
- Started Nov 2016
- Product built in Go language
- Concurrency
- High performance
- Coded after facing problems with unreliable APIs in production
- 3 core developers. More contributors are joining.
- 100% Open Source
Direct consumption of (micro)services?
API Gateway
KrakenD is a PURE API Gateway
Why KrakenD? There are many API GW solutions!
Yes, there are, but:
- Most of them cover features beyond an API Gateway
- Do not perform well or have poor performance
- Unfortunate architectures (e.g: share state between nodes)
- Single points of failure
- Paid, expensive and very limited. Monthly plans including X calls/month.
Convert that to reqs/sec!!
- Need complicated coding to make them work
- Not really extensible
The KrakenD
principles
- Reactive is key (even failing fast is
better than succeeding slow)
- The simpler, the better
- Everything is pluggable
- Each request must be processed in
its own request-scoped context
The Reactive Manifesto
http://www.reactivemanifesto.org/
Features
Features overview
KrakenD features
● Aggregates information from many sources into single endpoints.
● Manipulates responses and allows you to group, wrap, rename...
● Filters and shrinks responses, hiding unwanted attributes or selecting them
● Throttles (rate limits) connections against KrakenD and against backends
● Protects your backends with circuit breakers and implements all kinds of
security measures.
● Discovers your service instances by integrating with your SD provider
● Extends your ecosystem as it supports a myriad of middlewares and plugins,
such as OAuth or security layers.
● Speaks different encoding formats and protocols.
● Fine control of manipulations, validations and filtering with DSL configurations
Security features
● User quota
● Support for SSL
● OAuth client credentials grant supported
● Restrict connections by host
● HTTP Strict Transport Security (HSTS)
● Clickjacking protection
● HTTP Public Key Pinning (HPKP)
● MIME-Sniffing prevention
● Cross-site scripting (XSS) protection
Use cases
● Increase user experience in apps. Less data consumption and faster responses
● Instant creation of a new REST API
● Add APIs in legacy systems
● Unify data coming from different sources and encodings
● Publish a fixed interface, let the backends evolve and change contracts.
● Quick Microservices adoption
● Create aggregated views from a lot of services
● Build MVPs using data from anywhere (bonus: backend for api2html)
● Smooth transition over different API version releases
Performance
Performance
Requests per second in equal conditions. See benchmarks
Response time distribution
(real example)
Without KrakenD
~30% responses under 300ms
~60% responses between 300-1250ms
~10% responses over 1250ms
With KrakenD
~35% responses under 100ms
~55% responses between 100-300ms
~10% responses over 300ms
Do one thing and do it well.
KrakenD ecosystem
● KrakenD CE: KrakenD distribution ready to use.
● KrakenD framework: the core of the KrakenD is an open sourced library that
everyone can use, extend and modify. The project has several examples for
the integration with other third party libs (gorilla, negroni, gin, etc)
● KrakenD Contrib: A collection of components and middlewares to extend the
functionality
Designer (UI)
Try:
http://www.krakend.io/designer/
- No coding required
- The UI produces a
configuration file ready to
serve
How KrakenD works?
KrakenD uses two different states: building and working.
Building: When the service is initially being prepared to serve the requests,
prepares all the middlewares and defines the pipes. Each pipe is binded to an
endpoint via their outer common interface, resulting in a HTTP handler function.
Only when the configuration is parsed and the service being prepared.
Working: The router maps every request to a HTTP handler function and triggers
the pipe execution. As HTTP handler functions are built in the previous step,
KrakenD doesn't penalize the performance depending on the number of endpoints
or the possible cardinality of the URI requested by the users.
Architecture from
30.000ft
Composed of a set of go packages designed as building
blocks to create pipes and processors between an exposed
endpoint and one or several backends resources
CONFIG ROUTER PROXY
Components
Service definition Endpoints exposed
to the clients
Processing and
backend interaction
CONFIG ROUTER PROXY
The config package
The config package defines the entire service.
In the building stage, all the pipes are defined, with their tasks, helpers and
generators. Each pipe will be binded to an endpoint via their outer common
interface, resulting in a HTTP handler function.
The router package
The router layer is responsible for setting up the HTTP(S) services, binding the
endpoints defined by the config and transforming the HTTP request into proxy
requests before delegating the task to the inner layer (proxy).
When the internal proxy layer returns a response, the router layer converts it into a
proper HTTP response and sends it to the user.
This layer can be easily extended in order to use any HTTP router, framework or
middleware. Adding transport layer adapters for other protocols (Thrift, gRPC,
AMQP, NATS, etc) is in the roadmap.
The proxy package
Where most of the KrakenD components and features are placed. It defines two
important interfaces, designed to be stacked:
● Proxy is a function that converts a given context and request into a response.
● Middleware is a function that accepts one or more proxies and returns a single
proxy wrapping them.
This layer transforms the request received from the router into a single or several
requests to your backend services, processes the responses and returns a single
response.
Middlewares
Middlewares generate custom proxies that are chained depending on the workflow
defined in the configuration until each possible branch ends in a transport-related
proxy.
Each of these generated proxies is able to transform the input or even clone it
several times and pass it or them to the next element in the chain.
They can modify the received response or responses adding all kinds of features to
the generated pipe.
Middleware examples (open source)
● Balancing: uses some type of strategy for selecting a backend host to query.
● Concurrent: improves the QoS by sending several concurrent requests to the
next step of the chain and returning the first successful response using a
timeout for canceling the generated workload.
● Logging: logs the received request and response and also the duration of the
segment execution.
Middleware examples (open source)
● Merging: a fork-and-join middleware. Splits the process of the request into
several concurrent processes, each one against a different backend, and to
merge all the received responses from those created pipes into a single one. It
applies a timeout, as the concurrent one does.
● HTTP: completes the received proxy request by replacing the parameters
extracted from the user request in a defined URL Pattern.
● More middlewares and components:
https://github.com/devopsfaith/krakend-contrib
Live demo
KrakenD Playground
https://github.com/devopsfaith/krakend-playgroun
d
Get it
KrakenD:
http://www.krakend.io/download/
- Source code (compile yourself)
- Tarball
- Debian package
- RPM package
- Docker image
- Brew Formula
Install and run
Mac:
brew install krakend
krakend run -c krakend.json
---
Linux:
docker pull devopsfaith/krakend
docker run -p 8080:8080 -v $PWD:/etc/krakend/ devopsfaith/krakend
Give us a star if you like the project!
https://github.com/devopsfaith/krakend/stargazers

More Related Content

ODP
Selenium ppt
PDF
Designing APIs with OpenAPI Spec
PPT
Spring Core
PPTX
Automated Test Framework with Cucumber
PPTX
TypeScript VS JavaScript.pptx
PPT
Graphql presentation
PPTX
Introduction to microservices
PPTX
Spring Security 5
Selenium ppt
Designing APIs with OpenAPI Spec
Spring Core
Automated Test Framework with Cucumber
TypeScript VS JavaScript.pptx
Graphql presentation
Introduction to microservices
Spring Security 5

What's hot (20)

PPTX
Modern CI/CD Pipeline Using Azure DevOps
PPTX
Introduction to kubernetes
PPTX
Spring boot Introduction
PPTX
Introduction to Node.js
PPTX
Introducing type script
PPTX
Introduction To Microservices
PPTX
Type script - advanced usage and practices
PPTX
REST API Design & Development
PPTX
Gatekeeper: API gateway
PPSX
Microservices Docker Kubernetes Istio Kanban DevOps SRE
PPTX
Spring Boot
PPTX
Service mesh
PPTX
Json Web Token - JWT
PPTX
An Introduction To REST API
PPTX
Rest api with node js and express
PPTX
Microservices
PDF
Introduction to Tekton
PDF
Swagger UI
PDF
Introduction to jest
ODP
Introduction To RabbitMQ
Modern CI/CD Pipeline Using Azure DevOps
Introduction to kubernetes
Spring boot Introduction
Introduction to Node.js
Introducing type script
Introduction To Microservices
Type script - advanced usage and practices
REST API Design & Development
Gatekeeper: API gateway
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Spring Boot
Service mesh
Json Web Token - JWT
An Introduction To REST API
Rest api with node js and express
Microservices
Introduction to Tekton
Swagger UI
Introduction to jest
Introduction To RabbitMQ
Ad

Similar to KrakenD API Gateway (20)

PPTX
The new (is it really ) api stack
PDF
CNCF Singapore - Introduction to Envoy
PPTX
Debugging Microservices - QCON 2017
PDF
Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}
PDF
Open Source Networking Days- Service Mesh
PDF
Building Killer RESTful APIs with NodeJs
PPTX
Yotpo microservices
PPTX
APIs at the Edge
PDF
Open shift and docker - october,2014
PDF
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
PDF
Java one2013
PPTX
Service Meshes with Istio
PDF
All About Microservices and OpenSource Microservice Frameworks
PDF
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
PPTX
Gwt session
PPTX
Gwt session
PDF
Cloud Native API Design and Management
PDF
Building a sdn solution for the deployment of web application stacks in docker
PDF
APIs & Underlying Protocols #APICraftSF
The new (is it really ) api stack
CNCF Singapore - Introduction to Envoy
Debugging Microservices - QCON 2017
Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}
Open Source Networking Days- Service Mesh
Building Killer RESTful APIs with NodeJs
Yotpo microservices
APIs at the Edge
Open shift and docker - october,2014
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Java one2013
Service Meshes with Istio
All About Microservices and OpenSource Microservice Frameworks
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
Gwt session
Gwt session
Cloud Native API Design and Management
Building a sdn solution for the deployment of web application stacks in docker
APIs & Underlying Protocols #APICraftSF
Ad

Recently uploaded (20)

PDF
Session 1 (Week 1)fghjmgfdsfgthyjkhfdsadfghjkhgfdsa
PDF
Containerization lab dddddddddddddddmanual.pdf
PPTX
Introduction to cybersecurity and digital nettiquette
PDF
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
PDF
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
PDF
Uptota Investor Deck - Where Africa Meets Blockchain
PPTX
module 1-Part 1.pptxdddddddddddddddddddddddddddddddddddd
PDF
Understand the Gitlab_presentation_task.pdf
PPTX
t_and_OpenAI_Combined_two_pressentations
PPTX
TITLE DEFENSE entitle the impact of social media on education
PPTX
Internet Safety for Seniors presentation
PDF
The Evolution of Traditional to New Media .pdf
PPT
415456121-Jiwratrwecdtwfdsfwgdwedvwe dbwsdjsadca-EVN.ppt
PDF
BIOCHEM CH2 OVERVIEW OF MICROBIOLOGY.pdf
PPTX
Reading as a good Form of Recreation
PDF
si manuel quezon at mga nagawa sa bansang pilipinas
PDF
Exploring VPS Hosting Trends for SMBs in 2025
PPT
250152213-Excitation-SystemWERRT (1).ppt
PPTX
Top Website Bugs That Hurt User Experience – And How Expert Web Design Fixes
PPT
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
Session 1 (Week 1)fghjmgfdsfgthyjkhfdsadfghjkhgfdsa
Containerization lab dddddddddddddddmanual.pdf
Introduction to cybersecurity and digital nettiquette
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
Uptota Investor Deck - Where Africa Meets Blockchain
module 1-Part 1.pptxdddddddddddddddddddddddddddddddddddd
Understand the Gitlab_presentation_task.pdf
t_and_OpenAI_Combined_two_pressentations
TITLE DEFENSE entitle the impact of social media on education
Internet Safety for Seniors presentation
The Evolution of Traditional to New Media .pdf
415456121-Jiwratrwecdtwfdsfwgdwedvwe dbwsdjsadca-EVN.ppt
BIOCHEM CH2 OVERVIEW OF MICROBIOLOGY.pdf
Reading as a good Form of Recreation
si manuel quezon at mga nagawa sa bansang pilipinas
Exploring VPS Hosting Trends for SMBs in 2025
250152213-Excitation-SystemWERRT (1).ppt
Top Website Bugs That Hurt User Experience – And How Expert Web Design Fixes
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt

KrakenD API Gateway

  • 2. What is an API Gateway? TL;DR A REST service that exposes endpoints with use cases
  • 3. What is an API Gateway? TL;DR It’s also an entry point for clients to your microservices
  • 4. What is and what is not an API GW Extended version https://medium.com/devops-faith/an- api-gateway-is-not-the-new-unicorn- 303a3863f2a6
  • 5. And a Middleware? TL;DR An application that wraps the original application, adding more functionality
  • 7. Project overview - Started Nov 2016 - Product built in Go language - Concurrency - High performance - Coded after facing problems with unreliable APIs in production - 3 core developers. More contributors are joining. - 100% Open Source
  • 8. Direct consumption of (micro)services?
  • 10. KrakenD is a PURE API Gateway
  • 11. Why KrakenD? There are many API GW solutions! Yes, there are, but: - Most of them cover features beyond an API Gateway - Do not perform well or have poor performance - Unfortunate architectures (e.g: share state between nodes) - Single points of failure - Paid, expensive and very limited. Monthly plans including X calls/month. Convert that to reqs/sec!! - Need complicated coding to make them work - Not really extensible
  • 12. The KrakenD principles - Reactive is key (even failing fast is better than succeeding slow) - The simpler, the better - Everything is pluggable - Each request must be processed in its own request-scoped context
  • 16. KrakenD features ● Aggregates information from many sources into single endpoints. ● Manipulates responses and allows you to group, wrap, rename... ● Filters and shrinks responses, hiding unwanted attributes or selecting them ● Throttles (rate limits) connections against KrakenD and against backends ● Protects your backends with circuit breakers and implements all kinds of security measures. ● Discovers your service instances by integrating with your SD provider ● Extends your ecosystem as it supports a myriad of middlewares and plugins, such as OAuth or security layers. ● Speaks different encoding formats and protocols. ● Fine control of manipulations, validations and filtering with DSL configurations
  • 17. Security features ● User quota ● Support for SSL ● OAuth client credentials grant supported ● Restrict connections by host ● HTTP Strict Transport Security (HSTS) ● Clickjacking protection ● HTTP Public Key Pinning (HPKP) ● MIME-Sniffing prevention ● Cross-site scripting (XSS) protection
  • 18. Use cases ● Increase user experience in apps. Less data consumption and faster responses ● Instant creation of a new REST API ● Add APIs in legacy systems ● Unify data coming from different sources and encodings ● Publish a fixed interface, let the backends evolve and change contracts. ● Quick Microservices adoption ● Create aggregated views from a lot of services ● Build MVPs using data from anywhere (bonus: backend for api2html) ● Smooth transition over different API version releases
  • 20. Performance Requests per second in equal conditions. See benchmarks
  • 22. Without KrakenD ~30% responses under 300ms ~60% responses between 300-1250ms ~10% responses over 1250ms
  • 23. With KrakenD ~35% responses under 100ms ~55% responses between 100-300ms ~10% responses over 300ms
  • 24. Do one thing and do it well.
  • 25. KrakenD ecosystem ● KrakenD CE: KrakenD distribution ready to use. ● KrakenD framework: the core of the KrakenD is an open sourced library that everyone can use, extend and modify. The project has several examples for the integration with other third party libs (gorilla, negroni, gin, etc) ● KrakenD Contrib: A collection of components and middlewares to extend the functionality
  • 26. Designer (UI) Try: http://www.krakend.io/designer/ - No coding required - The UI produces a configuration file ready to serve
  • 27. How KrakenD works? KrakenD uses two different states: building and working. Building: When the service is initially being prepared to serve the requests, prepares all the middlewares and defines the pipes. Each pipe is binded to an endpoint via their outer common interface, resulting in a HTTP handler function. Only when the configuration is parsed and the service being prepared. Working: The router maps every request to a HTTP handler function and triggers the pipe execution. As HTTP handler functions are built in the previous step, KrakenD doesn't penalize the performance depending on the number of endpoints or the possible cardinality of the URI requested by the users.
  • 29. Composed of a set of go packages designed as building blocks to create pipes and processors between an exposed endpoint and one or several backends resources CONFIG ROUTER PROXY
  • 30. Components Service definition Endpoints exposed to the clients Processing and backend interaction CONFIG ROUTER PROXY
  • 31. The config package The config package defines the entire service. In the building stage, all the pipes are defined, with their tasks, helpers and generators. Each pipe will be binded to an endpoint via their outer common interface, resulting in a HTTP handler function.
  • 32. The router package The router layer is responsible for setting up the HTTP(S) services, binding the endpoints defined by the config and transforming the HTTP request into proxy requests before delegating the task to the inner layer (proxy). When the internal proxy layer returns a response, the router layer converts it into a proper HTTP response and sends it to the user. This layer can be easily extended in order to use any HTTP router, framework or middleware. Adding transport layer adapters for other protocols (Thrift, gRPC, AMQP, NATS, etc) is in the roadmap.
  • 33. The proxy package Where most of the KrakenD components and features are placed. It defines two important interfaces, designed to be stacked: ● Proxy is a function that converts a given context and request into a response. ● Middleware is a function that accepts one or more proxies and returns a single proxy wrapping them. This layer transforms the request received from the router into a single or several requests to your backend services, processes the responses and returns a single response.
  • 34. Middlewares Middlewares generate custom proxies that are chained depending on the workflow defined in the configuration until each possible branch ends in a transport-related proxy. Each of these generated proxies is able to transform the input or even clone it several times and pass it or them to the next element in the chain. They can modify the received response or responses adding all kinds of features to the generated pipe.
  • 35. Middleware examples (open source) ● Balancing: uses some type of strategy for selecting a backend host to query. ● Concurrent: improves the QoS by sending several concurrent requests to the next step of the chain and returning the first successful response using a timeout for canceling the generated workload. ● Logging: logs the received request and response and also the duration of the segment execution.
  • 36. Middleware examples (open source) ● Merging: a fork-and-join middleware. Splits the process of the request into several concurrent processes, each one against a different backend, and to merge all the received responses from those created pipes into a single one. It applies a timeout, as the concurrent one does. ● HTTP: completes the received proxy request by replacing the parameters extracted from the user request in a defined URL Pattern. ● More middlewares and components: https://github.com/devopsfaith/krakend-contrib
  • 39. Get it KrakenD: http://www.krakend.io/download/ - Source code (compile yourself) - Tarball - Debian package - RPM package - Docker image - Brew Formula
  • 40. Install and run Mac: brew install krakend krakend run -c krakend.json --- Linux: docker pull devopsfaith/krakend docker run -p 8080:8080 -v $PWD:/etc/krakend/ devopsfaith/krakend
  • 41. Give us a star if you like the project! https://github.com/devopsfaith/krakend/stargazers