Skip to content

feat(bigtable): Add experimental Bigtable connection pool with custom load balancing strategy. #12882

Merged
sushanb merged 6 commits intomainfrom
lb
Oct 16, 2025
Merged

feat(bigtable): Add experimental Bigtable connection pool with custom load balancing strategy. #12882
sushanb merged 6 commits intomainfrom
lb

Conversation

@sushanb
Copy link
Copy Markdown
Contributor

@sushanb sushanb commented Sep 16, 2025

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.

@sushanb sushanb requested review from a team September 16, 2025 17:27
@product-auto-label product-auto-label bot added the api: bigtable Issues related to the Bigtable API. label Sep 16, 2025
@sushanb sushanb added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 16, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 16, 2025
executeQueryRetryOption = clientOnlyExecuteQueryRetryOption
}

enableBigtableConnPool, _ := strconv.ParseBool(os.Getenv("ENABLE_BIGTABLE_CONN_POOL"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please align naming with googleapis/java-bigtable#2667

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move the env extraction to option.go?

}

// Num returns the number of connections in the pool.
func (p *LeastLoadedChannelPool) Num() int {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. Size()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dial is used for creating connPool with correct client Options

@sushanb sushanb requested review from a team and igorbernstein2 October 8, 2025 06:32
executeQueryRetryOption = clientOnlyExecuteQueryRetryOption
}

enableBigtableConnPool, _ := strconv.ParseBool(os.Getenv("ENABLE_BIGTABLE_CONN_POOL"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move the env extraction to option.go?

igorbernstein2
igorbernstein2 previously approved these changes Oct 15, 2025
bhshkh
bhshkh previously approved these changes Oct 16, 2025
@sushanb sushanb dismissed stale reviews from bhshkh and igorbernstein2 via 3c62267 October 16, 2025 17:34
@sushanb sushanb merged commit 7aa9612 into main Oct 16, 2025
12 checks passed
@sushanb sushanb deleted the lb branch October 16, 2025 18:38
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the Bigtable API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants