Service Mesh vs API Gateway

Ali Sozkesen
Ali Sozkesen 19 May 2021
Author:

The difference between API gateway and Service Mesh is considered many times by everyone in microservices and API architecture roles.

One of the most complex questions people have about a Service Mesh is, “What are the differences between API gateway?”. There is an overlap between API gateway and service networks.

In this article we will discuss this difference and see which is best for us! But first we need to dive deep about the meanings, what they are and where they are mostly used for.

What is Service Mesh?

Service mesh is just an infrastructure layer that sits on the top of the micro services and handles all the communications between services. Service mesh tracks, relays and secures all data flow between the services or microservices. With mash you are basically worrying about the end points, hosts, ports, metric collection and traffic routing. One of the most important examples of popular service meshes are Istio, CNCF project and Linkerd. And keep in mind that, you need API gateways in order to use Service mesh because API Gateways have an overlap with service mesh for the functionality.

What is API Gateway?

API Gateway is a software pattern or tool that sits in front of API or a bunch of APIs and manages requests and delivery of data and services. It acts as a Control Center to accept all application programming interface (API) calls, aggregate the various services required to fulfill them, and return the appropriate result. Just like Netflix’s API Gateway (Zuul), clients use a bunch of various devices like phones, tablets, smart tvs, etc. Netflix attempts to provide one size API that fits all different kinds of various devices.

The Difference Between Service Mesh and API Gateway

They both can handle request routing, service discovery, rate limiting, authentication and monitoring. But there are different intentions among them. A service mesh aims to manage internal service-to-service communication, while an API Gateway is primarily focused to manage traffic from client-to-service.

Service Mesh API Gateway
Focuses on internal organizing resources. Maps external traffic to internal resources.
Exposes service to the internet. Manages and controls services inside the network.
Handles east-west traffic. Handles north-south traffic.
Manages internal traffic service to service. Manages Traffic from edge level client to service.

Do you need to use both?

You can use both together, but as service mesh improves, it will cover a lot of what you get from an API gateway today. The key reason behind an API gateway is to target traffic from outside your system and transmit it inside to service. The key purpose behind a service mesh is to manage traffic inside your system.

You should keep in mind that Service Mesh technologies are developing rapidly, and starting to take on some of the places of an API gateway.

When Not to Use a Service Mesh

A service mesh might not ensure any supplemental interests in the following cases,

Observability: You do not need detailed tracking between services. Or all you need is observability, maybe it can be solved more simply with basic tools.

Where north-south traffic: All of the communication in your application stays within a single limit, there are no internal resources.

Few services: You have few services or your services don't measure too many examples.

Wrapping Up

Although there is overlap in terms of technology for now, Service Mesh still needs a lot of development to completely replace the API Gateway. For now their roles are quite different from each other, and understanding this difference can give you a lot of advantage on deploying your microservices architectures and discovering unwanted guesswork along the way.

Share:
 
Ali Sozkesen
Written by

Ali Sozkesen

A marketing professional with software development skills.