Welcome to ehttpd 🎉
ehttpd is a HTTP server library, which can be used to create custom HTTP server applications. It also offers an
optional threadpool-based server for simple applications (feature: server, disabled by default).
The rationale behind the thread-based approach is that it is much easier to implement than async/await, subsequently
requires less code, and is – in theory – less error prone.
Furthermore, it also simplifies application development as the developer cannot accidentally stall the entire runtime with a single blocking call. Since threads are managed and preempted by the OS-scheduler, they offer much stronger concurrency guarantees, and are usually more resilient against optimization issues or bugs.
While the thread-based approach is not the most efficient out there, it's not that bad either. Some wrk benchmarks:
$wrk-t64-c64http://localhost:9999/testolopeRunning10stest@http://localhost:9999/testolope64threadsand64connectionsThreadStatsAvgStdevMax+/-StdevLatency846.35us157.90us8.83ms95.44%Req/Sec1.19k29.881.39k72.71%764062requestsin10.10s,37.89MBreadRequests/sec:75632.95Transfer/sec:3.75MB$wrk-t64-c64http://localhost:9999/testolope-nokeepaliveRunning10stest@http://localhost:9999/testolope-nokeepalive64threadsand64connectionsThreadStatsAvgStdevMax+/-StdevLatency1.67ms2.94ms65.36ms99.23%Req/Sec298.0858.26360.0088.93%117764requestsin10.06s,7.97MBreadSocketerrors:connect64,read0,write0,timeout0Requests/sec:11700.35Transfer/sec:811.25KB$wrk-t64-c64http://localhost:9999/testolopeRunning10stest@http://localhost:9999/testolope64threadsand64connectionsThreadStatsAvgStdevMax+/-StdevLatency193.40us164.70us6.74ms88.35%Req/Sec5.81k1.36k9.99k73.34%3738117requestsin10.10s,185.38MBreadRequests/sec:370077.87Transfer/sec:18.35MB$wrk-t64-c64http://localhost:9999/testolope-nokeepaliveRunning10stest@http://localhost:9999/testolope-nokeepalive64threadsand64connectionsThreadStatsAvgStdevMax+/-StdevLatency639.38us217.27us5.82ms75.14%Req/Sec1.42k75.382.17k85.24%908872requestsin10.10s,61.54MBreadRequests/sec:89987.65Transfer/sec:6.09MB