Also, when you’re benchmarking requests to
localhost, a concurrency of 100 is too high to yield meaningful results.
Oops, I notice both go/Crystal get broken pipe issue at the last requests before the wrk comand ends.
even when I remove the -c 100(which use default 2 connections), I still get broken pipes errors
So, i consider the result is useful.
——–
Following is the result use default 2 connections
Crystal 1.18.2 build with “CRYSTAL_WORKERS=10 shards build --release -Dpreview_mt”
CPU usage is 400%
```
╰──➤ $ wrk -d 30 http://localhost:3000/posts
Running 30s test @ http://localhost:3000/posts
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 14.50ms 6.18ms 221.14ms 95.96%
Req/Sec 351.19 17.74 450.00 70.33%
20991 requests in 30.02s, 10.66GB read
Non-2xx or 3xx responses: 1
Requests/sec: 699.35
Transfer/sec: 363.67MB
```
Go version (CPU usage is 1000%, 10x Crystal)
╰──➤ $ wrk -d 30 ``http://localhost:8080/posts
Running 30s test @ ``http://localhost:8080/posts
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 12.64ms 1.78ms 25.44ms 69.56%
Req/Sec 397.34 24.37 470.00 74.50%
23749 requests in 30.03s, 12.06GB read
Requests/sec: 790.96
Transfer/sec: 411.30MB
Yes, you are right, when Crystal enable -Dpreview_mt and set to use 10 workers, it uses less than half the CPU resources of gin, but achieves nearly the same performance.
————
One more concern, but if built with -Dpreview_mt -Dexecution_context, the performance is too bad.
╰──➤ $ wrk -d 30 http://localhost:3000/posts
Running 30s test @ http://localhost:3000/posts
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 41.12ms 23.59ms 234.41ms 59.96%
Req/Sec 122.22 9.76 151.00 70.33%
7307 requests in 30.02s, 3.71GB read
Requests/sec: 243.43
Transfer/sec: 126.59MB
This result same as default shards build –release, does -Dexecution_context not respect the CRYSTAL_WORKERS env ? or just kemal not support that?
Compared to Go, which can leverage multiple cores and deliver solid performance (at least in this hello world test) without any compilation-time flag, Crystal still requires manual tuning, there’s still a long way to go.
