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

Sparse connections #284

Closed
winbatch opened this issue May 21, 2015 · 7 comments
Closed

Sparse connections #284

winbatch opened this issue May 21, 2015 · 7 comments

Comments

@winbatch
Copy link

Let's say I have 5 broker hosts in the cluster. I'm noticing if I supply a single broker to the API, there will be 6 connections created. 1 to each broker and 1 extra to the broker I supplied the API. I imagine the logic is simple and it is connecting to all the brokers in the metadata list but I think it should ignore the 1 it's already talking to. Can it be enhanced to skip him? We are trying to reduce the number of connections to the brokers.

@edenhill
Copy link
Contributor

A shortcoming of the Kafka protocol is that you can't identify the broker you are connected to, you can only do this by reference.
The reference is the metadata received from the bootstrap broker(s), which says:
broker id X is at host.example.com:9092

That's why librdkafka can't know that the bootstrap broker is indeed the same as one reported from metadata.

Anyway, others have raised concerns about the number of open connections, and I believe the scala/java clients only keeps connections open to the brokers it needs (e.g., the leaders for topic+partitions being produced/consumed).
I'm planning to add the same sparse behaviour to librdkafka, probably with a new configuration property that is disabled by default (!!).

@winbatch
Copy link
Author

Hmm. Can't you just call getpeername() on the socket to know who you're talking to?

@edenhill
Copy link
Contributor

I could, but DNS does not have to be asymetric, nor 1:1, so it couldn't really be trusted.

Disconnecting from brokers we dont need will solve your problem though, e.g., sparse connections, so that's what I'll go for.

@winbatch
Copy link
Author

Fair enough. I prefer your solution anyway as it further reduced connections

@winbatch
Copy link
Author

Hi- do you happen to know when you might implement this? I've made some changes to my code to feed you only one broker at a time (as needed) to reduce connections. If you add the sparse option soon (like within the week), I'll include that in my release. If you think it will be longer I'll just release with my change only (still a 40% improvement in our env)
Thanks!

@edenhill
Copy link
Contributor

Sparse connections will go into the dev branch with a bunch of other changes, so it is most likely a month or so from being merged into master.

@edenhill edenhill changed the title Extra socket connection Sparse connections May 31, 2015
@edenhill
Copy link
Contributor

edenhill commented Oct 7, 2016

Duplcate of #825

@edenhill edenhill closed this as completed Oct 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants