This project implements a high-performance HTTP server using the epoll I/O event notification mechanism. The server is capable of handling multiple concurrent connections efficiently, supporting basic HTTP methods and file serving capabilities.
Through my personal projects and internships, I have had the opportunity to experiment with backend frameworks such as Express.js, FastAPI, and others. The goal of this project was to uncover how these HTTP servers work behind the scenes, how computer networks interface with the Operating System, and how Asynchronous HTTP Servers such as ones with Express.js achieve high performance and concurrency. Specifically, this project aimed to:
- Gain a deep understanding of the low-level networking mechanisms in Unix-like operating systems.
- Explore the epoll I/O event notification system and its role in efficient server design.
- Implement a basic HTTP server from scratch without relying on high-level frameworks.
- Understand the challenges and considerations in handling concurrent connections.
- Learn about memory management and buffer handling in network programming.
- Investigate how file I/O operations integrate with network servers.
- Implement basic HTTP protocol handling, including parsing requests and forming responses.
- Explore performance optimization techniques for high-concurrency scenarios.
By building this server from the ground up, I sought to bridge the gap between high-level web frameworks and the underlying system calls and mechanisms that enable their functionality. This project has provided invaluable insights into the intricacies of network programming and the design considerations for scalable server applications.
- Utilizes epoll for efficient I/O multiplexing
- Supports GET and POST HTTP methods
- Implements custom endpoints (/ping, /echo, /read, /write, /stats)
- Serves static files
- Supports multiple concurrenct downloads for large files (>= 1GB)
- Maintains server statistics
- Network programming (sockets, HTTP protocol)
- Concurrent programming using epoll
- File I/O operations
- Memory management and buffer handling
- Error handling and logging
- Performance optimization for high-concurrency scenarios
- Clone the repository
- Compile the server:
make all - Create a
port.txtfile with your desired port number - Run the server:
./http_server
The server responds to the following endpoints:
/ping: Returns "pong"/echo: Echoes back the request headers/read: Returns previously saved data/write: Saves POST data (up to 1024 bytes)/stats: Returns server statistics- Any other path: Attempts to serve a file from the current directory
- Implement SSL/TLS support
- Implementing the producer/consumer concurrency model
Contributions are welcome! Please feel free to submit a Pull Request.