A simple C++ webserver for responsing HTTP-request(s). It's a self-learning project which draws heavily on the design of the following projects:
Different from these projects, this webserver is implemented based on C++11 standard library (e.g., std::thread, std::mutex).
- Ubuntu 20.04
- gcc 9.3.0 [g++]
【STILL DIRTY NOW】 Hard-coding the server-address-port and source path, make it and run:
./build/bin/httpancake
- Configuration interface
- Reactor server model
- EventLoop threadpool [One-loop-per-thread]
- Simple async log system
- HTTP-request parsing & responsing [GET]
- Use Timers to shutdown idle connections
- MySQL connection-pool
- Windows 10 WSL2: Ubuntu22.04
- CPU: Intel Core i5-8265U
- 8GB RAM
- The Logger-system was disabled
- ThreadPool size: 4
QPS | |
---|---|
Short-Connection | 23,825 |
Long-Connection | 35,014 |
- Short-connection result
./webbench -2 -c 1000 -t 60 http://127.0.0.1:9981/hello.html
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Request:
GET /hello.html HTTP/1.1
User-Agent: WebBench 1.5
Host: 127.0.0.1
Connection: close
Runing info: 1000 clients, running 60 sec.
Speed=1429491 pages/min, 3288001 bytes/sec.
Requests: 1429491 susceed, 0 failed.
- Long-connection result
./webbench -k -2 -c 1000 -t 60 http://127.0.0.1:9981/hello.html
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Request:
GET /hello.html HTTP/1.1
User-Agent: WebBench 1.5
Host: 127.0.0.1
Connection: Keep-Alive
Runing info: 1000 clients, running 60 sec.
Speed=2100869 pages/min, 5007071 bytes/sec.
Requests: 2100869 susceed, 0 failed.