Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the working of QueueCapacity/BatchSize/BatchTimeout #92

Closed
dgregoire opened this issue Apr 19, 2018 · 2 comments
Closed

Document the working of QueueCapacity/BatchSize/BatchTimeout #92

dgregoire opened this issue Apr 19, 2018 · 2 comments
Assignees
Labels
documentation in-progress Work in progress, see related pull request question

Comments

@dgregoire
Copy link

I've been using the Writer with a deadlined Context and I'm unsure how to configure it to allow batching while not blocking for the whole deadline duration.

If I set a BatchSize to 1, all is well but the load on the brokers and the network traffic is considerable. It's greatly reduced by setting BatchSize to another number - like 2, however WriteMessages blocks for the duration of the deadline (300ms here)

capture d ecran 2018-04-19 a 12 56 30

I believe my understanding of the documentation is wrong?

Unless the writer was configured to write messages asynchronously, the method blocks until all messages have been written, or until the maximum number of attempts was reached.

There's about 1.3k WriteMessages per second in this test, with BatchSize set to 2 and RequiredAcks set to 1.

@achille-roussel
Copy link
Contributor

@dgregoire are you able to share which version of Kafka you had done these tests against, as well as the number of brokers and partitions in the topic? The writer definitely shouldn't block until the deadline is reached, because we have tests that verify its behavior.

If it timed out due to reaching the context deadline you should be getting en error returned from the (*Writer).WriteMessages call, is this what you observed? (seems like it from your screenshot but I just wanted to confirm)

A batch size of 2 is quite small, I would expect this to put significant load on the Kafka brokers, which means some requests could timeout if there is concurrency involved and you hit hardware limits on the underlying hardware (like disk bandwidth, IOPS, CPU, etc...).

@dgregoire
Copy link
Author

@achille-roussel Kafka 1.0.1 with 3 brokers, 12 partitions / topic.

The specific use case is:

  • default batch size of 5/2
  • context with timeout in 100/200/500ms
  • WriteMessages() with 1 kafka.Message

In all combinaisons I tested, the WriteMessages function locks until the context is deadline exceeded and the function returns that error, unless the configured batch size is 1.

I suspected this might happen when using send messages with a number of message != batch size but never proved that theory, what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation in-progress Work in progress, see related pull request question
Projects
None yet
Development

No branches or pull requests

3 participants