API Gateway End Points to Microservices

0

We are building a cloud native architecture with React Frontend on S3, API Gateway, Microservices on Lamba functions and necessary AWS services. API Gateway to fulfill the cross-cutting concerns and to act as a BFF.

My question is about the mapping between the API Gateway and Microservices. There are 3 microservices (let say order, customer, payment) built on Java Spring.

  1. Should I need to create equivalent API's (https proxy) in API gateway to connect to the microservices?
  2. If so, should I need to create 3 API resources with 2 endpoint methods (let say get, post) in API gateway to map all the 3 microservices? so 3 API's with 6 methods in total?
  3. If so, should I need to create a microservice per API method (let say get, post) so 6 microservices in total?
  4. When comes to microservice that's also a Rest service which means list of Resources and methods again. In that case, 3 Microservices with (3 Resources X each 2 Methods) - 6 methods in total?
  5. So, I could visualize one to many mapping between API methods in API gateway and Microservice methods like 6 X 6 combinations? I agree microservice should not be actions based but creating a few CRUD actions is planned for now.
  6. For cross-cutting concerns (auth, logging etc.), should we define separate API resources in API Gateway? then no microservices required in that case.

I read a lot about API Gateway and Microservices but I could not get a clear understanding on the best practices around creating the API end points when it comes to integration with microservices. Please shed some light. Thanks.

1 Answer
1

In a cloud native architecture with an API Gateway, you typically do not need to create equivalent APIs in the API Gateway for each of your microservices. Instead, you can use the API Gateway to create a single, unified API that provides a single entry point for your client applications to access the functionality exposed by your microservices.

To do this, you can create a single API in the API Gateway and define multiple resources within that API to represent the different functionality exposed by your microservices. For example, you could create a resource for the "order" microservice, a resource for the "customer" microservice, and a resource for the "payment" microservice.

Within each of these resources, you can then define methods (such as "GET" and "POST") that map to the corresponding endpoints in your microservices. So, in the case of your three microservices, you would likely define three resources with two methods each, for a total of six methods.

You do not need to create a separate microservice for each method in the API Gateway. Instead, you can use the API Gateway to route requests from your client applications to the appropriate microservice and endpoint based on the resource and method specified in the request. This allows you to keep your microservices simple and focused on a specific set of functionality, while using the API Gateway to handle the cross-cutting concerns such as authentication, authorization, and rate limiting.

SeanSi
answered a year ago
  • Thanks for the detailed response, it helps. I have added a few more questions (#4 to 6) based on your answer. Appreciate if you can clarify.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions