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

Slow Producer #603

Closed
kiro opened this issue Feb 11, 2016 · 2 comments
Closed

Slow Producer #603

kiro opened this issue Feb 11, 2016 · 2 comments

Comments

@kiro
Copy link

kiro commented Feb 11, 2016

Hi,

we observe another peculiar behaviour, if we have a consumer and sync producer for the same topic running in two different goroutines (regardless of the number of partitions), the producer has significantly slower (~10x) produce rate than if it's running by itself.

We're using Sarama version Version 1.8.0 (2016-02-01), Kafka 0.8.2.1 and go1.5.1 linux/amd64

Config is

kafkaConfig.Producer.RequiredAcks = sarama.WaitForAll
kafkaConfig.Producer.Return.Errors = true
kafkaConfig.Producer.Return.Successes = true
kafkaConfig.Producer.Partitioner = sarama.NewManualPartitioner
kafkaConfig.Consumer.Return.Errors = true
kafkaConfig.Consumer.Fetch.Min = 8192
kafkaConfig.Consumer.MaxWaitTime = 250 * time.Millisecond
kafkaConfig.Net.DialTimeout = 5 * time.Second**

This is the profiler graph
https://www.dropbox.com/s/n5s0xssygcojxej/pprof001.svg?dl=0

code is here
https://gist.github.com/kiro/3fb5a80a2196d694cc61

logs look like

TRACE consumer/broker/2 added subscription to test/5
TRACE consumer/broker/1 added subscription to test/6
TRACE producer/broker/2 starting up
TRACE producer/broker/2 state change to [open] on test/1
TRACE consumer/broker/2 added subscription to test/7
TRACE Producer shutting down.
TRACE producer/broker/2 shut down
@eapache
Copy link
Contributor

eapache commented Feb 11, 2016

It's not clear if the producer and consumer are sharing the same client. If they are then that is likely the problem: from a single client, the kafka broker serves requests strictly serially, so while the consumer has requested new messages, the producer cannot proceed. Try using separate clients.

@kiro
Copy link
Author

kiro commented Feb 15, 2016

Hi, yes that was the problem, thanks for your help. Maybe the documentation should be updated, currently https://github.com/Shopify/sarama/blob/master/client.go#L12 states "A single client can be safely shared by multiple concurrent Producers and Consumers."

eapache added a commit that referenced this issue Feb 16, 2016
As pointed out in #603 this is generally inefficient and misleading.
@eapache eapache closed this as completed Feb 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants