My producer generates n
tasks from a single input message and publishes these on topic
.
The requirement is that out of all the individual consumers in the consumer group of topic
, no one of them should process more than 3 of any of these n
tasks within 1 hour.
This means that if I want to process all these messages immediately, I need at least ceil(n/3)
consumers. If there are fewer than ceil(n/3)
consumers then I need some way of deferring a message until there have been num_processed < 3
in the last hour.
In terms of practicalities to implement this solution, I am hoping to use Kafka with Faust [1] but I also have access to Redis if necessary.
My idea so far has been to ensure that there are at least ceil(n/3)
consumers when producing and then just use round-robin assignment of tasks to topic
by the producer. This is the optimal solution anyway because it prevents needing to ever wait up to 1 hour to process messages. However this would only work until enough consumers die whereupon more than 3 could be processed by the same consumer most likely within 1 hour. This is unacceptable.
Another idea might be to have the consumers check each time they take a message whether they have executed 3 of the n
tasks already and if so, somehow request that another consumer works on it - but I could not find any suitable mechanism in Kafka to enable this.