Sajith Silva
Sajith Silva

Reputation: 823

microsevice apigateway pattern

I'm working on a user web on a new project where I need to maintain good response time for each request. I'm wondering what are the microservice patterns I should be using.

I have been reading up on "api-gateway" pattern where the gateway is the service orchestrator. As I understand API should call the services synchronously in order to grantee the logical flow of the business. That really reduces some of the advantages reactive gives.

Other way is to make the api gateway asynchronous, then state needs to be maintained for each request so when service replies are received, it can be mapped to correct request and continue the flow.

I have been searching on this topic but could not find too many useful articles. Can you please share your thought or point me to some articles which discuss this topic.

Thank you !

Upvotes: 0

Views: 91

Answers (2)

Folger Fonseca
Folger Fonseca

Reputation: 303

making a call synchronous does not mean that it cant be reactive, reactive represents the way your app server will deal with request either using a thread pool (which is a limited resource) vs using a reactive approach you dispatch response as you have then. the second approach can still give you synchronous responses to your clients (web or mobile apps)

Upvotes: 0

Ian Swift
Ian Swift

Reputation: 71

The first optimization you should make should always be the most effective one. Look at your most expensive operation. For me, and I believe this will prove true for most developers, it's communicating between services. Whether it's from your API Gateway to data services, from data services to their databases, the goal should be to minimize that. So yes, the first thing you should do is make your API-Gateway requests happen in parallel as it talks to this service. Otherwise instead of doing (essentially) 1 call to a service (since they happen at the same time) you would be doing N calls, where N is the number of services. Big time loss there.

Upvotes: 1

Related Questions