API Gateway Patterns: Kong, Envoy, and Traefik
Configure Kong or Envoy as an API gateway to centralise auth, rate limiting, routing, caching, and observability.
Set up Kong or Envoy with the provided Docker‑Compose or yaml config to centralise auth, rate limiting, routing, caching, and observability.
Summary
The article explains the role of an API gateway as a single entry point that centralises authentication, rate limiting, routing, load balancing, caching, and observability for backend services. It compares three popular gateways—Kong, Envoy, and Traefik—highlighting Kong’s evolution from an Nginx‑based gateway to a full‑featured API management platform. The author provides a Docker‑Compose example for Kong 3.8, showing how to spin up a Postgres database, configure environment variables, expose ports 8000/8001, and create services and routes via curl. It also demonstrates adding a rate‑limiting plugin and a JWT authentication plugin to Kong. For Envoy, the article supplies a YAML configuration that defines listeners, filter chains, HTTP connection managers, virtual hosts, routes, retry policies, and clusters pointing to user‑service and order‑service. The guide emphasises that using an API gateway eliminates duplicated auth and rate‑limiting logic in each microservice. It also notes that Envoy is the data plane for Istio and other service meshes, offering high performance and programmability. The article concludes by encouraging developers to set up either Kong or Envoy to centralise cross‑cutting concerns and improve observability.
Key changes
- Provides Docker‑Compose setup for Kong 3.8 with Postgres 16 and ports 8000/8001.
- Shows how to create services, routes, rate‑limiting, and JWT plugins via curl.
- Supplies Envoy YAML config defining listeners, filter chains, HTTP connection manager, and retry policies.
- Demonstrates virtual hosts and routes for user‑service and order‑service clusters.
- Highlights that an API gateway centralises auth, rate limiting, routing, caching, and observability.
- Notes Envoy is the data plane for Istio and other service meshes.