Three infrastructure patterns that get lumped together in every architecture diagram — here's what actually separates them, and when you need one, two, or all three
By The Coding Gopher
Published: 2026-11-10
URL: https://thecodinggopher.substack.com/p/api-gateway-vs-service-mesh-vs-sidecar
If you’ve spent any time in a platform engineering Slack channel, you’ve probably watched someone ask “should we use a service mesh or an API gateway?” — and watched three people give three different, mildly contradictory answers. That’s not because anyone’s wrong. It’s because API gateways, service meshes, and sidecar proxies solve overlapping problems at different layers of the stack, and the industry has been sloppy about the vocabulary for years.
So let’s fix that. By the end of this, you’ll know exactly what each of these things does, how they relate to one another (spoiler: one of them is a building block for another), and — more usefully — which one your architecture actually needs.
The one-sentence version of each
- API Gateway — a single front door that sits between the outside world and your services, handling auth, rate limiting, and routing for incoming traffic.
- Sidecar Proxy — a lightweight proxy deployed alongside a single service instance, handling networking concerns for that one workload.
- Service Mesh — a fleet of sidecar proxies plus a control plane that coordinates them, managing traffic between your internal services.
If you only remember one distinction, make it this one: API gateways manage north-south traffic (client-to-service). Service meshes manage east-west traffic (service-to-service). Sidecar proxies are the mechanism a service mesh uses to do that.
Now let’s unpack each one properly.
Join a community of senior engineers. Subscribe and get FREE access to System Design deep dives.
Learn System Design, Visually (Module 1 Free)

Want to understand systems like this well enough to design them yourself?
My animated course System Design, Visually Explained builds every concept as a clean, step-by-step diagram, from the fundamentals to real interview designs. It grew out of my YouTube explainers, which have millions of views.
Module 1 is free. No card needed.
Want everything? All-Access Lifetime includes all 6 live courses (System Design, AI Engineering, Backend Development, Cloud Development, System Design: Case Studies and Data Structures & Algorithms), the 10 on the way (Distributed Systems, How Computers Really Work, Database Internals and more), the full System Design Visual Guide and every course after that, for one payment.
💡 Many engineers expense this through their team's learning budget.
API Gateway
An API gateway is the single, centralized entry point that external clients — mobile apps, web frontends, third-party integrators — talk to. Instead of a client needing to know about (and authenticate against) fifty different microservices, it talks to one gateway, which then routes the request to the right place internally.

\An API gateway acts as a single front door for applications,centralizing security, routing, and traffic management before requests reach backend microservices.\
What it typically handles:
- Authentication and authorization (API keys, OAuth, JWT validation)
- Rate limiting and quota enforcement
- Request routing and composition (sometimes aggregating multiple backend calls into one response)
- Protocol translation (REST in, gRPC out, for example)
- API versioning
- Request/response transformation
- Centralized logging and analytics for external traffic
Common tools: Kong, Amazon API Gateway, Apigee, NGINX, Azure API Management.

\An API gateway isa server that acts as a single entry point from client apps to backend microservices. It handles request routing, traffic management, security, and protocol translation so individual services do not have to repeat these tasks.\
The defining trait of a gateway is that it’s a single, centralized chokepoint sitting at the edge of your system. There’s usually one logical gateway (even if it’s horizontally scaled behind a load balancer) for the whole architecture, and it exists specifically to mediate the boundary between “outside” and “inside.”
Note: An API proxy is a lightweight intermediary that forwards client requests to a single backend API with basic routing and minimal processing. An API gateway is a comprehensive, centralized hub that manages multiple microservices, enforcing advanced security, rate limiting, analytics, and request transformations.
Sidecar Proxy
A sidecar proxy is a small, dedicated proxy process deployed next to a single service instance — literally as a second container in the same Kubernetes pod, or a co-located process. Every request in or out of that service passes through its sidecar first.
What it typically handles, on behalf of one service:
- mTLS encryption/decryption
- Retries, timeouts, and circuit breaking
- Load balancing across downstream instances
- Local telemetry (latency, error rates, request volume for that service)
- Traffic shaping (canary weights, header-based routing)
Common implementation: Envoy is the de facto standard here — it’s the proxy underneath Istio, and it powers plenty of standalone use cases too.

\A sidecar proxy isa helper helper tool that runs next to your main app. It intercepts all incoming and outgoing network traffic. This setup lets you add security and tracking features without changing your app code.\
The key idea behind the sidecar pattern is separation of concerns: your application code doesn’t need to implement retry logic, TLS handshakes, or circuit breakers in every language your teams happen to use. The sidecar handles all of that transparently, so a Go service and a Python service get identical networking behavior without either one writing networking code.
On its own, a sidecar proxy is just a local decision — it governs traffic for its service. It doesn’t know or care what the sidecar next to it is doing. That’s where the third piece comes in.
Build Redis, Git, Docker & Claude Code From Scratch

Want to become a better software engineer?
Trusted by engineers at Google, NVIDIA, and Anthropic, CodeCrafters helps you rebuild technologies like Redis, Git, Docker, and Claude Code from scratch so you can deeply understand how real systems work.
We’ve partnered with CodeCrafters to give all readers an exclusive 40% lifetime discount.
💡 Engineers may expense platforms like this through their team’s learning budget.
Service Mesh
A service mesh is what you get when you deploy a sidecar proxy next to every service in your system, and then add a control plane that configures all of them consistently and centrally
\A service mesh isa dedicated infrastructure layer that manages safe, fast, and transparent communication between software services. It removes communication logic from the app code and handles it using an array of lightweight network proxies.\
Structurally, a service mesh has two layers:
- Data plane — the actual sidecar proxies (usually Envoy) doing the packet-pushing, one per service instance.
- Control plane — the central controller that pushes configuration to every sidecar: routing rules, mTLS certificates, retry policies, traffic-splitting percentages for canary deploys, and so on.
What it typically handles, mesh-wide:
- Automatic mutual TLS between every service, with certificate rotation
- Fine-grained traffic control (e.g., “send 5% of traffic to v2”)
- Uniform observability — latency, error rate, and traffic graphs for every service-to-service call, without instrumenting application code
- Consistent retry/timeout/circuit-breaking policy across the whole fleet
- Fault injection for chaos testing
- Fine-grained authorization between services (service A can call service B, but not service C)
Common tools: Istio, Linkerd, Consul Connect, AWS App Mesh.
So the relationship is: a service mesh is essentially many sidecar proxies, unified by a control plane. The sidecars do the work of intercepting and handling traffic; the control plane is what makes sure they’re all doing it according to the same rules.
Join a community of senior engineers. Subscribe and get FREE access to System Design deep dives.
How they fit together

\Microservices architecture isa design style that builds a single application as a set of small, independent services. Each service runs its own process, focuses on one business task, and talks to other services using clear APIs.\
In a mature microservices architecture, it’s common to run all three at once, each doing a different job:
Internet / External Clients
│
▼
┌───────────────┐
│ API Gateway │ ← north-south traffic
└───────┬───────┘
│
┌─────────────┼─────────────┐
▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌─────────┐
│ Sidecar │ │ Sidecar │ │ Sidecar │ ← one per service instance
│ Proxy A │ │ Proxy B │ │ Proxy C │
└────┬────┘ └────┬────┘ └────┬────┘
│ │ │
┌────▼────┐ ┌────▼────┐ ┌────▼────┐
│Service A│ │Service B│ │Service C│
└─────────┘ └─────────┘ └─────────┘
▲ ▲ ▲
└─────────────┴─────────────┘
east-west traffic, coordinated by the
Service Mesh control plane
The gateway controls what enters the system from outside. The mesh controls how internal services talk to each other once they’re in. The sidecar is where the mesh’s rules actually get enforced, one service at a time.
Side-by-side comparison

So which one do you actually need?
A few rules of thumb, roughly in order of how most teams grow into this stack:
- Just building something with external clients and a handful of backend services? Start with an API gateway. You almost certainly need one before you need anything else — it’s your auth boundary and your rate limiter.
- Services calling each other a lot, and you’re duct-taping retry logic into every language separately? That’s the signal for sidecar proxies, even without a full mesh. Some teams run standalone Envoy sidecars without adopting a control plane at all.
- Dozens (or hundreds) of services, multiple teams, and you’re losing sleep over mTLS rotation, inconsistent retry behavior, or “why did that one Java service handle timeouts differently”? That’s when the coordination overhead of a full service mesh starts paying for itself.
It’s also worth saying plainly: you don’t need a service mesh at ten services. Meshes add real operational complexity — an extra control plane to run, upgrade, and debug, plus sidecar resource overhead on every pod. Plenty of solid production systems run an API gateway plus some in-app resilience libraries and never bother with a mesh at all. Reach for one when the coordination problem — not just the networking problem — becomes real.
The common confusion, resolved
The reason people conflate these three is that they all sit in the request path and they all touch similar concerns — routing, TLS, auth, observability. The difference is scope and direction, not function:
- The gateway asks: “Should this request from the outside world be let in, and where should it go?”
- The sidecar asks: “How should this specific service’s traffic behave — retries, encryption, timeouts?”
- The mesh asks: “How do I make sure every sidecar in my fleet is enforcing the same policy?”
Once you see it that way, the question stops being “gateway or mesh?” and becomes “which layer of my traffic problem am I actually trying to solve?” Most systems, as they grow, end up needing an answer at every layer — just not all on day one.