XenonStack

Enterprise Digital Platform

XenonStack Insights KrakenD API Gateway for Microservices: Guide

and | Published | Updated

KrakenD API gateway guide: one client entry point, aggregation and rate limits, JSON configuration, stateless gateway

Key takeaway

  • KrakenD API gateway for microservices: what it is, how to run it, features by edition, how it compares with Kong and Nginx, and when to use one.

KrakenD is an open-source API gateway that sits in front of your microservices and gives clients one entry point. According to its docs, it is a declarative, high-performance gateway that needs no programming: you describe endpoints and backends in a JSON file, and KrakenD aggregates, filters and secures the traffic. This guide explains when it fits, how to run it and what to check before you adopt it. KrakenD overview.

KrakenD is one way to apply the API gateway pattern. If you are still choosing an architecture, start with our guide to microservices architecture and design patterns and our comparison of service-oriented architecture and microservices.

What is an API gateway for microservices?

The microservices.io pattern catalogue describes an API gateway as the single entry point for all clients of a microservices application. It either proxies a request to the right service or fans it out to several services. It can also expose a different API for each client type and handle security such as authorisation checks. Source: microservices.io, API Gateway pattern.

The same source lists the benefits (clients are shielded from how the application is split into services, fewer round trips, protocol translation) and the cost: the gateway is another moving part to build, deploy and manage, and it adds a network hop, which that source considers insignificant for most applications.

What is KrakenD and how is it different?

KrakenD is written in Go and is built on the Lura Project, a Linux Foundation project (formerly the KrakenD Framework), according to its docs. Its design rules, as the docs list them, include reactive, fail fast, keep it simple, everything pluggable and request-scoped processing. The docs describe two states: a building state, where it parses configuration and prepares middleware, and a working state, where routes are already mapped in memory.

Two columns: without a gateway (many calls, client knows layout, repeated policies, failing backend) and with KrakenD (aggregated endpoint, JSON config, rate limits, circuit breaker).

It is also stateless. The Community Edition repository on GitHub describes it as a high-performance, stateless, declarative API gateway written in Go and lists the Apache-2.0 licence. The deployment docs say its nodes do not need to communicate with each other, and that a configuration change requires a restart, as with other stateless services such as Nginx. KrakenD CE on GitHub and KrakenD deployment docs.

How do you run KrakenD from the command line?

The run guide gives the basic command below. The flags it documents are -c or --config for the configuration file and -d or --debug for debug mode. By default KrakenD listens on port 8080, and the docs show a health check at /__health. Confirm port and other options in the run guide.

krakend run -c krakend.json

The minimal configuration in the docs declares the schema and version 4: { "$schema": "https://www.krakend.io/schema/v3.0/krakend.json", "version": 4 }. For containers, the docs say an immutable Docker image with your configuration takes a few seconds to build in a CI/CD pipeline, and recommend at least two instances for high availability.

How do endpoints and aggregation work?

Each endpoint object has an endpoint path, a method (default GET) and a backend array. Each backend sets a host and a url_pattern. A single endpoint can list several backends, and KrakenD merges their responses into one, using a fork-and-join middleware with a timeout. The output_encoding field defaults to json. Endpoint docs and design docs.

What features does KrakenD provide?

The tables below use only what the KrakenD docs state. Edition details change, so confirm on the Enterprise overview page before you buy or build.

CapabilityWhat the docs sayEdition
Aggregation and response shapingMerges several backend calls into one endpoint, with filtering and encoding optionsCommunity
Endpoint, client and proxy rate limitsStateless limits per endpoint, per end user and between KrakenD and backendsCommunity
Circuit breakerHalts requests to a failing backend after consecutive failuresCommunity
Stateful (Redis) and tiered rate limitingListed as additional Enterprise optionsEnterprise
Centralised authentication, RBAC, GitOps auditing, SLA supportListed on the Enterprise overview, which says Enterprise has over 30 additional featuresEnterprise
Extra backends such as gRPC, Kafka, RabbitMQ, NATSListed as Enterprise service connectivityEnterprise

Check the docs for security headers and authentication options that your version supports.

How does KrakenD compare with Kong, Nginx, MuleSoft and Postman?

These products do different jobs, so a tick-box matrix misleads. The table below quotes each vendor's own wording.

ProductHow its own site describes itWhere it fits
KrakenDDeclarative, high-performance, open-source API gateway needing no programming (krakend.io)Aggregation and BFF-style gateways configured in JSON
Kong GatewayA lightweight, fast and flexible cloud-native API gateway (developer.konghq.com)General-purpose API gateway; confirm editions on its site
NginxDocs say a common use of a reverse proxy is load balancing (docs.nginx.com)Reverse proxy and load balancer in front of services
MuleSoft AnypointA centralised API management platform, with a secure, high-performance gateway (mulesoft.com)Full API management in a MuleSoft estate
PostmanDescribes itself as API engineering for your agents (postman.com)API design and testing tooling, not a runtime gateway

How fast is KrakenD?

KrakenD's benchmark page claims about 18,000 requests per second on an ordinary laptop, and lists Amazon EC2 results from 10,126 requests per second on a c4.2xlarge to 2,758 on a t2.micro. The page footer is dated 28 October 2016 and the laptop is a 2015 MacBook Pro, so treat these as historic vendor figures, not a forecast for your workload. Load test with your own routes, payloads and backends. KrakenD benchmarks page.

When should you choose a gateway, and when not?

SituationSuggested approachTrade-off
Many clients need data from several servicesGateway with aggregation, such as KrakenDOne more component to deploy and run
You only need load balancing or TLS terminationA reverse proxy may be enoughNo response merging
You need full API lifecycle management and a developer portalEvaluate a management platformMore cost and platform scope
Agents and automations call your APIsPut rate limits, authentication and audit logging at the gatewayPolicy must be kept in step with the backends

For testing and deployment practice around gateways, see our guides to microservices testing and developing and deploying Spring Boot microservices.

How do you govern gateway traffic when AI agents call your APIs?

A gateway is a natural place to enforce who may call what, and how often. When AI agents become API consumers, the harder question is which decisions they are allowed to take and on what context. ElixirData Context OS keeps governed context, versioned policy and decision traces in one decision layer above AI agents, and ElixirClaw is an agentic OS platform to build, orchestrate and govern AI agents and automation workflows while keeping humans in control. AgentGRC keeps autonomous agent actions inside policy, with the audit trail risk teams need.

What should you do first?

  1. List the client types and the services each one needs; draw the calls you would aggregate.
  2. Run the minimal configuration locally and check /__health.
  3. Add one aggregated endpoint, then rate limits and a circuit breaker.
  4. Load test with your own traffic and decide between Community and Enterprise on the docs comparison.
  5. Build the configuration into an immutable image and run at least two instances.

To map one API decision your agents should make, and the context and policy it depends on, book a Context Workshop. See what happens in the workshop.

FAQ

What is KrakenD used for?

According to its docs, KrakenD is an open-source API gateway that aggregates multiple microservices behind single endpoints and can filter, throttle and authenticate traffic.

Is KrakenD free?

The Community Edition is open source under the Apache-2.0 licence, according to its GitHub repository. An Enterprise Edition adds features and SLA-backed support; confirm current terms on krakend.io.

Does KrakenD need a database?

The deployment docs say its nodes do not need to communicate with each other, and the repository describes it as stateless. Configuration lives in a JSON file.

How do you start KrakenD?

Run krakend run -c krakend.json. It listens on port 8080 by default and the docs show a health check at /__health.

Can KrakenD replace Nginx?

They overlap but differ. Nginx docs describe load balancing as a common reverse proxy use, while KrakenD focuses on aggregation and API gateway policies. Test both on your own traffic.

Are the old KrakenD benchmark figures still valid?

The vendor benchmark page is dated 28 October 2016, so treat the figures as historic and run your own load test.

Table of Contents

navdeep-singh-gill

Navdeep Singh Gill

Global CEO and Founder of XenonStack

LinkedIn profile

Navdeep Singh Gill is serving as Chief Executive Officer and Product Architect at XenonStack. He holds expertise in building SaaS Platform for Decentralised Big Data management and Governance, AI Marketplace for Operationalising and Scaling. His incredible experience in AI Technologies and Big Data Engineering thrills him to write about different use cases and its approach to solutions.

Get the latest articles in your inbox

Subscribe Now

Interested in Solving your Challenges with XenonStack Team
Get Started

Get Started with your requirements and primary focus, that will help us to make your solution

Please Select your Industry
Banking
Fintech
Payment Providers
Wealth Management
Discrete Manufacturing
Semiconductor
Machinery Manufacturing / Automation
Appliances / Electrical / Electronics
Elevator Manufacturing
Defense & Space Manufacturing
Computers & Electronics / Industrial Machinery
Motor Vehicle Manufacturing
Food and Beverages
Distillery & Wines
Beverages
Shipping
Logistics
Mobility (EV / Public Transport)
Energy & Utilities
Hospitality
Digital Gaming Platforms
SportsTech with AI
Public Safety - Explosives
Public Safety - Firefighting
Public Safety - Surveillance
Public Safety - Others
Media Platforms
City Operations
Airlines & Aviation
Defense Warfare & Drones
Robotics Engineering
Drones Manufacturing
AI Labs for Colleges
AI MSP / Quantum / AGI Institutes
Retail Apparel and Fashion

Proceed Next