Skip to content

Conversation

@sigfawn
Copy link

@sigfawn sigfawn commented Jan 2, 2026

This PR prevents memory exhaustion (OOM) in the Audit Logger service during high-velocity logging events.

1. Backpressure Handling

  • Problem: The logger was ignoring the return value of stream.write(). In scenarios like DDOS attacks or high-traffic bursts, logging thousands of events per second filled the Node.js internal buffer faster than it could be flushed to disk, causing massive memory spikes (verified 170MB+ in seconds).
  • Fix: Implemented a check for stream.write() return value. If it returns false (buffer full), the logEvent method now awaits the 'drain' event before proceeding.
  • Impact: This applies natural backpressure to the application. If disk I/O is saturated, API handlers waiting on logEvent will pause, preventing the process from crashing.

Result: Stable memory usage under high load.

@sigfawn sigfawn closed this by deleting the head repository Jan 11, 2026
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.

1 participant