Handling over 100,000 concurrent network sockets on a single Linux host requires non-blocking I/O multiplexing via epoll. However, deciding between Level-Triggered (LT) and Edge-Triggered (ET / EPOLLET) modes dictates how the kernel notifies user space, impacting context switch frequency, buffer read loops, and thread pool starvation under burst traffic.
The Architecture of epoll Event Readiness
How the Linux kernel tracks socket readiness inside the red-black tree and ready list:
Edge-Triggered mode emits an event notification ONLY when the socket state transitions from not-ready to ready. If user space fails to drain the kernel receive buffer completely until EAGAIN or EWOULDBLOCK is returned, the remaining bytes will stall indefinitely, causing deadlocked client connections.
epoll Notification Modes Compared
| epoll Polling Mode | Notification Trigger | Syscall Frequency | Starvation Vulnerability |
|---|---|---|---|
| Level-Triggered (Default) | Continuously while buffer has data | Higher (Re-notifies on partial read) | Low (Fair round-robin reads) |
| Edge-Triggered (EPOLLET) | State changes (New arrival only) | Minimal (Single wakeup per burst) | High (Requires read quota loops) |
| EPOLLET + EPOLLONESHOT | One worker thread per event | Moderate (Requires epoll_ctl re-arm) | Zero (Thread-safe worker pools) |
Non-Blocking Drain Loop with Read Quota in TypeScript
Preventing thread starvation while draining edge-triggered socket descriptors:
export interface DrainResult {
bytesRead: number;
isEAGAIN: boolean;
quotaExceeded: boolean;
}
export function drainEdgeTriggeredSocket(
fd: number,
readChunkFn: (fd: number) => { bytes: number; isEagain: boolean },
maxBytesQuota: number = 65536
): DrainResult {
let totalBytes = 0;
while (totalBytes < maxBytesQuota) {
const { bytes, isEagain } = readChunkFn(fd);
if (isEagain) return { bytesRead: totalBytes, isEAGAIN: true, quotaExceeded: false };
if (bytes <= 0) break;
totalBytes += bytes;
}
return { bytesRead: totalBytes, isEAGAIN: false, quotaExceeded: totalBytes >= maxBytesQuota };
}
Explore Advanced Linux Kernel & Cloud Infrastructure
Architect high-throughput socket gateways. Read our guide on Linux Kernel io_uring Zero-Copy Sockets, explore jemalloc memory arena purging on WebDesigner.la Systems Lab, review Louvain directory clustering on LinkDepot Graph Engineering, or deploy dedicated bare-metal servers.
