Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throttle Kafka consumption to the file writing speed #686

Merged
merged 49 commits into from
Apr 20, 2023

Conversation

danesss
Copy link
Contributor

@danesss danesss commented Apr 3, 2023

Issue

ECDC-3253: We currently read from Kakfa at max speed and buffer into memory, which can cause out-of-memory issues if Kafka is faster than the GPFS filesystem.

Description of work

We adapt the consumption rate to the file writing rate:

  • We add a new configuration setting for the size of write queue --max-queued-writes
  • We add a method in MessageWriter to be able to check current queue size
  • We extend StreamController to
    • Perform a periodic check of the write queue size
    • Pause all consumers for 200ms if queue is larger than configured
  • Topic and Partition classes have new methods to support pause and resume of the consumers.
  • Unit tests are added to verify pause/resume behaviour at the Partition level.

Nominate for Group Code Review

  • Nominate for code review

Reminder

Changes should be documented in changes.md

danesss and others added 2 commits April 3, 2023 16:56
We need to adapt the consumption rate to the file writing rate
to avoid out-of-memory issues due to WriteQueue buffering.
@cow-bot
Copy link
Contributor

cow-bot commented Apr 3, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5590 3771 67%
For more detail see Cobertura report in Jenkins interface

@cow-bot
Copy link
Contributor

cow-bot commented Apr 3, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5590 3778 67%
For more detail see Cobertura report in Jenkins interface

@cow-bot
Copy link
Contributor

cow-bot commented Apr 4, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5590 3774 67%
For more detail see Cobertura report in Jenkins interface

@cow-bot
Copy link
Contributor

cow-bot commented Apr 4, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5590 3781 67%
For more detail see Cobertura report in Jenkins interface

@cow-bot
Copy link
Contributor

cow-bot commented Apr 4, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5590 3774 67%
For more detail see Cobertura report in Jenkins interface

@cow-bot
Copy link
Contributor

cow-bot commented Apr 4, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5590 3780 67%
For more detail see Cobertura report in Jenkins interface

@cow-bot
Copy link
Contributor

cow-bot commented Apr 4, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5600 3781 67%
For more detail see Cobertura report in Jenkins interface

@cow-bot
Copy link
Contributor

cow-bot commented Apr 4, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5603 3775 67%
For more detail see Cobertura report in Jenkins interface

1 similar comment
@cow-bot
Copy link
Contributor

cow-bot commented Apr 4, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5603 3775 67%
For more detail see Cobertura report in Jenkins interface

@cow-bot
Copy link
Contributor

cow-bot commented Apr 4, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5603 3775 67%
For more detail see Cobertura report in Jenkins interface

@cow-bot
Copy link
Contributor

cow-bot commented Apr 4, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5603 3775 67%
For more detail see Cobertura report in Jenkins interface

@cow-bot
Copy link
Contributor

cow-bot commented Apr 12, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5607 3774 67%
For more detail see Cobertura report in Jenkins interface

@cow-bot
Copy link
Contributor

cow-bot commented Apr 15, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5606 3777 67%
For more detail see Cobertura report in Jenkins interface

@cow-bot
Copy link
Contributor

cow-bot commented Apr 15, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5606 3773 67%
For more detail see Cobertura report in Jenkins interface

src/Stream/Partition.h Outdated Show resolved Hide resolved
src/Stream/Partition.h Outdated Show resolved Hide resolved
src/Stream/Topic.h Outdated Show resolved Hide resolved
src/Stream/Topic.h Outdated Show resolved Hide resolved
/// Consumers are stopped when the write queue is larger than
/// StreamerOptions.MaxQueuedWrites. This variable defines the ratio below
/// which the consumers will be resumed.
float const QueuedWritesResumeThreshold{0.8F};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

src/StreamController.h Outdated Show resolved Hide resolved
Copy link
Member

@mattclarke mattclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
I think the names changes and names for new items are a big improvement 👍

@cow-bot
Copy link
Contributor

cow-bot commented Apr 19, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5606 3774 67%
For more detail see Cobertura report in Jenkins interface

@cow-bot
Copy link
Contributor

cow-bot commented Apr 19, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5606 3773 67%
For more detail see Cobertura report in Jenkins interface

1 similar comment
@cow-bot
Copy link
Contributor

cow-bot commented Apr 19, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5606 3773 67%
For more detail see Cobertura report in Jenkins interface

@cow-bot
Copy link
Contributor

cow-bot commented Apr 19, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5606 3774 67%
For more detail see Cobertura report in Jenkins interface

StreamersPaused atomic bool was set externally when throttling consumers,
instead of within the pauseStreamers() method.
It seems reasonable to ensure the mutex is set by making the setter
part of the method.
…cope

StreamersPaused atomic bool was set externally when throttling consumers,
instead of within the pauseStreamers() method.
It seems reasonable to ensure the mutex is set by making the setter
part of the method.
@cow-bot
Copy link
Contributor

cow-bot commented Apr 19, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5606 3774 67%
For more detail see Cobertura report in Jenkins interface

1 similar comment
@cow-bot
Copy link
Contributor

cow-bot commented Apr 19, 2023

Code Coverage
(Lines Exec Cover)
TOTAL 5606 3774 67%
For more detail see Cobertura report in Jenkins interface

@danesss danesss merged commit a31494f into main Apr 20, 2023
@danesss danesss deleted the ECDC-3253_throttle_consumers_to_file_writing_speed branch April 20, 2023 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants