migrate from monolith to microservice architecture

602 Views Asked by At

I have running my backend services based on Monolith Architecture using Node.js express. The application is getting big and I need to migrate from Monolith to Microserivce Architecture.

I decided to use REDIS pub/sub methods for messaging purpose among API Gateway and microservices. What is sure is that, I need to create a topic for every single API available under each microservice and then start listen for emitted event from API Gateway to interact and return appropriate data from microservice to Gateway and return that to end point.

For Instance, if an end point call api for gathering products list, there must be a listener opened inside the product microservice and listening for list event to generate the list and return via gateway to end point.

The question is, is there any solution available for me to either do not create event for every single API inside my microservices or there is no way for me and I need to create event listener for every API that I have?

1

There are 1 best solutions below

1
On

There are some patterns to refactoring a monolithic application to microservice. for example, you can use the anti-corruption layer to start it and the start to separate your bounded context one-by-one to a new Micro-service. Then you can use a gateway to handle your client request and authentications. To implement a fast dedicated Gateway you can use Ocelot. But don't forget that to implement a Microservice structure its important to know details about Domain-Driven Design (DDD) and some other patterns like CQRS and some Message brokers like rabbitMQ.

to start you can read and follow the below links:

Refactoring a monolith to microservices

Monoliths to microservices using domain-driven design