alexreidy / parallafka-for-dotnet

Parallelized Kafka consumer for maximizing throughput
Apache License 2.0
1 stars 1 forks source link

support a commit Delay or ASAP commit. #8

Closed Gonyoda closed 2 years ago

Gonyoda commented 2 years ago

This allows Parallafka clients to choose a commit delay for handling messages. A delay of TimeSpan.Zero means the handled messages will commit as quickly as possible. Any other delay means that commits will happen within that delay. If the message queue is filled, commits occur ASAP.

This approach is more efficient than what it replaces: 1) There is no infinite loop that attempts to commit messages even when no messages were handled 2) All messages are committed within the delay timespan 3) The commit timer starts the moment a message handler completes

Note: includes code from #7 and #5

Testing results: Given:

Run times: 1000 MaxQueuedMessages: ~9 seconds, 75 commits 100_000 MaxQueuedMessages: ~6 seconds, 3 commits

alexreidy commented 2 years ago

Thanks for the improvements