C++Projects

Project: Building a High-Performance Async Web Server with Coroutines & Thread Pool — Phase 4 Capstone

TT
TopicTrick Team
Project: Building a High-Performance Async Web Server with Coroutines & Thread Pool — Phase 4 Capstone

Project: Building a High-Performance Async Web Server with Coroutines & Thread Pool — Phase 4 Capstone


Table of Contents


Server Architecture: io_context + Thread Pool

mermaid

HTTP Request Model with std::span

cpp

Zero-Copy HTTP Parsing

cpp

Coroutine Session Handler

cpp

Graceful Shutdown with stop_token

cpp

Benchmarks: Our Server vs nginx

text

Extension Challenges

  1. HTTPS: Integrate asio::ssl::stream<tcp::socket> for TLS 1.3 support using OpenSSL
  2. WebSockets: Handle upgrade headers and implement the WebSocket handshake protocol (RFC 6455)
  3. HTTP/2: Add HTTP/2 multiplexing — multiple streams over one connection
  4. Static files: Add sendfile() (Linux) / TransmitFile() (Windows) for zero-copy static file serving
  5. Metrics: Export Prometheus metrics (/metrics endpoint) for requests/sec, p99 latency, active connections

Phase 4 Reflection

Phase 4 ConceptUsed In Server
std::jthread + stop_token (Module 14)Thread pool + graceful shutdown
std::condition_variable (Module 14)Thread pool task notification
co_await coroutines (Module 16)handle_session, accept_loop
std::span (Module 22)Request body zero-copy view
std::string_view (Module 9)URL parsing, routing, headers
Ranges algorithms (Module 15)Route matching
Memory model + atomics (Module 14)Lock-free counters

Proceed to Phase 5: C++26 Reflection & The Future →


Part of the C++ Mastery Course — 30 modules from modern C++ basics to expert systems engineering.