pubsub: Allow Receivers to manually pause/resume message streaming #11136
Labels
api: pubsub
Issues related to the Pub/Sub API.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
Is your feature request related to a problem? Please describe.
There are two main methods of flow control today:
ReceiveSettings.MaxOutstandingBytes
ReceiveSettings.MaxOutstandingMessages
These are sufficient for many workloads, maybe even most. But we have workloads where the message count itself isn't a great indicator of how much the system can handle.
Two examples of this:
Disabling outstanding messages works, but then we have zero control. I'd love to provide my own back pressure.
Describe the solution you'd like
I'm not sure what the most ergonomic way in the current design would be.
pubsub.Pause(ctx)
from a receiving function feels too hidden; though convenient. Giving a callback that is called before pulling other messages down to see how many more it can tolerate could work. Or even a simple "yes, I'm ready for more" or "no, I'm still busy".Describe alternatives you've considered
sub.Receive
when wanting to pause, starting it up again when wanting to resume.msg.Ack()
/msg.Nack()
outside of receive.msg.Nack()
to signal being too busyI suppose we could switch to
apiv1.SubscriberClient.Pull
. The main downside there is we have a lot of prior-art internally around the streaming SDK. Changing our main interface for getting messages would involve a lot more "specialness" about these few systems. I guess that's more of a "me" problem, but still worth pointing out I guess. :)Additional context
Without having some manual say into flow control, it's difficult to do capacity management on systems that aren't simple stream in -> batch out. This would be a very appreciated feature!
The text was updated successfully, but these errors were encountered: