APACHE APISIX: As an API Gateway in Microservices
Tags: microservices, cloudnative, apigateway, devops
Published: 2022-01-24 12:36:38

## Table of Content
 

- Microservices and Its Impact.
- API Gateway.
- How API Gateway Works.
- Integration of APISIX.
- Conclusion.

## Introduction

When building your application as a set of microservices, you’d decide how your application’s clients will interact with the microservices. With a monolithic application there is just one set of touchpoints of communication between an API and a server. 

In a microservices architecture, however, each microservice exposes a set of what are typically fine‑grained endpoints. 
In this article, you’ll walk through how microservices impacts client‑to‑application communication and the integration of an API Gateway called **[APISIX](www.apisix.apache.org)**.

## Microservices and Its Impact

Designing an application that is multi-lingual and easily scalable, easy to maintain and deploy while minimizing failure, microservices are used to achieve such results. Microservice is the process of designing and developing separated components that come together to form a more functional system.

Tasks are separately handled in microservice applications and its communication between clients and servers are handled using lightweight mechanisms. The communication between these services occurs through protocols such as HTTP, AMQP, and TCP. HTTP/REST and asynchronous messaging are the most widely used protocols. 

You can design your application as a collection of loosely coupled services that are connected together via an API Gateway.

## What is API Gateway 

The word API is an acronym for Application Programming Interface as you may already know, and it is a means of communication between clients and server. 
API gateway is a tool that manages clients and collection of backend services, it acts as an overturned proxy to accept all API calls made by the clients.

It accumulates all requests made and provides the accurate result needed, an API gateway is one part of the API management system that handles all requests processed, and gives back it’s result, ensuring they continuously meet high performance and security standards.

Enabling an API Gateway, you can create any type of APIs be it RESTful APIs and WebSocket APIs that foster real-time communication between applications. API Gateway supports containerized and serverless workloads, as well as web applications.

## How API Gateway Works


![API Gateway Pattern](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/20gob78hpn1ck8ez3apr.png) 

> “Cloud native architectures bring a whole new level of challenges, as does traffic from websites, mobile and IoT applications.”
Based on the adaptation of architecture like microservice the APISIX Gateway was designed to handle more traffic from different sources.

![API Gateway Microservices](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/srn9bpzswd9uh3gfqb7c.png)

## Integration of APISIX

[Apache APISIX](www.apisix.Apache.org) is a dynamic, real-time, high-performance API gateway that provides rich traffic management features such as load balancing, dynamic upstream, canary release, service meltdown, authentication, observability, and other rich traffic management features.

With the adoption of microservices over monolithic applications development, Apache APISIX is providing a more maintainable and scalable gateway system. For developers that are yet to be familiar with Apache APISIX, let me create this impression; APISIX is a dynamic version of Nginx. Using Lua to scale the development of plugins that has innovated the approach of traffic management.

Apache APISIX don’t relate with database, it handles traffic from L4 and L7 Network services, playing the role of load balancing over these network protocols. Apache APISIX is more like an all in one solution for L7 traffic. There are other Open Source projects that are designed and developed to handle similar issues related with L7 traffic; Nginx, Envoy, Kubernetes (K8s): ingressive controller, and Service Mesh.

Nginx is used in handling the movement of data packets that are initially entering a network from the clients, and while traffic within the data center – i.e server to server -- is also handled by Envoy. APISIX is one technology that handles both clients and server traffic.

## APISIX SOLUTION


![APISIX Solution](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ohi7fo86dko1ngw6lzm1.png)

## USED CASE

Banks uses Java Spring Cloud gateway to manage their data processes, and openID connects plugins for Apache APISIX to configure [Okta authentication](https://www.okta.com/products/authentication/). 
“Unlike the traditional authentication model, the centralized authentication model takes user authentication out of the application service. 

Take Apache APISIX as an example, the centralized authentication process is shown in the following diagram: first, the user initiates a request, and then the front gateway is responsible for the user authentication process, interfacing with the identity provider and sending the identity provider an authorization) request to the identity provider. The identity provider returns user info. After the gateway identifies the user, it forwards the user identity information to the back-end application in the form of a request header.”


![APISIX Modern Authentication](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oglepd1b8a9euji994kb.png)

## Conclusion 

Enterprises worldwide have used Apache APISIX to handle business-critical traffic, covering finance, Internet, manufacturing, retail, carriers, and more, such as NASA, the EU's Digital Factory, China Airlines, China Mobile, Tencent, Huawei, Sina Weibo, NetEase, Ke, 360, Taikang, Nayuki, and more. You can get started [here](https://apisix.apache.org/docs/apisix/getting-started/)

![Github:] (https://github.com/apache/apisix)
![Official website:](https://apisix.apache.org)