Skip to content

Instantly share code, notes, and snippets.

@phmarek
Created February 11, 2021 12:45
Show Gist options
  • Save phmarek/abd2dda5c1c032563bf1b7918745c7c2 to your computer and use it in GitHub Desktop.
Save phmarek/abd2dda5c1c032563bf1b7918745c7c2 to your computer and use it in GitHub Desktop.
HUNCHENTOOT:SEND-HEADERS and streaming output vs. FLEX:WITH-OUTPUT-TO-SEQUENCE
-             (let ((stream (hunchentoot:send-headers)))
+             (flex:with-output-to-sequence (stream)

and a short benchmark (wrk --latency -c2 -t2 -d 5)

gives these results. First HT:S-H:

...
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    24.07ms   14.31ms  48.32ms   61.35%
    Req/Sec    41.39      9.00    60.00     66.00%
  Latency Distribution
     50%   13.69ms
     75%   41.81ms
     90%   43.92ms
     99%   45.02ms
  414 requests in 5.01s, 700.10KB read
Requests/sec:     82.67
Transfer/sec:    139.81KB

With this single change to FLEX:W-O-T-S:

  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     7.95ms    2.69ms  30.98ms   92.86%
    Req/Sec   128.36     14.32   150.00     80.00%
  Latency Distribution
     50%    7.17ms
     75%    7.46ms
     90%    8.98ms
     99%   20.48ms
  1280 requests in 5.00s, 2.09MB read
Requests/sec:    255.76
Transfer/sec:    427.85KB

Seems that in the former case (nearly) each individual byte gets its own HTTP chunk...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment