1

I have been reading about Clojure for some time and I'm considering it as a replacement to Node.js (which I have used for another project). The most promising library seems to be Aleph/Lamina, which unfortunately doesn't have nearly as many examples as Node. My questions are:

  1. How can I process requests with a chain of async operations, such as reading a document from MongoDB, doing some calculations, saving the new document and sending it in the response? I was not able to write it from the examples in Lamina wiki page. It sounds like a pretty common use case and I was surprised not to found any code showing it. It would be great if you could show me some sample code.

  2. Is this setup adequate for a heavy-load server (say, tens of thousands requests per second)? I can't afford to create one thread for each new request, so I need something similar to the Node approach.

  3. Is there any example of a medium- or large-sized company out there using any of this?

  4. Is there any better Clojure replacement to Node (besides Aleph/Lamina)? Perhaps Clojurescript targetting Node? My client is not written in Javascript, so using the same language in both client and server is not an advantage in my case.

Thanks!

Olle Sjögren
  • 5,315
  • 3
  • 31
  • 51
aeuhuea
  • 449
  • 4
  • 7

1 Answers1

1

Few pointers:

  1. You need to look at Aleph which builds HTTP abstractions over Lamina channels abstraction.
  2. Reading and writing docs to MongoDB can be async but the library should provide this. In Node.js the MongoDB library has to be async other wise it would screw up the Node programming model, where as this is not the case with Clojure so most probably the Clojure MongoDB library provides non-async function.
  3. Async operations are only helpful in case of IO i.e reading/writing to mongodb, sending response back etc. Generation computations are CPU bound operations and has nothing to do with async model.
  4. Vert.x is Java world Node.js. Clojure support is on roadmap. I would prefer Aleph as you can play in async and non-async world as required.
Ankur
  • 33,367
  • 2
  • 46
  • 72
  • Thanks, @Ankur. How feasible/easy is it to write a wrapper to make [CongoMongo](http://github.com/aboekhoff/congomongo) or Monger async? Or would it be better to wrap the [Java Mongo Async driver](http://www.allanbank.com/mongodb-async-driver/)? – aeuhuea Nov 25 '12 at 00:44