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
spanner: Session Pool Configuration #1683
Comments
Hi @LiHaoTan You normally do not have to manually configure the session pool. In most cases the default settings will work well, and you can safely use the If you do need to supply a custom session pool configuration, or other Spanner client configuration, you should create your client using the config := ClientConfig{
SessionPoolConfig: SessionPoolConfig{
MaxOpened: 1000,
},
}
formattedDatabase := fmt.Sprintf("projects/%s/instances/%s/databases/%s", "[PROJECT]", "[INSTANCE]", "[DATABASE]")
client, err := spanner.NewClientWithConfig(ctx, formattedDatabase, config) |
Thank you for your reply. Also sorry for my unclear phrasing but with regards to configuring the session pool I was actually asking how we should tune the session pool. For instance (a completely artificial example), assuming I am going to do 2,000 concurrent reads a second, and I am using 10 Kubernetes pods, then should I set it I understand that I should profile my application to figure things out but just wondering if there are some general guidelines. |
Thanks for the clarification. As always with these things, the answer depends on the circumstances. The most important general rule of thumb is: Set Furthermore, the following applies:
|
Thank you so much for your explanation! |
Closing this issue as hopefully the above note has provided the information you needed. Please feel free to reopen if something is not clear. |
What is discussed in this issue is the meaning of the settings as of v1.1.0.
|
See inline replies.
The meaning of
The meaning of
Correct. This setting does not have any function anymore, and is only kept around to prevent compilation failures in existing applications.
Correct.
Correct, and good spot on the missing change to the godoc. I'll update that.
Correct. The change from
Correct, the meaning and behavior of this option has not changed. It is a setting that is normally not needed, and in most cases it's better to just use a higher
All the above is correct. This setting is still used in the Go client library to maintain a number of write-prepared sessions in the pool, and it can be useful to tweak this value if your application has a significantly different read/write ratio than reflected in this setting. |
Thanks for answering! |
FYI for readers: v1.43.0(#7149) has introduced the inline begin transaction for ReadWriteTransactions and |
I am trying to understand when it is required to manually configure the session pool.
I read the session docs and it appears to say that only creators of client libraries need to manage sessions manually. However, one way of interpreting that means that I should still set the session pool config appropriately, and the client library will manage the sessions according to what I want to achieve.
In the recent changelog, I see that
spanner.NewClient
is created with a minimum of 100 opened sessions by default now.Am I right to say that in many cases the default config will work well, or do I need to use my own config for better performance?
I am also not sure but it seems I used to see Spanner documentation on how to configure the session pool configuration, for example
MaxOpened
. I can't seem to find that anymore, and the godoc doesn't appear to explain that.The text was updated successfully, but these errors were encountered: