Hi,
I'm using the following code:
import jester, asyncdispatch
import os
routes:
get "/slow":
sleep(1000)
resp "thanks for waiting"
get "/fast":
resp "whooosh"
runForever()
I can get hundreds of requests per seconds on the /fast route. But once I add requests to the /slow route (even just 1-2 per second) the performance of the /fast route drops as well. So the /slow route appears to block the whole server.
How would I go about changing my code above to have the /slow route not affect the whole server?
Jester relies on Nim's built-in async modules, which are unfortunately built on a single-threaded asynchronous approach. This means any blocking operation done on the main thread will stall all operations.
If your aim is to pause a route, I suggest using something like sleepAsync. For operations that don't have an asynchronous version, you'll need to run the procedure on another thread.