TECH_COMPARISON
API Gateway vs Service Mesh: A Detailed Comparison for System Design
Compare API gateways and service meshes — explore trade-offs in traffic management, observability, security, and when to use each pattern.
API Gateway vs Service Mesh
API gateways and service meshes manage traffic at different layers of the architecture. An API gateway handles north-south traffic (external clients entering the system). A service mesh handles east-west traffic (services communicating with each other internally).
API Gateway
An API gateway sits at the edge of your system. It handles authentication, rate limiting, request routing, protocol translation, and API versioning for external clients. Tools like Kong, AWS API Gateway, and Traefik serve this role.
Service Mesh
A service mesh deploys a sidecar proxy (typically Envoy) alongside every service instance. These proxies handle mTLS encryption, load balancing, retries, circuit breaking, and observability for all internal traffic. Istio, Linkerd, and Consul Connect are popular implementations.
They Solve Different Problems
The API gateway protects your system from the outside world. The service mesh protects services from each other. In a mature microservices architecture, you need both.
When a Service Mesh Is Overkill
Service meshes add significant complexity and resource overhead. Every service gets a sidecar proxy consuming CPU and memory. For architectures with fewer than 10-20 services, the operational cost often outweighs the benefits. Simple retry logic and circuit breakers in application code may suffice.
When It Is Essential
At scale (50+ services), implementing retries, mTLS, circuit breaking, and observability in every service's application code is unsustainable. The service mesh provides these capabilities uniformly without changing application code.
Learn more in our system design interview guide and microservices interview questions. See pricing for access.
The Bottom Line
Use an API gateway for external traffic management. Add a service mesh when internal service communication complexity justifies the operational investment — typically at 20+ services with strong observability and security requirements.
GO DEEPER
Master this topic in our 12-week cohort
Our Advanced System Design cohort covers this and 11 other deep-dive topics with live sessions, assignments, and expert feedback.
// RELATED_COMPARISONS
BFF vs API Gateway: A Detailed Comparison for System Design
Compare Backend for Frontend and API Gateway patterns — learn when to use client-specific backends vs a shared gateway in your architecture.
REST vs GraphQL: A Detailed Comparison for System Design
Compare REST and GraphQL APIs — learn the trade-offs in flexibility, performance, caching, and developer experience for modern system design.
REST vs gRPC: A Detailed Comparison for System Design
Compare REST and gRPC for system design — explore trade-offs in performance, serialization, streaming, and language support for microservices.
GraphQL vs gRPC: A Detailed Comparison for System Design
Compare GraphQL and gRPC — explore trade-offs in flexibility, performance, schema design, and when to use each in modern distributed systems.
Monolith vs Microservices: A Detailed Comparison for System Design
Compare monolithic and microservices architectures — understand trade-offs in scalability, deployment, team structure, and operational complexity.
REST vs WebSocket: A Detailed Comparison for System Design
Compare REST and WebSocket protocols — understand when to use request-response vs persistent bidirectional connections in system design.