All Projects

HTTP Proxy Server

Multi-threaded proxy in C with LRU cache

Overview

A multi-threaded HTTP proxy server written in C, built to internalize OS primitives — threading, locks, semaphores, and caching. It uses POSIX threads with semaphore-based synchronization (sem_wait/sem_post) instead of pthread_join for worker coordination, which keeps the API parameter-free and makes the concurrency model easier to reason about. The proxy handles parallel client requests, speaks a full HTTP parsing + socket-programming pipeline, and layers in a thread-safe LRU cache on top to reduce redundant upstream traffic and improve response latency. The codebase is intentionally annotated — it's as much a learning artifact as it is a working proxy — and the README discusses limitations (fixed cache-entry size, single-method support) and extensions (multi-process parallelism, URL allow-listing).

What I learned

  • Trade-offs between semaphores and condition variables for worker coordination.
  • Cache-line-friendly data structures in a tight C codebase.