How can I control the number of sessions per grpc channel in spanner?
See original GitHub issueHello!
The document says We also recommend having no more than 100 sessions per gRPC channel
.
https://cloud.google.com/spanner/docs/sessions?hl=en
I couldn’t figure out how to control this using Google.Cloud.Spanner.Data.
Do I just specify MaximumActiveSessions and MaximumGrpcChannels when creating the SpannerConnection?
For example, if I use a SpannerConnection generated as follows, will I be limited to 100 sessions per channel?
var sessionOptions = new SessionPoolOptions
{
MaximumActiveSessions = 2000,
};
var sessionPoolManager = SessionPoolManager.Create(sessionOptions);
var spannerConnectionStringBuilder = new SpannerConnectionStringBuilder
{
DataSource = $"MyDataBase",
MaximumGrpcChannels = 20,
SessionPoolManager = sessionPoolManager,
};
var spannerConnection = new SpannerConnection(spannerConnectionStringBuilder);
Thank you.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Sessions | Cloud Spanner
Configuring the number of sessions and gRPC channels in the pools ... The client libraries have a default number of sessions in the...
Read more >Spanner sessions/channels recommendation needed #4961
Hi Spanner team I want to know whats the recommended configuration required for min / max sessions on spanner. whats the ideal count...
Read more >SpannerClient - Documentation
The Cloud Spanner API can be used to manage sessions and execute transactions on data stored in Cloud ... Terminate the gRPC channel...
Read more >Performance best practices with gRPC
Use a pool of gRPC channels, for example, create a list of gRPC channels. Random is used to pick a channel from the...
Read more >Sessions | Cloud Spanner - Price 2 Meet
A session represents a communication channel with the Cloud Spanner ... 100 is the maximum number of concurrent sessions per gRPC channel.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@y-nishine: Great! In that case, I’ll close this issue for now… but if you have further questions on this topic, or experience any difficulties, please add another comment and we can reopen it.
The exact channel allocation process is somewhat tricky. The code you’ve got there won’t guarantee 100 sessions per channel, but it will sort of aim for it. When a CreateSession request is issued, that will be allocated to the least-loaded existing channel… but looking at the code, it looks like that’s based on current active requests rather than sessions allocated to that channel.
Now of course, we shouldn’t be creating more sessions if there are idle ones (at least once we’ve reached a reasonably steady state) but it does mean they may not be evenly allocated. Batch allocation of sessions makes this even more complex, unfortunately.
I think the configuration you’ve specified there is a reasonable one - assuming you really need that many active sessions at all, of course - but it’s not a guarantee. You could increase the maximum number of gRPC channels (e.g. to 30 or 40) to reduce the average number per channel, potentially.