by arohner · 12y ago · 0 comments
[from TFA]
> This however does come with a cost:
> - We cannot use Clojure’s concurrency primitives (futures/promises/agents).
Running my own large-ish Clojure service (CircleCI), I'm pretty convinced that futures are an anti-pattern in many situations. If your future is for side-effects, rather than for computation, the future call should probably be going on a durable queue being processed by a cluster of machines. (post "/user/foo" [request]
(update-db)
(future (send-user-email))
{:status 200
:body (render-page)})
What happens if email delivery fails? What happens if this box powers off? etc. Queues don't solve all your failure scenarios here, but they're a great first step.As soon as you want to make the use of futures robust, you will basically start reimplementing parts of a work queue library.
E.g. futures assume they will be handled within the lifetime of the current process: they do not survive catastrophic process failure. If you want to overcome that assumption with persistence, you can either reinvent a wheel, or use a work queuing library that has already implemented this for you.
E.g. you can reinvent your own generic on-fail-retry or you can submit the work to a queue managed by library code that has already implemented retrying for you.
Scaling RabbitMQ at SoundCloud: http://vimeo.com/69960105
Edit: usually with durable queues on SSDs
Edit: text version of the talk: http://blog.pivotal.io/pivotal/case-studies-2/scaling-with-r...
What is it about RabbitMQ or Redis durability that you find lacking? What alternative do you recommend?
http://aphyr.com/posts/315-call-me-maybe-rabbitmq
But all systems like this have weak points, just look at the other systems aphyr has analyzed.