Skip to content

Commit c956615

Browse files
committed
add benchmarks
1 parent b5bfe2c commit c956615

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,55 @@ To generate an HMAC secret, you can use the following command for convenience:
339339
```bash
340340
openssl rand -hex 32
341341
```
342+
343+
## Benchmarks ⚡
344+
345+
**TL;DR**: The `kemal-hmac` middleware has a minimal impact on the performance of a kemal application.
346+
347+
Running `kemal` with the `kemal-hmac` middleware results in an extra `0.14ms` of latency per request on average.
348+
349+
Whereas running Ruby + Sinatra + Puma results in an extra `118ms` of latency per request on average.
350+
351+
[![rps](./docs/assets/rps.png)](./docs/assets/rps.png)
352+
353+
## kemal + kemal-hmac
354+
355+
```shell
356+
$ wrk -c 100 -d 40 -H "hmac-client: my_client" -H "hmac-timestamp: 2024-10-15T22:01:46Z" -H "hmac-token: 5b1d59098a2cccfb6e68bfea32dee4c19ae6bbd816d79285fbce3add5f2590d1" http://localhost:3000/applications/123/tokens/123
357+
Running 40s test @ http://localhost:3000/applications/123/tokens/123
358+
2 threads and 100 connections
359+
Thread Stats Avg Stdev Max +/- Stdev
360+
Latency 1.14ms 426.66us 15.60ms 98.16%
361+
Req/Sec 44.71k 3.15k 55.55k 67.75%
362+
3559413 requests in 40.01s, 492.21MB read
363+
Requests/sec: 88965.26
364+
Transfer/sec: 12.30MB
365+
```
366+
367+
## kemal without kemal-hmac
368+
369+
```shell
370+
$ wrk -c 100 -d 40 http://localhost:3000/applications/123/tokens/123
371+
Running 40s test @ http://localhost:3000/applications/123/tokens/123
372+
2 threads and 100 connections
373+
Thread Stats Avg Stdev Max +/- Stdev
374+
Latency 1.00ms 409.37us 10.66ms 97.56%
375+
Req/Sec 51.30k 4.63k 66.11k 72.62%
376+
4084149 requests in 40.01s, 564.77MB read
377+
Requests/sec: 102080.95
378+
Transfer/sec: 14.12MB
379+
```
380+
381+
## Ruby with Sinatra + Puma
382+
383+
```shell
384+
$ wrk -c 100 -d 40 http://localhost:3000/applications/123/tokens/123
385+
Running 40s test @ http://localhost:3000/applications/123/tokens/123
386+
2 threads and 100 connections
387+
Thread Stats Avg Stdev Max +/- Stdev
388+
Latency 119.23ms 152.42ms 582.52ms 78.86%
389+
Req/Sec 3.53k 1.00k 5.73k 75.50%
390+
280940 requests in 40.07s, 46.24MB read
391+
Requests/sec: 7010.87
392+
Transfer/sec: 1.15MB
393+
```

docs/assets/rps.png

25.8 KB
Loading

0 commit comments

Comments
 (0)