Marcin Kulik
2016-06-08 18:16:54 UTC
I created a simple "wait" ring handler which waits for 3 seconds (good old
Thread.sleep), and then returns text "done" as the response body (note: I
use Compojure to route to this handler).
I use Aleph but I am not using any Aleph/Manifold/Netty specific features
here.
I created bash script which hits Aleph with curl, 200 parallel requests
(curl http://localhost:3000/myhandler & curl
http://localhost:3000/myhandler & curl http://localhost:3000/myhandler &
...).
To my surprise, I got all 200 responses roughly after 3 seconds.
How is this possible when Thread.sleep blocks the thread, and Aleph uses
2*cpu-cores threads for processing requests? (I have 4 cores)
Is it creating 200 temporary threads to handle this?
I'm switching to Aleph from Jetty because one of my handlers (let's call it
"upload") is uploading file to S3, and I want the synchronous upload
(clj-aws-s3) to happen on my own core.async based, bounded uploader pool.
So I'm returning Manifold deferred from the handler (s/->source
channel-with-eventual-upload-response). Seems to be working great. However,
the above test with "wait" endpoint confused me, and before I put more work
into my main goal ("upload" endpoint), I'd like to understand what's really
going on in there.
Thread.sleep), and then returns text "done" as the response body (note: I
use Compojure to route to this handler).
I use Aleph but I am not using any Aleph/Manifold/Netty specific features
here.
I created bash script which hits Aleph with curl, 200 parallel requests
(curl http://localhost:3000/myhandler & curl
http://localhost:3000/myhandler & curl http://localhost:3000/myhandler &
...).
To my surprise, I got all 200 responses roughly after 3 seconds.
How is this possible when Thread.sleep blocks the thread, and Aleph uses
2*cpu-cores threads for processing requests? (I have 4 cores)
Is it creating 200 temporary threads to handle this?
I'm switching to Aleph from Jetty because one of my handlers (let's call it
"upload") is uploading file to S3, and I want the synchronous upload
(clj-aws-s3) to happen on my own core.async based, bounded uploader pool.
So I'm returning Manifold deferred from the handler (s/->source
channel-with-eventual-upload-response). Seems to be working great. However,
the above test with "wait" endpoint confused me, and before I put more work
into my main goal ("upload" endpoint), I'd like to understand what's really
going on in there.
--
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aleph-lib+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aleph-lib+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.