I am looking for an algorithm to distribute some tasks. The problem is this:
Let's say I have a major task maker and some client clients. The producer creates tasks, and consumers take tasks (for starters, one at a time), process them, and when they are completed, perform new tasks (I already have a task queue).
The fact is that if you think that a task needs to be obtained from the producer to the consumer, it may make sense to combine the tasks together. For example, let's say we have 10 tasks in total and 2 consumers. If each task requires 5 ms and the network delay is 5 ms, sending each of two groups of 5 tasks to each of them will be 5 ms + 5 * 5 ms = 30 ms; individually, 5 * 5 will be required when sending tasks ms + 5 * 5ms = 50 ms, because the delay overhead appears for each task.
This is not as simple as grouping, as some tasks are likely to take longer and it would be wise to send them separately so that other tasks that take a shorter time are handled in parallel by other consumers. I plan to make some statistics about the type of tasks. The number of consumers is also not constant.
Any idea of a good algorithm or good reading that can help me achieve this?
source
share