IGNITE-22403 Algorithm improvement for kafka topic partition distribution #272
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Distribution for partitions from kafka topic over requested threads in
AbstractKafkaToIgniteCdcStreamer
(CDC Kafka to Ignite) is not uniform.There might be cases with unequal load on threads, that reads data from kafka, which might result in overhead/bottleneck and slow workflow in general for the whole CDC with Kafka process. The improved version takes that into account.
Initially, for uniform distribution to form, the streamer calculated the ratio between the number of partitions and the number of threads.It didn't take into account the modulus of the result, thus leading to underestimated number of partiotions one thread can take. The fixed version of the algorithm uses modulus to round up the underestimated number to pump up the load on the first threads. To make things work, the number of partitions taken by each thread is reevaulated for each thread, which allows to reduce the difference in parity and integral division in general. In other words, threads balance themself out while partitions are being distributed from the first thread to the last one.