Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

InflightReadsLimiter - limit the memory used by reads end-to-en #5920

Conversation

liangyepianzhou
Copy link

Fixes #xyz

Main Issue: #xyz

PIP: #xyz

Motivation

Modifications

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

eolivelli and others added 5 commits September 25, 2023 21:44
…m storage/cache to the write to the consumer channel) (apache#18245)

* InflightReadsLimiter - limit the memory used by reads end-to-end (from storage/cache to the write to the consumer channel)

Motivation:

Broker can go out of memory due to many reads enqueued on the PersistentDispatcherMultipleConsumers dispatchMessagesThread (that is used in case of dispatcherDispatchMessagesInSubscriptionThread set to true, that is the default value)
The limit of the amount of memory retained due to reads MUST take into account also the entries coming from the Cache.

When dispatcherDispatchMessagesInSubscriptionThread is false (the behaviour of Pulsar 2.10) there is some kind of natural (but still unpredictable!!) back pressure mechanism because the thread that receives the entries from BK of the cache dispatches immediately and synchronously the entries to the consumer and releases them

Modifications:

- Add a new component (InflightReadsLimiter) that keeps track of the overall amount of memory retained due to inflight reads.
- Add a new configuration entry managedLedgerMaxReadsInFlightSizeInMB
- The feature is disabled by default
- Add new metrics to track the values

* Change error message

* checkstyle

* Fix license

* remove duplicate method after cherry-pick

* Rename onDeallocate

(cherry picked from commit 6fec66b)
(cherry picked from commit 47c98e5)
@liangyepianzhou
Copy link
Author

liangyepianzhou#1

@liangyepianzhou liangyepianzhou merged commit 74dca67 into streamnative:branch-2.10.5.4-681bb8 Sep 28, 2023
mattisonchao pushed a commit that referenced this pull request Dec 28, 2023
* InflightReadsLimiter - limit the memory used by reads end-to-end (from storage/cache to the write to the consumer channel) (apache#18245)

* InflightReadsLimiter - limit the memory used by reads end-to-end (from storage/cache to the write to the consumer channel)

Motivation:

Broker can go out of memory due to many reads enqueued on the PersistentDispatcherMultipleConsumers dispatchMessagesThread (that is used in case of dispatcherDispatchMessagesInSubscriptionThread set to true, that is the default value)
The limit of the amount of memory retained due to reads MUST take into account also the entries coming from the Cache.

When dispatcherDispatchMessagesInSubscriptionThread is false (the behaviour of Pulsar 2.10) there is some kind of natural (but still unpredictable!!) back pressure mechanism because the thread that receives the entries from BK of the cache dispatches immediately and synchronously the entries to the consumer and releases them

Modifications:

- Add a new component (InflightReadsLimiter) that keeps track of the overall amount of memory retained due to inflight reads.
- Add a new configuration entry managedLedgerMaxReadsInFlightSizeInMB
- The feature is disabled by default
- Add new metrics to track the values

* Change error message

* checkstyle

* Fix license

* remove duplicate method after cherry-pick

* Rename onDeallocate

(cherry picked from commit 6fec66b)
(cherry picked from commit 47c98e5)

* [fix][broker][branch-2.10] limit the memory used by reads end-to-end

(cherry picked from commit eeb80e1)

* remove gpg plugin

* remove release profile

* remove release plugin

* Revert "remove release plugin"

This reverts commit 20522ea.

* Revert "remove release profile"

This reverts commit 64627fd.

* Revert "remove gpg plugin"

This reverts commit 8054d59.

---------

Co-authored-by: Enrico Olivelli <eolivelli@apache.org>
@lhotari
Copy link
Member

lhotari commented Feb 21, 2024

Is there any difference compared to apache#18245 ?

@lhotari
Copy link
Member

lhotari commented Feb 21, 2024

@liangyepianzhou @codelipenghui I think that apache#17241 would also be needed to address problems. There might also be other PRs that are relevant. That's why it would be better if users would try to migrate to Pulsar 3.0.x instead of trying to patch 2.10.x to support end-to-end back pressure. There are multiple gaps in 2.10.x .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants