Linux C++17 main/sub-reactor architecture — Epoll ET + memory pool + connection pool heartbeat + half/sticky packet handling.
Understand the core techniques of Linux high-concurrency network programming: the reactor pattern, epoll edge-triggered I/O, memory pools, and packet fragmentation/assembly. Supports 100k+ concurrent connections — a solid reference and project foundation for learning C++ network programming.
C++17 · CMake · Linux Epoll ET · main/sub reactor · custom memory pool / thread pool
- Main/sub reactor: main thread accepts connections, IO thread pool handles reads/writes
- Epoll edge-triggered: works with non-blocking IO
- Memory pool: pre-allocated fixed-size blocks, O(1) allocation
- Connection pool: heartbeat timeout detection, max connection limit
- Half/sticky packet handling: three strategies — line-based, fixed-length, and custom delimiters
- Graceful shutdown: eventfd interrupts all
epoll_waitcalls
Measured with the custom TitanBench tool (local WSL, 500 concurrent / 8 threads / 30 s):
| Metric | Value |
|---|---|
| QPS | 64,756 ~ 70,000+ |
| Average latency | 2.42 μs |
| P99 latency | 7.00 μs |
| Success rate | 100% |
./build.sh
./build/bin/tcp_server -p 9999
# Test
nc 127.0.0.1 9999
