Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] feat: dynamic channel pool #799

Draft
wants to merge 44 commits into
base: experimental_v3
Choose a base branch
from

Conversation

daniel-sanche
Copy link
Contributor

@daniel-sanche daniel-sanche commented Jun 15, 2023

This PR adds dynamic channel pooling, where channel pools will resize depending on channel usage patterns. To implement this, I moved more logic into grpc channel subclasses, resulting in the following classes:

  • _WrappedChannel: a generic class that holds a grpc channel, and delegates all calls to the wrapped object
  • _BackgroundTaskMixin: an interface/mixin class that provides logic for starting and managing a background task associated with a grpc channel
  • RefreshableChannel: a channel that uses _BackgroundTaskMixin and _WrappedChannel to periodically refresh the wrapped channel, and call a warm up callback when the new channel is set up. This replaces some logic that was currently in the client
  • TrackedChannel: a _WrappedChannel that keeps tracks of the counts number of active rpcs as they are sent
  • PooledChannel: a grpc channel subclass that maintains a static pool of channels, and alternates incoming requests between them. For our use-case, (if we allow static channels) each channel in the pool will be a RefreshableChannel.
  • DynamicPooledChannel: a PooledChannel that wraps each channel in the pool in a TrackedChannel, and maintains a _BackgroundTaskMixin task to periodically change the pool size based on channel usage.

custom_channel drawio


TODO:

  • check performance, make optimizations as needed
    • possible optimizations:
      • create a class that combined RefreshableChannel with TrackedChannel, to cut down on the layers of wrapping
      • create CacheableChannel that saves and returns a cahed MultiCallable, to avoid the overhead of creating one on each call (does grpc already do this internally?)
  • add system tests
  • get full unit test coverage

Later:

  • move most classes in _channel_pooling into api_core, to share with other libraries

@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. api: bigtable Issues related to the googleapis/python-bigtable API. labels Jun 15, 2023
@daniel-sanche daniel-sanche changed the base branch from v3 to experimental_v3 August 30, 2023 20:39
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 googleapis/python-bigtable API. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant