So, I have a service made in node running on Kubernetes and I need to make a very heavy operation every 30 minutes (CRON JOB). It's a bunch of database operations for each tenant on my application (currently, 5 tenants).
The thing is that if I start then all, even asynchronously, on the same process the service goes into too much load and crashes.
Because of this, I tried to use the child_process module. My idea was to create a new process for each tenant,do what it needs to do and then kill the process.
I'm using child_process.fork('heavyLoadFile') to create the child process.
The thing is that when the work is done, the CPs are not being destroyed. They stay there as a "zombie" process, doing absolutely nothing.
I tried to process.kill() on the CP but it also kills the parent process.
How can I kill only the child_process? Oh, and do you guys think of a better way to handle this heavy loads?