googleapis / java-spanner

Apache License 2.0
55 stars 110 forks source link

feat: support multiplexed sessions for RO transactions #3141

Closed harshachinta closed 2 months ago

harshachinta commented 3 months ago

With multiplexed sessions, the client optimizes and runs multiple applicable requests concurrently on a single session. A single multiplexed session is sufficient to handle all concurrent read-only traffic. Read/write transactions always use regular sessions. This can be enabled through an environment variable GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS.

Session management behavior in Java client,

  1. GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS is set to true - Client uses multiplexed sessions.
  2. GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS is set to false - Client uses regular session cached in the session pool for running 1 concurrent transaction per session.
  3. GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS is not set - Client uses default session management mechanism which is using regular session cached in the session pool.

Note: Multiplexed sessions is unsupported when you use SpannerOption#enableGrpcGcpExtension. Enable multiplexed sessions when gRPC-GCP is unset.

generated-files-bot[bot] commented 3 months ago

Warning: This pull request is touching the following templated files:

harshachinta commented 2 months ago

@harshachinta Check if https://github.com/googleapis/java-spanner/pull/3156 is also a blocker for releasing mux. Reason: https://github.com/googleapis/java-spanner/blob/main/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java#L2971-L2975

olavloite commented 2 months ago

Check if #3156 is also a blocker for releasing mux. Reason: https://github.com/googleapis/java-spanner/blob/main/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java#L2971-L2975

@harshachinta No, it's not a blocker. All of it is dead code, due to the static return false in https://github.com/googleapis/java-spanner/blob/main/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java#L2971-L2975