Service Mesh vs API Gateway

Kasun Indrasiri
Oct 9, 2017 · 3 min read

In one of my previous articles on service mesh, there were a couple of questions related to the relationship between Service Mesh and API Gateway. So, in this post, I’m planning to discuss the usage of Service Mesh and API Gateway.

In order to differentiate API Gateways and service mesh, let’s have a closer look at the key characteristics API Gateways and Service Mesh.

API Gateway: Exposes your services as managed APIs

The key objective of using API Gateway is to expose your (micro) services as managed APIs. So, the API or Edge services that we develop at the API Gateway layer serves a specific business functionality.

  • API/Edge services call the downstream (composite and atomic) microservices and contain the business logic that creates compositions/mashups of multiple downstream services.

Service Mesh

Now let’s look at how we can differentiate Service Mesh.

  • Service Mesh is a network communication infrastructure which allows your to decouple and offload most of the application network functions from your service code.

Coexistence of API Gateway and Service Mesh

The key differentiators between API Gateways and service mesh is that API Gateways is a key part of exposing API/Edge services where service mesh is merely an inter-service communication infrastructure which doesn’t have any business notion of your solution.

Figure 1 illustrates how API Gateway and service mesh can coexist. As we discussed above, there are also some overlapping features (such as circuit breakers etc.) but it’s important to understand these two concepts are serving fundamentally different requirements.

Image for post
Image for post
Figure 1: API Gateways and service mesh in action

As shown in figure 1, service mesh is used alongside most of the service implementations as a sidecar and it’s independent of the business functionality of the services.

On the other hand, API Gateway hosts all the API services (which has a clearly defined business functionality) and it’s a part of the business functionality of your solution. API Gateway may have in-built inter-service communication capabilities but that doesn’t prevent API Gateway using service mesh to call downstream services(API Gateway->service mesh->microservices).

At API Management level, you can either use in-built inter-service communication capabilities of API Gateway or API Gateway can call downstream services via service mesh by offloading application network functions to service mesh.

Replacing API Gateway with Service Mesh sidecar proxy

In certain use cases, we can eliminate API Gateway altogether and offload the API Gateway capabilities to the Sidecar proxy that is colocated with the service that you want to expose as an API. The API management plane/control plane needs to communicate with the sidecar proxy to apply the API Management capabilities.

Image for post
Image for post

However, this model force us to expose services through the sidecar proxy layer which is colocated with the microservice.

References

Microservices in Practice

Microservices in Practice

Kasun Indrasiri

Written by

Author of O’Reilly ‘gRPC Up and Running’, ‘Microservices for the Enterprise’, Software Architect, Product Manager, Apache Committer, Director-Integration @WSO2

Microservices in Practice

Microservices in Practice

Kasun Indrasiri

Written by

Author of O’Reilly ‘gRPC Up and Running’, ‘Microservices for the Enterprise’, Software Architect, Product Manager, Apache Committer, Director-Integration @WSO2

Microservices in Practice

Microservices in Practice

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store