-
Couldn't load subscription status.
- Fork 121
Open
Description
The code below would work 10 times faster if compiled with AsyncHttpServer instead of HttpBeast.
I guess it's because it uses spawn and competes with HttpBeast for same ThreadPool.
Not sure if it's a problem or expected behaviour, feel free to close.
import os, threadpool, jester
proc process(data: string): string =
sleep 100
"processed " & data
routes:
get "/":
let cresult = spawn process("something")
while true:
await sleep_async 1
if cresult.is_ready: break
resp ^cresultResults with HttpBeast nim c -r --threads:on play.nim , 2 req/sec
wrk -t2 -c2 -d10s http://localhost:5000
Running 10s test @ http://localhost:5000
2 threads and 2 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 991.70ms 25.97ms 1.00s 90.00%
Req/Sec 0.30 0.47 1.00 70.00%
20 requests in 10.06s, 2.99KB read
Requests/sec: 1.99
Transfer/sec: 304.09BResults with AsyncHttpServer nim c -r --threads:on play.nim , 20 req/sec
wrk -t2 -c2 -d10s http://localhost:5000
Running 10s test @ http://localhost:5000
2 threads and 2 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 104.47ms 1.67ms 108.73ms 61.98%
Req/Sec 9.06 0.83 10.00 81.77%
192 requests in 10.09s, 18.19KB read
Requests/sec: 19.04
Transfer/sec: 1.80KBMetadata
Metadata
Assignees
Labels
No labels