feat(bigtable): Add experimental Bigtable connection pool with custom load balancing strategy. #12882
Conversation
… load balancing strategy
igorbernstein2
requested changes
Sep 29, 2025
bigtable/bigtable.go
Outdated
| executeQueryRetryOption = clientOnlyExecuteQueryRetryOption | ||
| } | ||
|
|
||
| enableBigtableConnPool, _ := strconv.ParseBool(os.Getenv("ENABLE_BIGTABLE_CONN_POOL")) |
Contributor
There was a problem hiding this comment.
Please align naming with googleapis/java-bigtable#2667
Contributor
There was a problem hiding this comment.
Also consider putting wrapping this in a function in internal/option/option.go so that all options and env vars are co-located instead of sprinkled
Contributor
There was a problem hiding this comment.
can you move the env extraction to option.go?
| } | ||
|
|
||
| // Num returns the number of connections in the pool. | ||
| func (p *LeastLoadedChannelPool) Num() int { |
Contributor
Author
There was a problem hiding this comment.
The interface requires Num().
| // Mutex is only used for selecting the least loaded connection. | ||
| // The load array itself is manipulated using atomic operations. | ||
| mu sync.Mutex | ||
| dial func() (*grpc.ClientConn, error) |
Contributor
Author
There was a problem hiding this comment.
dial is used for creating connPool with correct client Options
igorbernstein2
requested changes
Oct 14, 2025
bigtable/bigtable.go
Outdated
| executeQueryRetryOption = clientOnlyExecuteQueryRetryOption | ||
| } | ||
|
|
||
| enableBigtableConnPool, _ := strconv.ParseBool(os.Getenv("ENABLE_BIGTABLE_CONN_POOL")) |
Contributor
There was a problem hiding this comment.
can you move the env extraction to option.go?
igorbernstein2
previously approved these changes
Oct 15, 2025
bhshkh
previously approved these changes
Oct 16, 2025
bhshkh
approved these changes
Oct 16, 2025
bhshkh
added a commit
that referenced
this pull request
Dec 15, 2025
PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release. Librarian Version: v0.7.0 Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-go@sha256:718167d5c23ed389b41f617b3a00ac839bdd938a6bd2d48ae0c2f1fa51ab1c3d <details><summary>bigtable: 1.41.0</summary> ## [1.41.0](bigtable/v1.40.1...bigtable/v1.41.0) (2025-12-15) ### Features * add PeerInfo proto in Bigtable API (PiperOrigin-RevId: 829585900) ([185951b](185951b3)) * precompute featureflags in client and reuse (#13297) ([3b3253a](3b3253ac)) * Add experimental Bigtable connection pool with custom load balancing strategy. (#12882) ([7aa9612](7aa96127)) * Enable ALTS hard bound token in Bigtable w/ direct access (#13153) ([9023934](90239341)) * Enable routing cookie and attempt headers for enhanced retries (#12964) ([96cfd47](96cfd47a)) ### Bug Fixes * fix project id sent in otel (#13286) ([4865868](4865868c)) * screaming uppercase metric status (#13484) ([b35ee8f](b35ee8fd)) ### Performance Improvements * parallelize the exportTimeSeries function (#13004) ([bafd691](bafd691d)) </details>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LeastLoadedChannelPool, which manages a set of gRPC connections. It implements a custom load balancing strategy that routes new requests (both unary Invoke calls and NewStream calls) to the connection with the fewest currently active requests. This load is tracked atomically for each connection in the pool.
bigtable/internal/transport/connpool.go: Contains the implementation of the LeastLoadedChannelPool.
bigtable/internal/transport/connpool_test.go: Adds unit tests for the new connection pool and its load-balancing logic.