Closed sjy-dv closed 9 months ago
Sessions in Cloud Spanner and connections in traditional relational databases are different, however they do have some similarities. The best way to view it is like this:
So as a rule of thumb, you should have as many sessions in your session pool as the number of concurrent transactions that your client will execute in parallel. Note that a transaction in this case in also includes read-only transactions, as the Spanner client will use one session from the pool for each transaction that it executes.
You write that a single Cloud Spanner node can execute 1,000 queries, but that number is incorrect. The correct number is 22,500. See https://cloud.google.com/spanner/docs/performance#increased-throughput. Note that the maximum throughput is in an ideal case, and that in the real world with an application that is executing both reads and writes at the same time, and where not all reads are simple reads selecting a single row using the primary key, the number will be lower.
Sessions are unrelated to the number of Cloud Spanner nodes. You should determine the number of sessions that you need in your client based on what your client will be doing. A couple of extreme examples:
I fully understand that one gRPC channel can handle up to 100 sessions.
If a single Google Spanner node can perform 1000 concurrent queries, does this mean that one node is equivalent to 1000 sessions?
Spanner, unlike traditional databases, uses the concept of sessions rather than connections. However, due to similar mechanisms like session pools and connection pools, it's often confusing whether sessions and connections are the same thing. Is a session the same as a connection?