Repository navigation
ContextPIP-82: Tenant and Namespace Level Rate Limiting introduced Resource Groups as a way to apply rate limits across all topics of a tenant or namespace, no matter how many topics it contains. The proposal covers:
As far as I can tell from the current code base and documentation, the actual implementation is smaller:
If I've missed something, for example a later PR or PIP that covers this, please point me to it. Questions
Our use caseWe run a shared, multi-tenant Pulsar cluster and need to keep specific tenants within publish and dispatch rate quotas. Today we can't cap a tenant's total throughput, so from time to time one or more tenants put heavy load on the cluster. When this happens:
The per-topic and per-subscription limits that exist today don't solve this. A tenant can spread its load over many topics, subscriptions and namespaces, so no single limit is reached while the total load still overwhelms the brokers and bookies. What we need is aggregate enforcement: ideally per tenant, as PIP-82 describes, and at least per namespace as a first step, for both publish and dispatch. Environment: Pulsar version Thanks! Sources: |
Replies: 2 comments
|
This is a broad question to answer. Resource Groups don't really solve the complete problem of QoS in Pulsar. Current stateThe work to improve QoS in Pulsar has been delayed. The Pulsar 4.0 announcement blog post contains some context about the planned future improvements. In that blog post, the assumption was that admission control could be handled primarily with rate limits, as is done with the existing PIP-82. However, a rate-limit-based approach alone cannot solve the challenges. The next detail to address is the lack of produce backpressure in Pulsar. I have a WIP PIP document at https://github.com/lhotari/pulsar/blob/lh-produce-backpressure/pip/pip-produce-backpressure-WIP.md, which has a lot of background context and details. It's Claude-generated with human assistance, so due to its length it isn't really readable. Pulsar (including 5.0.0) also contains some areas that perform poorly today: tiered storage and topic compaction. Those are resource-heavy, and there's potential to reduce the load on the cluster significantly once they have been optimized. Topic compaction also isn't currently fully covered by a backpressure solution, and therefore it can cause broker crashes. Future stateAdapting to the actual capacity, for example by inspecting queue sizes and service time, and implementing adaptive limits is how the available capacity can be shared. Dynamically adjusted rate limiters can be used as part of this. The first goal would be to have "adaptive throttling", so that the Pulsar broker wouldn't crash under load. This requires "backpressure", which is about flow control. It would be possible to improve PIP-82's rate limiting so that the cluster-wide tenant-level and dispatch limits would also be enforced. However, since that anyway requires solving backpressure and preventing broker overload to avoid crashes, backpressure should be fixed first. Fixing backpressure also makes it possible to use the available infrastructure resources most efficiently, without needing to provision for peak workloads, since there would be ways to "smooth the peaks" (as the batch job example below shows). Once proper admission control has been implemented, it should be possible to set weights for tenants and for different workloads. For batch-job-like consumers and producers, low latency isn't a requirement, and throughput isn't a hard requirement either, as long as the flow control can adjust to the available capacity. The produce backpressure WIP document contains details about why this isn't currently the case. For real-time use cases, there should be a way to prioritize the workload and also to start shedding traffic by sampling or dropping data when producing cannot keep up. Some real-time sources cannot stop the data from flowing, and the only option is to drop some data if the producer cannot keep up. There's currently no easy way to implement this with Pulsar (it's possible, but it requires additional solutions on the client side). Pulsar 5.0 has significant performance improvements, and more are coming. Coding agents can drive the Pulsar Performance Testing Framework with the AGENTS.md instructions and create automated experiments to make improvements. This is an extremely powerful tool for continuing to improve Pulsar's performance. Mitigations available todayBroker memory limits and cache. The PIP-442 document explains the current memory-based backpressure controls. In your case, you should first ensure that you have them in place. For example, Producers and clients. Since producers are usually the main source of problems, one way to currently address the problem is to set explicit Upgrade to Pulsar 5.0. It's recommended to go with Pulsar 5.0 (5.0.1 will be released very soon). Before Pulsar 5.0, the cache can consume significantly more memory than the configured setting. Pulsar 5.0 isn't only about scalable topics, and it's safe to upgrade from Pulsar 4.x to 5.0. There are more details in the Pulsar 5.0 release highlights and in the Pulsar 5.0 announcement blog post. Users who don't want to start using the new features can opt out (for example with Capacity. Until the problem has been resolved, the best approach to deal with it is to overprovision the cluster. Pulsar already supports "broker isolation", where you can reserve specific brokers to serve only certain tenants. The problem with this is that it's an overprovisioning solution where you reserve extra capacity. A potentially better approach is to add more capacity to the whole cluster so that it can handle the peak workloads. Upgrading to Pulsar 5.0 is also a way to add capacity without adding more infrastructure resources, thanks to its performance improvements. |
@Goodkat Would you like to contribute a performance scenario to Pulsar's Performance testing framework that reproduces your issue and simulates your workload in the IoT domain that has been chosen as explained in the testing strategy. I'd like to avoid synthetic workloads in the scenarios so adapting a workload pattern to the IoT domain with a good background story is the current approach there. The scale of your workload doesn't need to be exposed. Most workloads can be down scaled to demonstrate the performance issues which occur in an actual much higher scale in production. You could use statistics from your own environment like batch message (entry) size variance, batch sizing etc. to find a way to simulate a similar type of workload. Downsizing the message sizes wouldn't make sense so that would be useful to keep at similar sizing as it's in your use cases. |
This is a broad question to answer. Resource Groups don't really solve the complete problem of QoS in Pulsar.
Current state
The work to improve QoS in Pulsar has been delayed. The Pulsar 4.0 announcement blog post contains some context about the planned future improvements. In that blog post, the assumption was that admission control could be handled primarily with rate limits, as is done with the existing PIP-82. However, a rate-limit-based approach alone cannot solve the challenges.
The next detail to address is the lack of produce backpressure in Pulsar. I have a WIP PIP document at https://github.com/lhotari/pulsar/blob/lh-produce-backpressure/pip/pip-produce-backpressure-WIP.md, whic…