Backend Development 24 min read

Designing API Gateways: Comparison, Key Considerations, and Best Practices

This article explains how to design API gateways by comparing common gateway solutions, outlining essential design aspects such as routing, service discovery, load balancing, resilience, security, and high performance, availability, and scalability, and summarizing the strengths of OpenResty, Kong, Zuul, and Spring Cloud Gateway.

Wukong Talks Architecture
Wukong Talks Architecture
Wukong Talks Architecture
Designing API Gateways: Comparison, Key Considerations, and Best Practices

Overview

The article introduces API gateways, explains why they are needed, and links to a previous deep‑dive on Spring Cloud Gateway.

Comparison of Common Gateways

A visual comparison of several popular API gateways gives readers a quick overall impression.

Design Considerations for an API Gateway

Routing and Forwarding

Requests first reach the gateway, are matched by predicates, and then forwarded to the appropriate backend service.

Service Registration and Discovery

Service instances register their name, IP, and port with a registry; the gateway queries the registry to route requests by service name.

Load Balancing

The gateway distributes traffic among multiple instances of a service to achieve load balancing.

Resilience (Elastic Design)

Features such as retries, idempotency, flow control, circuit breaking, and monitoring are incorporated so that backend services can focus on business logic.

Security

SSL termination, session validation, authorization, data validation, and protection against malicious attacks are handled at the gateway level, along with advanced capabilities like gray‑release, API aggregation, and orchestration.

Key Design Priorities

High Performance

The gateway should not become a bottleneck; high‑performance languages (C, C++, Go, Java) and asynchronous non‑blocking I/O (e.g., Netty, Spring Reactor) are recommended.

High Availability

To avoid a single point of failure, the gateway must be clustered, support hot configuration reloads, and provide graceful restarts.

Clustering : The gateway should form its own cluster and synchronize data internally.

Service‑oriented : Configuration changes should be possible without downtime, ideally via an Admin API.

Graceful Restart : New requests are routed to new processes while old processes finish existing work before exiting.

High Scalability

The gateway must handle increasing traffic by scaling horizontally, supporting plugins or modules for custom business logic, and integrating with DNS, CDN, or dedicated load‑balancers.

Operational Design Guidelines

Keep business logic loosely coupled from the gateway; the gateway should only handle protocol headers.

Provide application monitoring and tracing (e.g., distributed tracing IDs) to collect throughput, latency, and error metrics.

Implement resilience patterns such as circuit breaking, rate limiting, retries, and timeouts.

Adopt DevOps practices for automated testing, performance testing, and fault‑tolerant deployment.

Gateway Types and Use Cases

Traffic Gateway

Acts as a global entry point for traffic, handling policies like global rate limiting, logging, and load balancing. Kong is a typical example.

Business Gateway

Placed closer to backend services, it provides features such as authentication, logging, encryption, circuit breaking, and API management. Popular implementations include Zuul and Spring Cloud Gateway.

Common Open‑Source Gateways

OpenResty (Nginx + Lua)

Kong (cloud‑native, built on OpenResty)

Zuul / Zuul2 (Netflix)

Spring Cloud Gateway (Spring ecosystem)

OpenResty

High‑performance web platform based on Nginx and Lua, suitable for handling massive concurrency and extending Nginx with Lua scripts.

Kong

Cloud‑native API gateway built on OpenResty, offering plugins for authentication, traffic control, monitoring, and serverless integration.

Zuul 1.0

Edge service that provides dynamic routing, security, monitoring, and load balancing via a filter chain.

Zuul 2.0

Rewritten with Netty for asynchronous non‑blocking processing, introducing inbound, endpoint, and outbound filters.

Spring Cloud Gateway

Based on Spring Framework 5, Project Reactor, and Netty, it offers route predicates, filters, and integrates with Hystrix, DiscoveryClient, and other Spring Cloud components.

Summary Comparison

A final diagram compares the strengths and trade‑offs of the four major gateways, helping readers choose the most suitable solution for their architecture.

backend architecturemicroservicesHigh Availabilityload balancingAPI gatewaySpring Cloud GatewayKong
Wukong Talks Architecture
Written by

Wukong Talks Architecture

Explaining distributed systems and architecture through stories. Author of the "JVM Performance Tuning in Practice" column, open-source author of "Spring Cloud in Practice PassJava", and independently developed a PMP practice quiz mini-program.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.