Java input streams are blocking, rather than asynchronous, so yes it would
use a thread per stream.

In theory an asynchronous solution would be more efficient, and there are
adapters, like http-kit, that support this optimisation.

However, in practice, Java can handle many threads in a single process, so
it's unlikely you'll run into difficulties until you have to support 1000s
of concurrent downloads. It's often a good idea to avoid premature
optimisations, particularly if you lack concrete benchmarks.

It also depends a lot on how you're generating the downloads. If you're
generating the files dynamically, you may find that your bottleneck is
CPU-bound, rather than I/O-bound; in which case, there would be little
benefit to going async. If you're just serving static files, then it might
be useful hosting your files on a service like S3, and redirecting your
users instead.

- James


On 23 April 2014 04:03, Andrew Chambers <andrewchambe...@gmail.com> wrote:

> When you set the body of a ring response to a java input stream and return
> it, is this still a thread per stream? or does it use some sort of java
> event loop for efficiency?
> I'm worried that a traffic download/upload server in ring wouldn't handle
> many concurrent large file uploads and downloads as efficiently as
> something like google go or nodejs would.
> I would like to use ring because I want Datomic to manage the access
> permissions.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to