Implementation of a simple HTTP server with C++
- Run on Linux only
- It can handle a huge concurrent connections (> 10k).
- Only support HTTP/1.0 and HTTP/1.1, with basic request methods: GET, POST, PUT, DELETE.
- Only support basic HTTP/1.1, persistent connections, focus on serving as much RPS as possible.
- Support basic request and response, request size < 4KB.
- The art of speed is about epoll, refer 63.4.5 of The Linux Programming Interface book
TBU
To install this server, follow these steps:
- Clone this repository:
git clone git@github.com:nguyenhien1994/simple-http-server.git
- Navigate to the repository directory:
cd simple-http-server
- Build the source code:
mkdir build
cd build
cmake .. && make
To start the server, run ./HttpServer
from the build directory.
The server will start on port 38080 by default.
Access the demo API via: localhost:38080/helloworld
Note: you may need to increase the resource limit with ulimit
before running the server.
Benchmarking with wrk
- On the Laptop with 8 cores and 16GB RAM: It can serve > 200k rps and 10k concurrent connections
Contributions are welcome! Please open an issue or submit a pull request if you would like to contribute.
- Add basic design
- Add unittests
- Support more features HTTP/1.1
- Support send a receive message with large payload ...