This project implements a multithreaded HTTP web server in Rust with a custom thread pool. It handles multiple client connections concurrently by reusing a fixed number of worker threads, improving performance compared to spawning a new thread for every request.
- Handles HTTP requests on
127.0.0.1:7878 - Routes:
/→ Returnshello.html/sleep→ Simulates slow response (5s delay)- Any other path → Returns
404.html
- Custom Thread Pool for concurrent request handling
- Graceful Shutdown after serving 2 connections
- Logs worker activity for clarity
- TCP Listener accepts incoming connections on
127.0.0.1:7878 - Each connection is submitted as a job to the thread pool
- Workers pick up jobs from the channel and execute them
- After processing 2 connections, the server shuts down because take(2) is Initalized for Optimization.
- Thread pool ensures a graceful exit by joining all worker threads
- TCP Listener accepts incoming connections on
127.0.0.1:7878 - Each connection is submitted as a job to the thread pool
- Workers pick up jobs from the channel and execute them
- After processing 2 connections, the server shuts down
- Thread pool ensures a graceful exit by joining all worker threads
- TCP Listener accepts incoming connections on
127.0.0.1:7878 - Each connection is submitted as a job to the thread pool
- Workers pick up jobs from the channel and execute them
- After processing 2 connections, the server shuts down
- Thread pool ensures a graceful exit by joining all worker threads
git clone https://github.com/your-username/rust-multithreaded-webserver.gitcd rust-multithreaded-webservercargo run- http://127.0.0.1:7878/ → Loads hello.html
- http://127.0.0.1:7878/sleep → Waits 5 seconds, then loads hello.html
- Any other path → 404.html
