BACKEND SYSTEMS

Webserv

Webserv is a production-inspired HTTP/1.1 web server implemented entirely from scratch in modern C++. The objective of the project is to understand how web servers such as Nginx and Apache process requests internally by implementing every major subsystem manually.

YEAR

2023

ROLE

Designed • Developed • Shipped

STACK

C++98TCPIPv4BSD Socketssocket()bind()

01/PROBLEM → SOLUTION

02/SYSTEM ARCHITECTURE

How the system fits together

  1. TCP Listening Socket
  2. Event Loop
  3. HTTP Parser
  4. Router
  5. Static File Handler
  6. HTTP Response Builder
DRAG / SWIPE TO PAN DIAGRAM
Web ClientBROWSER / CURLTCP Listening SocketPORT 80/443Event LoopPOLLConnection ManagerACCEPT / REGISTERClient SocketNON-BLOCKING I/OHTTP ParserREQUEST VALIDATIONRouterVIRTUAL SERVER MATCHERStatic File HandlerDISK I/OCGI ExecutorPROCESS SPAWNERHTTP Response Builder

Drag to pan or Hover to trace or Click to inspect

03/KEY ENGINEERING DECISIONS

Event Multiplexing

One poll() loop watches all sockets instead of a thread per client, cutting memory and context-switch overhead.

Non-Blocking I/O

Sockets run non-blocking so a slow client cannot pause the server for everyone else.

Layer Separation

Networking is isolated from HTTP parsing and routing so subsystems evolve independently.

04/IMPACT & TAKEAWAYS

HTTP/1.1 Compliant. Implements request/response, methods, headers, and persistent connections by hand over TCP/IPv4.

Feature Set. Virtual servers, routing, CGI execution, file uploads, and custom error pages all working.

Concurrency Verified. Hundreds of concurrent client events coordinated through one event-driven loop.