How to create and manage workflows in NodeJS?

For example, let's say a user requests some kind of sound file that needs to be processed, then, of course, nodejs cannot perform intensive processing, so it must unload it into a workflow.

These workers should probably be able to pub / sub for events, respawn when they die, and the line should be able to load balance, maintain cache and continue to live. I saw 0MQ and others like it, but I'm not sure how I'm going to integrate it into a web application ...

What is the standard way to create and manage these workflows? And what tools are used?

Edit: One more thing: let's say sound processing takes a lot of time and the request expires. Is there any way around this other than increasing the timeout?

Edit 2: By workers, I mean, Heroku workers as workers - how do they work?

+4
source share
1 answer

Personally, I would probably do something like adding tasks to the redis database. Then another process (possibly written in another language, if it is very heavy) subscribes to this key in the redis database and starts the tasks that are added to it. It can even manage some workflows.

For a timeout, you can use one request only to run the task and another request to get the results (using longpolling if the result is not yet available or even better than server click through websites).

+1
source

Source: https://habr.com/ru/post/1391930/


All Articles