So, I'm working on a medium-largish server application in Clojure (medium
amounts of code- currently >10KLOC and growing quickly, two people working
on it now and hopefully more in the future.  This isn't brag-worthy size,
but it's large enough to start causing problems).  Specifically, there will
be a lot of asynchronous compute-heavy jobs being spawned off, and other
jobs that want to start when some set of other jobs all complete.  Obviously
starting a new thread for every job is way to expensive, not to mention the
fact that trying to schedule 10K threads causes many OS's schedulers to fall
down and go boom.  What I want is some way to schedule tasks to be executed
by some set of worker threads, and then be able to control the number of
worker threads on a server.  What I'm interested in is other people's
opinions on how I should architect this app.

The first idea is to just use agents- every job has an agent associated with
it, and a little infrastructure code and I'm done.  This has the advantage
of being very idiomatic for clojure, but there is no way, to my knowledge,
to control how many worker threads are executing agents at any given time-
please correct me if I'm wrong.

The second possibility is to use the java.util.concurrent package, and build
something out of Futures and Executors etc.  This has the advantage of being
closer to the semantics I want, including giving me control on the number of
worker threads, but it's Java code and thus "less idiomatic".  Here I'd be
worried about someone in the future using agents, if not directly then via
some "careless" use of a library.  I really hate trying to disallow the use
of an idiomatic feature of a language, as it rarely works.

Other possibilities include bringing in the Jakarata Commons or Apache
Commons or some other third-party library.

So that's my question: what are people's opinions?  Which of these options
(or other options I haven't noticed yet) is going be least pain/best
performance?  By all means, please pontificate.  Thanks.

Brian

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to