HARDBackend Engineer

Design a Web Server

Build an HTTP web server supporting keep-alive connections, request pipelining, and multiple handler types

Estimated Time: 120 minutes

Solution Overview

Web servers use event-driven architecture with select/epoll for handling concurrent connections. Non-blocking I/O prevents thread starvation. HTTP/1.1 keep-alive reuses connections. Worker processes/threads handle requests in parallel.

Architecture Pattern

Event-driven server with multiplexing and request pipelining

Key Concepts

Non-blocking I/OMultiplexingHTTP/1.1 ProtocolKeep-AliveWorker Pools

Used By Companies

NginxApacheCaddy

Learn Implementation Details

Explore a complete guide for building this system from scratch with step-by-step tutorials:

Solution Overview

Web servers use event-driven architecture with select/epoll for handling concurrent connections. Non-blocking I/O prevents thread starvation. HTTP/1.1 keep-alive reuses connections. Worker processes/threads handle requests in parallel.

Companies
  • Nginx
  • Apache
  • Caddy
Key Concepts
  • Non-blocking I/O
  • Multiplexing
  • HTTP/1.1 Protocol
  • Keep-Alive
  • Worker Pools
Implementation Url

https://github.com/codecrafters-io/build-your-own-x#build-your-own-web-server