Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jester with HttpBeast is slow if used with ThreadPool #273

Open
al6x opened this issue Mar 14, 2021 · 4 comments
Open

Jester with HttpBeast is slow if used with ThreadPool #273

al6x opened this issue Mar 14, 2021 · 4 comments

Comments

@al6x
Copy link

al6x commented Mar 14, 2021

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 ^cresult

Results 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.09B

Results 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.80KB
@al6x al6x changed the title HttpBeast is slow with ThreadPool Jester with HttpBeast is slow if used with ThreadPool Mar 14, 2021
@unkn0wn-root
Copy link

Seems that project is pretty much dead.

@dom96
Copy link
Owner

dom96 commented Mar 27, 2021

What project?

@avahe-kellenberger
Copy link

Any updates on this? @dom96 have you been able to recreate it?

@dom96
Copy link
Owner

dom96 commented Dec 12, 2021

Haven't had a chance to yet, can you reproduce it? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants