I'm creating worker_threads in node and I'm collecting them to custom WorkerPool. All workers are unique, because they have unique worker.threadId. My app have ability to terminate specific worker -- I have terminateById() method in WorkerPool.
So if you have one node.js instance -- everything is all right. But if you're trying to use docker-swarm or Kubernetes -- you will have n amount of different WorkerPool instances. So, for example, you have created some workers in one node instance and now you're trying to terminate one -- it means you have some request with threadId(or other unique data to identify worker). For example your load balancer have chosen to use another node instance for this request, in this instance you have no workers.
At first I thought, that I can change unique index for worker to something like userId+ThreadId and then store it in redis for example. But then I haven't found any info about something like Worker.findByThreadID(). Then what can I do in situation, when you have multiple node instances?
UPDATE: I have found some info about sticky sessions in load balancers. That means, that using cookies we can stick specific user to specific node instance, but this in my case this stickiness has to be active until worker is terminated. It can last for days
So, I have two answers.