24- API Gateway

 

-->  API Gateway :

An API gateway is an API management tool that sits between a client and a collection of backend services.

 An API gateway acts as a reverse proxy to accept all application programming interface (API) calls, aggregate the various services required to fulfill them, and return the appropriate result.

OR

In simple terms single entry point for clients.

Client does not call all services directly.

The request first goes to API Gateway which will forward the requests to appropriate backend services.



Why use API gateway? 

In a microservice architecture, the API gateway pattern can help to solve a range of issues. 

The gateway sits at the edge of the microservices, managing API calls that flow between client applications and the various services. 


Without an API gateway, you’re left dealing with a direct client-to-microservices pattern. Such implementations can get very messy, very fast. 

You end up with multiple client calls to multiple microservice endpoints, with client apps and microservices coupled in a way that discourages any kind of evolution of your microservices due to the layers of complexity involved. You’re effectively stifling innovation. 




The benefits of an API gateway for microservices


The advantages of an API gateway in microservices architectures are numerous. Let’s look at some of the headline benefits. 


--> Prevents exposing internal concerns to external clients 

An API gateway separates external public APIs from internal microservice APIs, allowing for microservices to be added and boundaries changed. The result is the ability to refactor and right-size microservices over time, without negatively impacting externally-bound clients.


--> Adds an additional layer of security to your microservices

API gateways help to prevent malicious attacks by providing an additional layer of protection from attack vectors such as SQL Injection, XML Parser exploits and denial-of-service (DoS) attacks.


--> Enables support for mixing communication protocols

While external-facing APIs commonly offer an HTTP or REST-based API, internal microservices may benefit from using different communication protocols. 

Protocols may include ProtoBuf, AMQP or perhaps system integration with SOAP, JSON-RPC or XML-RPC. An API gateway can provide an external, unified REST-based API across these various protocols, allowing teams to choose what best fits the internal architecture.


--> Decreased microservice complexity

Microservices have common concerns, such as: authorization using API tokens, access control enforcement and rate limiting. Each of these concerns can add more time to the development of microservices by requiring that each service implement them. 

An API gateway will remove these concerns from your code, allowing your microservices to focus on the task at hand.


--> Microservice mocking and virtualization

By separating microservice APIs from the external API, you can mock or virtualize your services to validate design requirements or assist in integration testing.




The drawbacks of a microservice API gateway


While there are many benefits to using an API microservice gateway, there are some downsides:

-->  Your deployment architecture will require more orchestration and management with the addition of an API gateway


--> Configuration of the routing logic must be managed during deployment, to ensure proper routing from the external API to the proper microservice


--> Unless properly architected for high availability and scale, an API gateway can become a limiting factor and even a single point of failure

Comments

Popular posts from this blog

INDEX OF JAVA 8 and MICROSERVICES BLOG