Skip to content

fix(feeder): rate-limit drop logs to prevent memory spikes#2721

Merged
Aryan-sharma11 merged 1 commit into
kubearmor:mainfrom
AryanBakliwal:fix-mem-usage
Jun 30, 2026
Merged

fix(feeder): rate-limit drop logs to prevent memory spikes#2721
Aryan-sharma11 merged 1 commit into
kubearmor:mainfrom
AryanBakliwal:fix-mem-usage

Conversation

@AryanBakliwal

@AryanBakliwal AryanBakliwal commented Jun 30, 2026

Copy link
Copy Markdown
Member

Purpose of PR?:
During high-event loads (e.g., thousands of events per second) where connected clients cannot consume the stream fast enough, the Feeder's internal client broadcast channels fill up. The previous implementation executed

kg.Printf("log channel busy, log dropped.")

for every single dropped event.
Spamming the standard output logger thousands of times per second resulted in the KubeArmor's memory usage spike exponentially.

This PR adds a counter to track dropped logs, printing a single warning for every 10,000 dropped logs to prevent memory spikes.

Fixes #

Does this PR introduce a breaking change?
No

If the changes in this PR are manually verified, list down the scenarios covered:
image

Additional information for reviewer? :
Mention if this PR is part of any design or a continuation of previous PRs

Checklist:

  • Bug fix. Fixes #
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • PR Title follows the convention of <type>(<scope>): <subject>
  • Commit has unit tests
  • Commit has integration tests

Comment thread KubeArmor/feeder/feeder.go

@nyrahul nyrahul left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@Aryan-sharma11 Aryan-sharma11 merged commit c918a46 into kubearmor:main Jun 30, 2026
20 checks passed
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.

4 participants