Skip to content

About

Linux C++17 high-performance TCP server: main/sub Reactor + Epoll ET + memory pool + connection-pool heartbeat + half/sticky packet handling, 100k+ concurrent connections

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

22 Commits

Folders and files

Repository files navigation

High-Performance TCP Server

Linux C++17 main/sub-reactor architecture — Epoll ET + memory pool + connection pool heartbeat + half/sticky packet handling.

What it solves

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.

Tech stack

C++17 · CMake · Linux Epoll ET · main/sub reactor · custom memory pool / thread pool

Features

  • 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_wait calls

Benchmark

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%

Benchmark screenshot Benchmark screenshot

Usage

./build.sh
./build/bin/tcp_server -p 9999

# Test
nc 127.0.0.1 9999

About

Linux C++17 high-performance TCP server: main/sub Reactor + Epoll ET + memory pool + connection-pool heartbeat + half/sticky packet handling, 100k+ concurrent connections

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages