The problem
TCP buffers fill. Sender's socket write blocks or queues. Application queue behind that grows unbounded. Eventually OOM.
Advertisement
Detection
Send queue depth is your key metric. Emit as a metric. Alert when non-zero for >5 seconds.
Advertisement
Bounded queue + drop policy
// Bound the outgoing queue; drop oldest when full
if (outQueue.size() >= MAX_QUEUE) {
outQueue.poll(); // drop oldest
droppedCounter.increment();
}
outQueue.offer(message);