Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs and batch jobs

I have an server side nodejs express app that responds to requests from front end clients. I need to implement a batch job that will run every hour. If I implement the batch job in the same service, does it mean that the service is 'occupied' until the cron job is completed and it will not be able to serve any requests? Should I create a separate service instead that will run the batch job?

like image 361
sand Avatar asked Feb 11 '26 14:02

sand


1 Answers

If your batch job does not occupy the cpu 100%, then the server will still serve requests. Every time you do async io or wait for timers, there is plenty of time for the express root routine to deal with requests.

I don't know what your job and server are doing, look at it from Separation of Concerns. If the job scheduler and server belong together, then implement them together, otherwise I recommend to make two services out of it.

like image 106
CFrei Avatar answered Feb 13 '26 09:02

CFrei



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!