V
V
vetsmen2019-10-29 15:15:46
JavaScript
vetsmen, 2019-10-29 15:15:46

What is the best way to organize communication with a microservice?

Good day.
There is an application on Node.JS in conjunction with the cluster.
Task: upon a certain event from the user, set a task for execution to the API, which will execute a chain of requests and return a response.
Problem: clusters have been raised on Node.JS, however, in my opinion, for the API to work correctly, it needs to be abstracted into a separate process, because you need a single setTimeout to poll the API and a single RPS limiter.
Solution: send a message from the cluster to the API service through some kind of broker with a confirmation queue, then for this service to process this request, enter the result of the work into the database itself and send a notification via Redis pub / sub about the end of the work if the user is online. If not, the information will be pulled through the database the next time the user logs in.
Questions:
1) Is it normal to organize one-way communication between the main application and the microservice through a message broker?
2) Is it normal to delegate work from the database of the main application to the microservice? In fact, it will only update some data that the main application initially initializes there.
And in general, am I moving in the right direction?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IDONTSUDO, 2019-10-29
@vetsmen

What you will read below regarding the universal silver bullet is not.
1) In general, I would recommend doing this directly through sockets.
2) Nothing is true, everything is allowed, and it depends very much on the tasks. I don't think I can tell it exactly like Ilya Klimov *link to lecture on microservices*

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question