apache / pulsar

Apache Pulsar - distributed pub-sub messaging system
https://pulsar.apache.org/
Apache License 2.0
14.18k stars 3.57k forks source link

Feature Request: Add option for isolated connections for Pulsar consumers and producers #23403

Open lhotari opened 5 days ago

lhotari commented 5 days ago

Motivation

Currently, in Pulsar, TCP connections are shared across all consumers and producers for a client. This can lead to issues with backpressure and flow control, particularly for producers. The shared connection usage causes head-of-line blocking problems. To address this, it is proposed to add configuration options to allow consumers and producers to use isolated TCP/IP connections or connection groups.

Benefits

This feature provides a simple improvement in connection management and performance isolation, which can be implemented as an interim solution or alongside more comprehensive flow control mechanisms such as PIP-385.

Additional Context

lhotari commented 5 days ago

@grssam Thanks for your work on PIP-385 to improve rate limiting and flow control. Have you considered adding an option for isolated connections as well? This has been discussed several times in relation to rate limiters and could complement PIP-385 nicely. While PIP-385 will significantly improve the "head-of-line blocking" problem by adding rate limit semantics to the protocol, it won't completely eliminate the queuing that inherently occurs in a TCP connection. For certain high-priority or latency-sensitive use cases, having the ability to isolate producers or consumers on dedicated connections could be valuable. I understand there's a tradeoff with increased connection count, but for some scenarios, that may be an acceptable cost for improved isolation and predictability. WDYT?

grssam commented 5 days ago

@grssam Thanks for your work on PIP-385 to improve rate limiting and flow control. Have you considered adding an option for isolated connections as well? This has been discussed several times in relation to rate limiters and could complement PIP-385 nicely. While PIP-385 will significantly improve the "head-of-line blocking" problem by adding rate limit semantics to the protocol, it won't completely eliminate the queuing that inherently occurs in a TCP connection. For certain high-priority or latency-sensitive use cases, having the ability to isolate producers or consumers on dedicated connections could be valuable. I understand there's a tradeoff with increased connection count, but for some scenarios, that may be an acceptable cost for improved isolation and predictability. WDYT?

For specific known high priority topics, can't the users simply create separate client? my PIP tries to solve the overall problem holistically in a default situation along with adding the protocols to notify the clients.. .. but for certain specific limited sub-set which has higher priority and needs separate connection, it can already be solved today..

lhotari commented 5 days ago

For specific known high priority topics, can't the users simple not create separate client?

@grssam Good point. Yes, that's possible. There's a proposal to make it easier "PIP-234: Support using shared thread pool across multiple Pulsar client instance" #19074. That would be an alternative solution. I think it would be good to finally implement PIP-234.

my PIP tries to solve the overall problem holistically in a default situation.. but for certain specific limited sub-set it can already be solved today..

Yes that's true. I'm not saying that isolation would be a replacement for PIP-385. We need a producer flow control solution in the Pulsar binary protocol. That has been in discussions for a very long time and I appreciate that you are driving the efforts to finally act and make it happen.

grssam commented 5 days ago

For specific known high priority topics, can't the users simple not create separate client?

@grssam Good point. Yes, that's possible. There's a proposal to make it easier "PIP-234: Support using shared thread pool across multiple Pulsar client instance" #19074. That would be an alternative solution. I think it would be good to finally implement PIP-234.

Sorry, I updated my original reply a bit later. I realized i was doing double negatives. what I meant was actually that for higher priority topics, users can always create a separate client instead of using the client that spins up producers for the rest of the topics