Closed dabibu153 closed 2 years ago
generatePdf is a blocking operation maybe? Remember javascript is single threaded, so to parallelize you will need to fork child processes or talk to another long running process over the network. Queue is probably not very useful for your use case as I understand it so far
In a browser context you can use web workers to parallelize
thanks for the reply and the clarification. after some RnD, I decided to settle with worker-threads. now the heavy blocking operation (generatePDF) is moved down to a worker thread while the main thread handles the API requests.
I am trying to implement a operation queue that will handle a heave processing task while the rest of the express application and all the APis keep working normally. But as soon as the queue is called [ queue.start() ], all the APis in the server stop responding and don't work until the queue is done with its work.
how do i make it so both the queue and the rest of the express server work simultaneously.
` const startHeavyQueue = (filters) => {
`
this is the function i call withing the main api. the api simply calls it and returns a 200 response stating when the processing is done, you will get a notification.
now its my first time attempting anything more than a simple express server, so any and all input is appreciated. thanks