feat: replace thread-per-consumer pub/sub with async receive pool - #1065
Merged
Conversation
Eliminate the thread-per-consumer model that causes thread exhaustion at scale (40+ workspaces × 4 flows ≈ 480 OS threads) by migrating to pulsar.asyncio.Client with fully async receive loops. Core infrastructure: - Add AsyncPulsarBackend using pulsar.asyncio.Client for native async - Add ReceiverPool: shared work queue with configurable worker count - Add SenderPool: async producer dispatch with drain-on-stop - Add RequestResponseClient with streaming support (request_stream) - Add AsyncConfigClient and AsyncRequestResponseWrapper for service use Migration: - Migrate all core services to AsyncProcessor (config, flow, IAM, librarian, cores, bootstrapper, metering) - Replace Subscriber/Consumer inheritance with ReceiverPool registrations - Replace Producer send with SenderPool handles - Use BaseException throughout for pulsar.asyncio.PulsarException compatibility (inherits BaseException, not Exception) - Close-before-cancel shutdown pattern for async Pulsar consumers Includes tech spec: docs/tech-specs/async-receive-threading.md
Contributor License Agreement ✅All contributors have signed the CLA. Thank you! |
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.
Eliminate the thread-per-consumer model that causes thread exhaustion at scale (40+ workspaces × 4 flows ≈ 480 OS threads) by migrating to pulsar.asyncio.Client with fully async receive loops.
Core infrastructure:
Migration:
Includes tech spec: docs/tech-specs/async-receive-threading.md