Skip to content

Instantly share code, notes, and snippets.

@luislavena
Created November 27, 2021 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luislavena/9ba5c6e9024b833a9b419ce29aafa457 to your computer and use it in GitHub Desktop.
Save luislavena/9ba5c6e9024b833a9b419ce29aafa457 to your computer and use it in GitHub Desktop.

Ref: crystal-lang/distribution-scripts#127 (comment)

Synthetic micro benchmark of basic HTTP server against localhost, this time Crystal 1.2.1 on multiple versions of Alpine:

# A very basic HTTP server
require "http/server"

server = HTTP::Server.new do |context|
  context.response.content_type = "text/plain"
  context.response.print "Hello world!"
end

Signal::INT.trap do
  puts "Shutdown requested."
  server.close
end

ipaddr = server.bind_tcp("0.0.0.0", 8080)

puts "Listening on http://#{ipaddr.address}:#{ipaddr.port}/"
server.listen

Crystal 1.2.1 on Alpine 3.12 (best of 3 bench):

❯ plow -c 5 -d 30s http://localhost:8080/
Benchmarking http://localhost:8080/ for 30s using 5 connection(s).
@ Real-time charts is listening on http://[::]:18888

Summary:
  Elapsed    30.001s
  Count      1493553
    2xx      1493553
  RPS      49783.348
  Reads    4.795MB/s
  Writes   2.754MB/s

Statistics   Min     Mean    StdDev     Max
  Latency   17µs     97µs     56µs    7.944ms
  RPS       45915  49783.62  1104.21  51078.05

Latency Percentile:
  P50    P75    P90    P95    P99   P99.9  P99.99
  93µs  122µs  151µs  175µs  318µs  502µs  1.126ms

Latency Histogram:
  93µs     1431235  95.83%
  160µs      53010   3.55%
  284µs       7203   0.48%
  428µs       1639   0.11%
  577µs        376   0.03%
  1.083ms       74   0.00%
  1.424ms       14   0.00%
  1.811ms        2   0.00%

Crystal 1.2.1 on Alpine 3.13 (best of 3 bench):

❯ plow -c 5 -d 30s http://localhost:8080/
Benchmarking http://localhost:8080/ for 30s using 5 connection(s).
@ Real-time charts is listening on http://[::]:18888

Summary:
  Elapsed        30s
  Count      1475226
    2xx      1475226
  RPS      49173.273
  Reads    4.736MB/s
  Writes   2.720MB/s

Statistics    Min       Mean    StdDev     Max
  Latency     16µs      98µs     58µs    5.209ms
  RPS       44555.55  49172.22  1531.21  50450.54

Latency Percentile:
  P50    P75    P90    P95    P99   P99.9  P99.99
  94µs  123µs  154µs  177µs  323µs  503µs  1.103ms

Latency Histogram:
  97µs     1454405  98.59%
  175µs      18257   1.24%
  333µs       1943   0.13%
  488µs        474   0.03%
  792µs         97   0.01%
  1.349ms       30   0.00%
  2.169ms       15   0.00%
  5.136ms        5   0.00%

Crystal 1.2.1 on Alpine 3.14 (best of 3 bench):

❯ plow -c 5 -d 30s http://localhost:8080/
Benchmarking http://localhost:8080/ for 30s using 5 connection(s).
@ Real-time charts is listening on http://[::]:18888

Summary:
  Elapsed        30s
  Count      1479025
    2xx      1479025
  RPS      49300.800
  Reads    4.749MB/s
  Writes   2.727MB/s

Statistics    Min       Mean    StdDev     Max
  Latency     17µs      98µs     56µs    3.627ms
  RPS       45856.49  49299.64  1104.19  50453.53

Latency Percentile:
  P50    P75    P90    P95    P99   P99.9  P99.99
  93µs  123µs  153µs  176µs  336µs  497µs  1.031ms

Latency Histogram:
  95µs     1414667  95.65%
  148µs      53648   3.63%
  246µs       8811   0.60%
  418µs       1694   0.11%
  678µs        164   0.01%
  1.12ms        30   0.00%
  1.631ms        9   0.00%
  2.45ms         2   0.00%

Crystal 1.2.1 on Alpine 3.15 (best of 3 bench):

❯ plow -c 5 -d 30s http://localhost:8080/
Benchmarking http://localhost:8080/ for 30s using 5 connection(s).
@ Real-time charts is listening on http://[::]:18888

Summary:
  Elapsed        30s
  Count      1474887
    2xx      1474887
  RPS      49161.930
  Reads    4.735MB/s
  Writes   2.719MB/s

Statistics    Min       Mean    StdDev     Max
  Latency     18µs      98µs     60µs    4.369ms
  RPS       44423.06  49161.08  1249.31  50214.87

Latency Percentile:
  P50    P75    P90    P95    P99   P99.9  P99.99
  93µs  123µs  153µs  177µs  341µs  622µs  1.238ms

Latency Histogram:
  96µs     1421915  96.41%
  145µs      42156   2.86%
  229µs       8472   0.57%
  371µs       1780   0.12%
  494µs        414   0.03%
  756µs        119   0.01%
  1.513ms       29   0.00%
  3.395ms        2   0.00%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment