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

Configure maximum concurrent leader probes #303

Merged
merged 3 commits into from
Jul 10, 2024

Conversation

masnax
Copy link
Contributor

@masnax masnax commented Jul 5, 2024

Recently, go-dqlite was updated in #292 to concurrently open up to 10 requests to other cluster members when probing for leadership. The goal of this was to prevent go-dqlite from getting hung up on some unresponsive nodes.

One issue with this is that it is a bit too aggressive, each attempt to fetch the leader will execute effectively 2n - 1 network requests where n is the number of cluster members. #302 will make this return early if the leader is found, but it would also be great if a project could configure this value to grow and shrink based on the current health of the cluster.

Effectively, if the cluster is healthy, the 2n -1 requests are redundant because we generally only need a maximum of 2. (One to some node and another to who that node reports is the leader).

So this PR adds the WithConcurrentLeaderConns option to each of client, driver, and app. The default value will remain 10 as before.

In particular for app and driver, the value is actually recorded as a pointer so that a project can dynamically grow and shrink the maximum concurrent connections that will be maintained when probing for the leader during the role adjustment interval.

The idea here is that the hook from #301 can be used to check the deviation in node response times after each role adjustment, and then increment or decrement the maximum connections that the cluster can tolerate.

@cole-miller
Copy link
Contributor

Making the concurrency limit configurable seems reasonable to me; I'd also be totally fine lowering the default from 10 if that works better for LXD.

@masnax masnax force-pushed the configure-max-conns branch from c6c51bc to 0e722f1 Compare July 9, 2024 21:50
Copy link
Contributor

@cole-miller cole-miller left a comment

Choose a reason for hiding this comment

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

Only one minor comment, otherwise this looks good!

masnax added 3 commits July 10, 2024 16:09
These are made to be pointers so that they can be dynamically assigned
based on cluster health from the last check.

Signed-off-by: Max Asnaashari <[email protected]>
@masnax masnax force-pushed the configure-max-conns branch from 0e722f1 to 3727522 Compare July 10, 2024 16:10
@cole-miller cole-miller merged commit 54a06be into canonical:master Jul 10, 2024
37 checks passed
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