Closed dtryon closed 4 years ago
Hi @dtryon!
Thanks for using microjob: hope it is helping you with your job 💪
Well, I'd recommend starting the thread pool before calling starting the Koa server (app.listen
to be clear).
With the thread pool working for all the incoming requests, you can improve performance in terms of context switching between the main thread and the worker.
Well, no. The worker thread starts at the beginning, before the Koa server. This way it will be available for each request: when you need to off load some CPU computation, just send the request to the worker thread through microjob.
Hi, and thank you for that awesome work. The api is perfect for my use case (off loading some CPU intensive calcs).
Is there some guidance on how to setup a web server to use microjob?
for example, say I'm using koa. Should I use
start()
next to the import at the top of a module? This will cause the worker pool to be global. Or should I callawait start()
andawait stop()
on every request?Thank you.