Server
I am working on a server to manage several worker instances through TCP Sockets. However, I am having an issue distributing the tasks evenly among the worker instances.
Worker
The worker can have a set number of slots (threads) for tasks, and the amount of workers fluctuates from time to time. I want to be able to add and remove a worker on-demand. The tasks should be redistributed (so that each worker has tasks proportional to their capacity) in the event of the addition/deletion of workers. I also want to be able to add and remove tasks on-demand.
Example with Table View
| Worker 1 (Slot Capacity of 2) | Worker 2 (Slot Capacity of 2) | Worker 3 (Slot Capacity of 8) |
|---|---|---|
| task1 | task3 | task5 |
| task2 | task4 | task6 |
| task7 | ||
| task8 | ||
| task9 | ||
| task10 | ||
| task11 | ||
| task12 |
Are there any existing libraries that can help with this data structure? If not, what's my best route for making my own data structure like this?