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

derive Spanner default gRPC connection count from GOMAXPROCS #1622

Merged
merged 1 commit into from
Oct 27, 2023

Conversation

vroldanbet
Copy link
Contributor

@vroldanbet vroldanbet commented Oct 27, 2023

at some point when it was moved to connection pools, we set the default to 4, but before it used pools, it was using just one connection, so this reverts that regression on the defaults when the pool was introduced.

@vroldanbet vroldanbet requested a review from a team as a code owner October 27, 2023 12:45
@vroldanbet vroldanbet self-assigned this Oct 27, 2023
@vroldanbet vroldanbet changed the title derive Spanner gRPC connection count from GOMAXPROCS derive Spanner default gRPC connection count from GOMAXPROCS Oct 27, 2023
@github-actions github-actions bot added the area/datastore Affects the storage system label Oct 27, 2023
@@ -37,14 +37,17 @@ const (
type Option func(*spannerOptions)

func generateConfig(options []Option) (spannerOptions, error) {
// originally SpiceDB didn't use connection pools for Spanner SDK, so it opened 1 single connection
// This determines if there are more CPU cores to increase the default number of connections
defaultNumberConnections := max(1, math.Round(float64(runtime.GOMAXPROCS(0)/2.0)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you set to maxprocs/2 to leave more room for non-spanner work?

The docs say:

Increasing the size of the session pool beyond the maximum number of threads that a single application instance can handle is not recommended. Instead, increase the number of application instances.

So I would think just setting to GOMAXPROCs is a fine default. (This quote says session pool but from context they mean connection count)

Copy link
Contributor Author

@vroldanbet vroldanbet Oct 27, 2023

Choose a reason for hiding this comment

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

Did you set to maxprocs/2 to leave more room for non-spanner work?

Because I don't know if folks are running lots of replicas and this could open a whole lot of connections to Spanner, so tried to be more conservative. I feel like GFE should be able to handle it but 🤷🏻

So I would think just setting to GOMAXPROCs is a fine default. (This quote says session pool but from context they mean connection count)

Yep! I agree that's the recommendation, it's just not sure how it's going to affect existing deployments

Updated it to use GOMAXPROCS

at some point when it was moved to connection pools, we set
the default to 4, but before it used pools, it was using
just one connection, so this reverts that regression on the
defaults when the pool was introduced.
@josephschorr josephschorr added this pull request to the merge queue Oct 27, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 27, 2023
@josephschorr josephschorr added this pull request to the merge queue Oct 27, 2023
Merged via the queue into main with commit 589153e Oct 27, 2023
20 checks passed
@josephschorr josephschorr deleted the spanner-conn-pool-count branch October 27, 2023 18:13
@github-actions github-actions bot locked and limited conversation to collaborators Oct 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/datastore Affects the storage system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants