public int CreateSessionMaximumBatchSize { get; set; }
The maximum number of sessions that will be created in a batch.
Sessions created are associated to the gRPC channel they are created on, so
all sessions created in a batch are associated to the same gRPC channel.
Batch size should be limited so as not to overload a given channel.
If the sessions needing to be created at any given time are more than this value
then multiple batches of this size or less will be created.
This property must always be positive. The default value is 15 minutes.
The exact value used is subject to "jitter" to avoid a lot of sessions being refreshed at the exact same time.
A lower value will cause sessions to be refreshed more often, slightly reducing the risk of sessions expiring
while being used, at the cost of performing more refreshes.
This value must be less than the expire timer on the Spanner server which is currently set at 60 minutes.
MaximumActiveSessions
public int MaximumActiveSessions { get; set; }
Maximum number of sessions that can be active per database. An active session is one that has been
acquired but not yet released back to the pool.
This property has a minimum value of 1, and a default value of 400.
MaximumConcurrentSessionCreates
public int MaximumConcurrentSessionCreates { get; set; }
The maximum number of sessions that will be created concurrently per session pool.
Spanner has limits on the number of sessions that can be created concurrently without affecting performance.
This value is not typically changed.
The minimum number of sessions to maintain in the pool of available sessions.
If the number of pooled sessions falls below this number, more sessions are added automatically.
This property has a minimum value of 0, and a default value of 100.
PoolEvictionDelay
public TimeSpan PoolEvictionDelay { get; set; }
The amount of time before sessions are forcibly evicted from the pool. This is usually in the order of days,
as sessions can be reused for a long time if they're suitably refreshed. Deleting long-lasting sessions
can help with server-side resource management.
The total time allowed for a network call to the Cloud Spanner server, including retries. This setting
is applied to calls to create, refresh and delete sessions, as well as beginning transactions.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe latest version of the \u003ccode\u003eSessionPoolOptions\u003c/code\u003e class is \u003ccode\u003e5.0.0-beta05\u003c/code\u003e, with various previous versions also available for reference, including version numbers ranging from 3.5.0 up to 5.0.0-beta04.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSessionPoolOptions\u003c/code\u003e provides configuration for session management in Google Cloud Spanner, including properties such as \u003ccode\u003eMaximumActiveSessions\u003c/code\u003e, \u003ccode\u003eMinimumPooledSessions\u003c/code\u003e, \u003ccode\u003eIdleSessionRefreshDelay\u003c/code\u003e, \u003ccode\u003ePoolEvictionDelay\u003c/code\u003e, and \u003ccode\u003eTimeout\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe class offers control over session creation with \u003ccode\u003eCreateSessionMaximumBatchSize\u003c/code\u003e and \u003ccode\u003eMaximumConcurrentSessionCreates\u003c/code\u003e, and the behavior when resources are exhausted can be controlled with \u003ccode\u003eWaitOnResourcesExhausted\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSessionPoolOptions\u003c/code\u003e allows to add labels to any sessions that are created using this pool via the \u003ccode\u003eSessionLabels\u003c/code\u003e property, to help keep track of the sessions.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSessionPoolOptions\u003c/code\u003e enables the fine-tuning of session behavior with various timeouts and delays for session refreshing, eviction, and network calls with their respective default values.\u003c/p\u003e\n"]]],[],null,["# Google Cloud Spanner v1 API - Class SessionPoolOptions (5.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [5.1.0 (latest)](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [5.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/5.0.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [4.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.6.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [4.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.5.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [4.4.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.4.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [4.3.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.3.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [4.2.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.2.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [4.1.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.1.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [4.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.0.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [3.15.1](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.15.1/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [3.14.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.14.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [3.13.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.13.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [3.12.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.12.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [3.11.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.11.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [3.10.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.10.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.9.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.8.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.7.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.6.0/Google.Cloud.Spanner.V1.SessionPoolOptions)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.5.0/Google.Cloud.Spanner.V1.SessionPoolOptions) \n\n public sealed class SessionPoolOptions\n\nReference documentation and code samples for the Google Cloud Spanner v1 API class SessionPoolOptions.\n\nOptions for session pools. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e SessionPoolOptions \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Spanner.V1](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.Spanner.V1.dll\n\nConstructors\n------------\n\n### SessionPoolOptions()\n\n public SessionPoolOptions()\n\nConstructs a new [SessionPoolOptions](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SessionPoolOptions) with default values.\n\nProperties\n----------\n\n### CreateSessionMaximumBatchSize\n\n public int CreateSessionMaximumBatchSize { get; set; }\n\nThe maximum number of sessions that will be created in a batch.\nSessions created are associated to the gRPC channel they are created on, so\nall sessions created in a batch are associated to the same gRPC channel.\nBatch size should be limited so as not to overload a given channel.\nIf the sessions needing to be created at any given time are more than this value\nthen multiple batches of this size or less will be created.\n\n**Remarks** \n\nThis value must be positive. The default value is 5.\n\n### IdleSessionRefreshDelay\n\n public TimeSpan IdleSessionRefreshDelay { get; set; }\n\nThe amount of time a session must be idle before it is refreshed.\n\n**Remarks** \n\nThis property must always be positive. The default value is 15 minutes.\n\n\nThe exact value used is subject to \"jitter\" to avoid a lot of sessions being refreshed at the exact same time.\n\n\nA lower value will cause sessions to be refreshed more often, slightly reducing the risk of sessions expiring\nwhile being used, at the cost of performing more refreshes.\n\n\nThis value must be less than the expire timer on the Spanner server which is currently set at 60 minutes.\n\n### MaximumActiveSessions\n\n public int MaximumActiveSessions { get; set; }\n\nMaximum number of sessions that can be active per database. An active session is one that has been\nacquired but not yet released back to the pool.\n\n**Remarks** \nThis property has a minimum value of 1, and a default value of 400.\n\n### MaximumConcurrentSessionCreates\n\n public int MaximumConcurrentSessionCreates { get; set; }\n\nThe maximum number of sessions that will be created concurrently per session pool.\nSpanner has limits on the number of sessions that can be created concurrently without affecting performance.\nThis value is not typically changed.\n\n### MinimumPooledSessions\n\n public int MinimumPooledSessions { get; set; }\n\nThe minimum number of sessions to maintain in the pool of available sessions.\nIf the number of pooled sessions falls below this number, more sessions are added automatically.\n\n**Remarks** \nThis property has a minimum value of 0, and a default value of 100.\n\n### PoolEvictionDelay\n\n public TimeSpan PoolEvictionDelay { get; set; }\n\nThe amount of time before sessions are forcibly evicted from the pool. This is usually in the order of days,\nas sessions can be reused for a long time if they're suitably refreshed. Deleting long-lasting sessions\ncan help with server-side resource management.\n\n**Remarks** \n\nThis property must always be positive. The default value is 7 days.\n\n\nThe exact value used is subject to \"jitter\" to avoid a lot of sessions being evicted at the exact same time.\n\n\nA lower value will cause sessions to be evicted more often, delaying operations if no sessions are available\nwhen requested.\n\n### SessionLabels\n\n public IDictionary\u003cstring, string\u003e SessionLabels { get; }\n\nLabels to use for any sessions created with this pool.\n\n### Timeout\n\n public TimeSpan Timeout { get; set; }\n\nThe total time allowed for a network call to the Cloud Spanner server, including retries. This setting\nis applied to calls to create, refresh and delete sessions, as well as beginning transactions.\n\n**Remarks** \n\nThis value must be positive. The default value is one minute.\n\n### WaitOnResourcesExhausted\n\n public ResourcesExhaustedBehavior WaitOnResourcesExhausted { get; set; }\n\nDetermines the behavior of a request for a session when [MaximumActiveSessions](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SessionPoolOptions#Google_Cloud_Spanner_V1_SessionPoolOptions_MaximumActiveSessions) has been reached.\n\n**Remarks** \nThe default value is [Block](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ResourcesExhaustedBehavior#Google_Cloud_Spanner_V1_ResourcesExhaustedBehavior_Block)."]]