API Gateway vs Service Mesh
An API gateway and a service mesh both sit in the path of every request, but they guard two very different doors. A gateway is the front door, where calls from apps and browsers first come in. A service mesh handles the calls between services inside the system. Most big systems that use one end up using both.
API Gateway
One front door that sends each request to the right service.
An API gateway is a single front door that sits in front of many back-end services. Every request from an app goes to the gateway first. It checks who is calling, applies rate limits, and then sends the request on to the right service. It can also combine answers from several services into one reply. Clients only need to know one address.
Service Mesh
Small helpers sit next to each service. They handle the calls between them.
A service mesh is a layer that handles the traffic between services. The services do not have to. Next to each service runs a small proxy, often called a sidecar. All calls in and out pass through these proxies. They add encryption, retries, timeouts and traffic numbers without any change to the app code. It is mostly used when a company runs dozens or hundreds of services.
In one line
- API Gateway
- One front door that sends each request to the right service.
- Service Mesh
- Small helpers sit next to each service. They handle the calls between them.