Skip to main content

Crate ehttpd

Crate ehttpd 

Source
Expand description

License BSD-2-Clause License MIT AppVeyor CI docs.rs crates.io Download numbers dependency status

§ehttpd

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).

§Threadpool-based server

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.

§Performance

While the thread-based approach is not the most efficient out there, it’s not that bad either. Some wrk benchmarks:

§MacBook Pro (M1 Pro, v0.14.0)
$ wrk -t 64 -c 64 http://localhost:9999/testolope
Running 10s test @ http://localhost:9999/testolope
  64 threads and 64 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   846.35us  157.90us   8.83ms   95.44%
    Req/Sec     1.19k    29.88     1.39k    72.71%
  764062 requests in 10.10s, 37.89MB read
Requests/sec:  75632.95
Transfer/sec:      3.75MB

$ wrk -t 64 -c 64 http://localhost:9999/testolope-nokeepalive
Running 10s test @ http://localhost:9999/testolope-nokeepalive
  64 threads and 64 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.67ms    2.94ms  65.36ms   99.23%
    Req/Sec   298.08     58.26   360.00     88.93%
  117764 requests in 10.06s, 7.97MB read
  Socket errors: connect 64, read 0, write 0, timeout 0
Requests/sec:  11700.35
Transfer/sec:    811.25KB
§Linux Machine (Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz, v0.14.0)
$ wrk -t 64 -c 64 http://localhost:9999/testolope
Running 10s test @ http://localhost:9999/testolope
  64 threads and 64 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   193.40us  164.70us   6.74ms   88.35%
    Req/Sec     5.81k     1.36k    9.99k    73.34%
  3738117 requests in 10.10s, 185.38MB read
Requests/sec: 370077.87
Transfer/sec:     18.35MB

$ wrk -t 64 -c 64 http://localhost:9999/testolope-nokeepalive
Running 10s test @ http://localhost:9999/testolope-nokeepalive
  64 threads and 64 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   639.38us  217.27us   5.82ms   75.14%
    Req/Sec     1.42k    75.38     2.17k    85.24%
  908872 requests in 10.10s, 61.54MB read
Requests/sec:  89987.65
Transfer/sec:      6.09MB

Modules§

bytes
Provides (mostly) stack-allocating trait implementors over different underlying sources
error
Implements the crate’s error type
http
A HTTP adapter
server
Implements a simple threadpool-based server

Macros§

err
Creates a new error

Type Aliases§

Server