HTTP Proxy Server

A high-performance, multi-threaded networking intermediary engineered in C.

> ./proxy_router_sim.sh Packets Cached: 0
Move mouse over the terminal to route incoming packets.

System Architecture

Multi-threading Core

Leverages POSIX threads (pthreads) to handle multiple concurrent client connections. A semaphore system enforces a strict MAX_CLIENTS limit, preventing memory exhaustion and ensuring stable throughput under high load.

HTTPS Secure Tunneling

Intercepts the HTTP CONNECT method to establish a blind TCP relay. By utilizing the select() system call, the proxy seamlessly multiplexes encrypted TLS traffic between the client and upstream servers without deep packet inspection.

The Cache Evolution: O(N) to O(1)

The most critical performance bottleneck in early iterations was the caching mechanism. Scanning a standard Linked List to find URLs or identify the oldest items for eviction scales linearly O(N), causing high CPU latency as the cache grows.


The system was re-architected to achieve Amortized O(1) time complexity for both lookups and evictions by combining two advanced data structures:

Previous CPU Latency

~14,726 ns

Optimized CPU Latency

~6,327 ns (57% Faster)