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

Reduce timeout for the first Connect() request #540

Merged
merged 1 commit into from
Nov 27, 2018

Conversation

ralt
Copy link
Contributor

@ralt ralt commented Nov 22, 2018

In the case of a zookeeper server under pressure, it will typically try to maintain the quorum rather than handling client requests. In this kind of case, the quorum is maintained, the connection works, but the client is frozen there.

Retrying after a shorter timeout means we can reconnect to another server before losing the session altogether.

Copy link
Member

@StephenSorriaux StephenSorriaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thank you for your PR.

I am not sure if this is the best way to handle this case... KazooClient is accepting a timeout parameter, isn't it better to personnalize that parameter? I might be missing something... why the value of len(client.hosts)?

@ralt
Copy link
Contributor Author

ralt commented Nov 23, 2018

Hi,

This was defined in a similar manner as connect_timeout. The idea being that if you have one server, then the timeout can be the full timeout (/ 1). If you have more, then it makes sense to split that, so that the client gets a chance to retry on other servers if the Connect() request fails.

@StephenSorriaux
Copy link
Member

You are right, this makes sense.

It is also available in the java client (https://github.com/apache/zookeeper/blob/master/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java#L1383).

Can you please amend your commit in order to follow the CONTRIBUTING.md guidelines?

Copy link
Member

@StephenSorriaux StephenSorriaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please amend your commit.

In the case of a zookeeper server under pressure, it will typically try to maintain the quorum rather than handling client requests. In this kind of case, the quorum is maintained, the connection works, but the client is frozen there.

Retrying after a shorter timeout means we can reconnect to another server before losing the session altogether.
@ralt
Copy link
Contributor Author

ralt commented Nov 27, 2018

@StephenSorriaux does it look good now?

@StephenSorriaux
Copy link
Member

@ralt That is great! Thanks again for your PR.

@StephenSorriaux StephenSorriaux merged commit 2ae392e into python-zk:master Nov 27, 2018
@ralt
Copy link
Contributor Author

ralt commented Nov 27, 2018

Thanks for the merge! 👍

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

Successfully merging this pull request may close these issues.

2 participants