The Roles of Service Mesh and API Gateways in Microservice Architecture - by Tanmay Deshpande - Better Programming - Oct, 2020 - Medium
The Roles of Service Mesh and API Gateways in Microservice Architecture - by Tanmay Deshpande - Better Programming - Oct, 2020 - Medium
Tanmay Deshpande
Oct 3 · 5 min read
If you’re into microservices, then you might’ve heard about these two terms multiple
times. Often people get confused between the two. In this article, I’m going to talk about
service meshes and API gateways in detail and discuss when to use what.
The reason for having this refresher is we’re going to talk about some of these layers in
the next sections.
Service Mesh
A service mesh is a technology that manages service-to-service communication within a
distributed software system. Service meshes manage the east-west type of network
communications. East-west traffic indicates a traffic flow inside a data center,
Kubernetes cluster, or a distributed system.
Data plane
The proxies residing next to the app are called the data plane, while the management
components coordinating the behavior of proxies are called the control plane.
A service mesh allows you to separate the application’s business logic from the network,
reliability, security, and observability.
Since the service mesh provides health checks, retries, timeouts, and circuit breaking, it
improves the baseline reliability of your application.
Security
A service mesh allows mutual TLS among the services, which helps increase the security
of service-to-service communication. You can also implement access-control lists (ACLs)
as security policies.
A true service mesh/sidecar proxy supports a wide range of services and implements
L4/L7 traffic policies.
There are numerous service meshes available on the market. The following are a few of
them:
Istio
Linkerd
Kuma
Consul
You can find a number of articles on the internet comparing the service meshes listed
above.
API Gateway
An API Gateway acts as a single point of entry into a cluster, a data center, or a group of
distributed services. In the network topology, it’s often referred to as north-south traffic.
Typically, mobile clients fall into this type of network traffic.
It’s also quite possible that people may end up using API gateways for communication
between two products deployed in the same data center. In that case, the traffic type
can be east-west.
An API Gateway takes calls from clients and routes those to appropriate services. While
doing so, it can also translate protocols.
Authentication: An API Gateway can take care of the authentication and pass on
the token information to the services
Traffic control: An API Gateway can throttle inbound and outbound API traffic
Internal API gateway: Acts as a gateway for a group of services or a for product
scope
There are a number of API gateways available on the market. The following are a few of
them:
Apigee
Kong Gateway
When you can deploy sidecar proxies for every single service instance and its
replicas
When services can share the same CA certificate in order to establish secure
communication (this might not be possible across various products)
When you want to provide the API full lifecycle management to the developers
The above diagrams showcase that for a product scope, you can implement a service
mesh (east-west traffic). When there needs to be communication across products, an
internal API gateway can be used (east-west traffic). When clients at the edge need to
communicate with the services, an edge API gateway can be used (north-south traffic).