Forum OpenACS Development: Re: Build a web server (HTTPS) in 20 lines of code

Collapse
Posted by Neophytos Demetriou on
First release of twebserver is out. You can find it here: v1.47.0.

Features

  • High performance web server (HTTPS) written in C and Tcl.
  • It uses a highly efficient event-driven model with fixed number of threads to manage connections.
  • It can be easily extended.
  • It is a TCL loadable module.
  • It is the absolute minimum.
  • It supports multiple certificates for different hosts (SNI).
  • Keepalive connections
  • Compression (gzip)

Benchmarks

Here are some benchmarks with and without keepalive:

With keepalive (example-best-with-native-threads.tcl - uses parse_conn/return_conn): 89 microseconds per request

# gohttpbench -v 10 -n 1000000 -c 10 -t 1000 -k "https://localhost:4433/example";

Document Path: /example Document Length: 251 bytes Concurrency Level: 10 Time taken for tests: 8.88 seconds Complete requests: 1000000 Failed requests: 0 HTML transferred: 251000000 bytes Requests per second: 112609.68 [#/sec] (mean) Time per request: 0.089 [ms] (mean) Time per request: 0.009 [ms] (mean, across all concurrent requests) HTML Transfer rate: 27602.55 [Kbytes/sec] received

Without keepalive (example-best-with-native-threads.tcl - uses parse_conn/return_conn): 1.6 millisecond per request

# gohttpbench -v 10 -n 1000000 -c 10 -t 1000 "https://localhost:4433/example";

Concurrency Level: 10 Time taken for tests: 155.66 seconds Complete requests: 1000000 Failed requests: 0 HTML transferred: 246000000 bytes Requests per second: 6424.29 [#/sec] (mean) Time per request: 1.557 [ms] (mean) Time per request: 0.156 [ms] (mean, across all concurrent requests) HTML Transfer rate: 1543.33 [Kbytes/sec] received

PS. Not bad for a month's worth of work. I will fix any issues and improve it further. All feedback is welcome. Many thanks to Holger Ewert for the constructive feedback so far.