> However I’m not living into the illusion that I got everything right in the first release, so it will take months (or years?) of iteration to really reach the operational simplicity I’m targeting.
It's always refreshing to hear such good programmers acknowledging how hard building complex systems is.
And this from antirez who writes such excellent programms, Redis runs in several companies I've been, without ever crashing, making any trouble - most people I've met forget they have Redis running because it just works and works and works. Can't praise that piece of code high enough.
Disque is definitely exciting, and looks like it can replace RabbitMQ, which has serious flaws in its clustering design. I'm looking forward to trying it out.
However, if some constructive criticism is permitted, I have to say that, having written distributed applications for many years, I have come to dislike the "classical" push/pop queue data model:
* Acking is a bad idea. It requires the broker to manage a lot of state, including locking and timeouts.
* Re-queuing invalidates total ordering.
* On the performance side, parallel distributed queue consumption (which also breaks total ordering) is directly at odds with this model.
* Queues as opaque objects — you can only inspect by popping the top message, and you cannot access older, dequeued messages. Fortunately, Disque allows you to read the entire queue without mutating it, but it doesn't look like you can read old messages.
* Complicated queue topologies (fanouts, dead letter queues, etc.) become a logical necessity of the strict FIFO structure. (These topologies need to be declared every time the client starts up, and introduces the possibility of schema conflicts.)
* Logical de-duping is probably not possible.
Apache Kafka gets the data model right. It wisely acknowledges that queues are linear and should stay that way: In Kafka, queues are strictly append-only logs where every consumer has a cursor to the last position it read. In this model, many of the classical concerns melt away: Acks/nacks are unnecessary (consumers simply "commit" their position); total ordering is always preserved (since the queue cannot be reordered) and parallelism is made explicit (through named partitions); de-duping is trivial, and complicated topologies are largely eliminated (AMQP-type "exchanges" that fan out to separate queues are unnecessary because multiple readers can all consume the same queue without changing it, as their position is independent of the queue); and you get to choose either at-most-once or at-least-once delivery consistency by how carefully you manage your offset.
Since logs are strictly linear, you are also given the choice of how much history to keep — all of it, if you want — which opens up some interesting use cases that are not possible with classical brokers.
Kafka isn't perfect. It's a huge pain if you're not in Java land. There are no modern, mature "high-level" client implementations for Go, Ruby or Node.js. Its reliance on the JVM and on ZooKeeper makes it fairly heavyweight, both on the server and on the consumer side (the new API for broker-stored offsets simplifies things, but non-Java clients are far behind). I would really love to have a lighter-weight, language-agnostic Kafka-like implementation without the Java baggage.
Last point: The fact that Disque calls its messages "jobs" makes me a little disappointed that it is, in fact, not a job management system. I'd love a solid, distributed job manager.
Kafka has a different data model which works for some scenarios, but not others.
We attempted to use Kafka as part of a job management system, where long-running jobs were scheduled and workers consumed partitions, but what we found was that since consumers work on partitions, a long-running task could block an entire partition's worth of work, with no way to migrate it to another partition.
Kafka works really well when the bottleneck is the broker to begin with -- if you have a lot of small, lightweight messages being passed to other systems, and the broker is having trouble keeping up. Analytics and logs are great examples where Kafka's data model works really well.
But for a smaller number of larger messages that takes seconds to minutes to process (we were using it to schedule data downloads and video processing), workers could be sitting idle while there was still plenty more work to do.
We moved to Amazon SQS for now, but I imagine we'll move to something like Disque in the future.
Hello, thanks for the comment. I hope the following notes may help to make clear what are the ideas behind the design decisions used in Disque:
> Acking is a bad idea. It requires the broker to manage a lot of state, including locking and timeouts.
I think it’s much better to put the complexity on the broker than putting it on the client. It’s definitely a tradeoff so many other people may not agree. Because of ACKs, a message will be delivered again to some client forever until there is a clear proof that the client processed the message (the ACK). The client has very little room for errors. In the Kafka model, which makes sense when you want to do stream processing, the client has to handle the storage of the offset. When the offset is committed to the broker itself, then the broker becomes a store that must guarantee certain kinds of consistency, which is fairly more complex than taking state in an AP system. Given that Disque targets workloads which are not stream oriented, where the order of messages is not very important, if not for the best-effort of trying to serve first who arrived first on the average case, to put the complexity of handling the state to the client (by managing the offset), or to the broker by solving a storage and consistency problem, seems a bad idea to me.
> Re-queuing invalidates total ordering.
This is a fundamental assumption of Disque: “causal/total order of messages is overrated”. There are a few use cases where it is a very important feature to have, there are a lot of use cases where it is not. When you don’t have to guarantee order, a lot of scalability and robustness can be added to the system since it can be AP, can handle the re-delivery of messages avoiding to put complexity to the client, can survive larger network issues, does not need any strongly consistent component which can make operations harder, and so forth.
> On the performance side, parallel distributed queue consumption (which also breaks total ordering) is directly at odds with this model.
I don’t agree with this statement. Because of this data model, different producers and consumers for the same huge queue, can split the load among many nodes in a completely scalable way. But this does not prevent scaling many unrelated queues as well. Different nodes will handle different queues, and Disque has mechanisms in order to improve affinity so that producers and consumers for the same queues will try to stay to the same nodes whenever possible.
Similarly not having to solve a storage problem (to commit clients offsets) makes a system easier to scale. To store something consistently is almost always going to cost some performance.
> Queues as opaque objects — you can only inspect by popping the top message, and you cannot access older, dequeued messages. Fortunately, Disque allows you to read the entire queue without mutating it, but it doesn't look like you can read old messages.
Disque has iterators in order to solve this problem. You can iterate, with filters, the whole messages space. However note that in the Kafka model you have the problem that the queue is a linar accessible object but without clues about what was processed and not, since the broker itself (AFAIK) has no clue about what the state of a job is: to be processed, already processed, processed 10 times with errors, and so forth. Again, this is a tradeoff, I’m much more happy with more state on the broker than on the client for the use cases Disque is designed for.
* Complicated queue topologies (fanouts, dead letter queues, etc.) become a logical necessity of the strict FIFO structure. (These topologies need to be declared every time the client starts up, and introduces the possibility of schema conflicts.)
Not sure about this since as said strict FIFO is not targeted nor possible with Disque.
* Logical de-duping is probably not possible.
This is true (or not) with all the messaging systems, basically. Storing the offset in the client side (or committing it to the broker) is the same: you need to have a consistent store, somewhere, in order to make sure after crash recovery events or network partitions you are not going to process the same messages again. Actually in order to guarantee single processing you have to store the offset as part of the transaction that produces the effects of processing the message. The same can be achieved with any messaging system that guarantees the delivery of the message, if you have a CP store somewhere. The trivial case is that you use unique IDs in order to make processing idempotent, or you use to store states in the CP store in order to make out of order delivery of messages not an issue since you ignore every message which does not match the current state. This is more the matter of moving things in some place or the other. For all the cases where single processing is desirable but not extremely important, Disque “cheap” best-effort single processing can be enough and is very scalable.
> Last point: The fact that Disque calls its messages "jobs" makes me a little disappointed that it is, in fact, not a job management system. I'd love a solid, distributed job manager.
Disque is a general messaging system, but certain design characteristics are biased towards the idea that messages will be jobs. However it is opinionated about what should be and what should not be inside the broker itself. If you want more, it’s up to the client library to implement a more full fledged job processing system on top of what Disque provides.
Last note: given that I wrote Disque to provide something to the OSS world, I was not very interested in competing with something in particular: Kafka or RabbitMQ or some other message queue. Actually the less overlap the better, so my attempt was to create something different. There are things at which existing technologies will be better and maybe there will be things at which Disque will be better.
Currently, we have a huge background processing system built using Sidekiq backed by Redis. The biggest problem we are facing today is to run machines with lot of in-memory storage because jobs are queued to Redis and Redis works in-memory. These machines costs a lot.
I think the same issue will happen even here because this is also in-memory store and persistence works like how Redis handles it.
ZeroMQ is not a messaging broker, it's a socket abstraction. (I interpret the zero in ZeroMQ to mean "no".) So they are not comparable at all. You can build a broker with ZeroMQ, which people have done [1], in the same sense that you can build a broker on plain TCP sockets.
There are plenty, but few/none that solve the problem Disque solves. You could easily use Kafka or RabbitMQ, but Disque aims to provide simplicity rather than be full-featured. @antirez described it as solving the case where you just need a queue with very basic guarantees and good performance without all the bells and whistles that a more complex system has. Disque is (spiritually, not technically) a lot like Mongo was five years ago compared to something much heavier like Postgres. In that sense, there are few (if any) product-ready alternatives that solve the same problem.
It should also be noted that you could probably successfully use Redis for much of what Disque does (Disque is based on Redis). Disque adds nice features, though, and removes most of the features of Redis that are outside its scope.
We have used nsq to ship billions of log messages daily for over 2 years. It is very sensible operationly and easy to configure to the level of robustness your use may have. It does not allow seeking into the queue like Kafka, but we have never needed that capability, and we found it easier to design around this rather than take on the operational burden.
It seems like Disque is a "simplified" Kafka, or a more vertically purposed Redis. It seems that it differs from RabbitMQ significantly because rabbit requires a queue to push the messages in, while Disque allows jobs to be pushed independently of consumers being setup.
[+] [-] kevan|10 years ago|reply
It's always refreshing to hear such good programmers acknowledging how hard building complex systems is.
[+] [-] BogusIKnow|10 years ago|reply
[+] [-] nikolay|10 years ago|reply
[+] [-] lobster_johnson|10 years ago|reply
However, if some constructive criticism is permitted, I have to say that, having written distributed applications for many years, I have come to dislike the "classical" push/pop queue data model:
* Acking is a bad idea. It requires the broker to manage a lot of state, including locking and timeouts.
* Re-queuing invalidates total ordering.
* On the performance side, parallel distributed queue consumption (which also breaks total ordering) is directly at odds with this model.
* Queues as opaque objects — you can only inspect by popping the top message, and you cannot access older, dequeued messages. Fortunately, Disque allows you to read the entire queue without mutating it, but it doesn't look like you can read old messages.
* Complicated queue topologies (fanouts, dead letter queues, etc.) become a logical necessity of the strict FIFO structure. (These topologies need to be declared every time the client starts up, and introduces the possibility of schema conflicts.)
* Logical de-duping is probably not possible.
Apache Kafka gets the data model right. It wisely acknowledges that queues are linear and should stay that way: In Kafka, queues are strictly append-only logs where every consumer has a cursor to the last position it read. In this model, many of the classical concerns melt away: Acks/nacks are unnecessary (consumers simply "commit" their position); total ordering is always preserved (since the queue cannot be reordered) and parallelism is made explicit (through named partitions); de-duping is trivial, and complicated topologies are largely eliminated (AMQP-type "exchanges" that fan out to separate queues are unnecessary because multiple readers can all consume the same queue without changing it, as their position is independent of the queue); and you get to choose either at-most-once or at-least-once delivery consistency by how carefully you manage your offset.
Since logs are strictly linear, you are also given the choice of how much history to keep — all of it, if you want — which opens up some interesting use cases that are not possible with classical brokers.
Kafka isn't perfect. It's a huge pain if you're not in Java land. There are no modern, mature "high-level" client implementations for Go, Ruby or Node.js. Its reliance on the JVM and on ZooKeeper makes it fairly heavyweight, both on the server and on the consumer side (the new API for broker-stored offsets simplifies things, but non-Java clients are far behind). I would really love to have a lighter-weight, language-agnostic Kafka-like implementation without the Java baggage.
Last point: The fact that Disque calls its messages "jobs" makes me a little disappointed that it is, in fact, not a job management system. I'd love a solid, distributed job manager.
[+] [-] Jasper_|10 years ago|reply
We attempted to use Kafka as part of a job management system, where long-running jobs were scheduled and workers consumed partitions, but what we found was that since consumers work on partitions, a long-running task could block an entire partition's worth of work, with no way to migrate it to another partition.
Kafka works really well when the bottleneck is the broker to begin with -- if you have a lot of small, lightweight messages being passed to other systems, and the broker is having trouble keeping up. Analytics and logs are great examples where Kafka's data model works really well.
But for a smaller number of larger messages that takes seconds to minutes to process (we were using it to schedule data downloads and video processing), workers could be sitting idle while there was still plenty more work to do.
We moved to Amazon SQS for now, but I imagine we'll move to something like Disque in the future.
[+] [-] sametmax|10 years ago|reply
Does a proper "queing" project, that is messaging independant exists ? That would open the door to a standardization of the queing semantics and API.
Like, if I want to use crossbar.io (with it's WAMP protocol) for the messaging part, but need task queue, what are my options ?
[+] [-] antirez|10 years ago|reply
> Acking is a bad idea. It requires the broker to manage a lot of state, including locking and timeouts.
I think it’s much better to put the complexity on the broker than putting it on the client. It’s definitely a tradeoff so many other people may not agree. Because of ACKs, a message will be delivered again to some client forever until there is a clear proof that the client processed the message (the ACK). The client has very little room for errors. In the Kafka model, which makes sense when you want to do stream processing, the client has to handle the storage of the offset. When the offset is committed to the broker itself, then the broker becomes a store that must guarantee certain kinds of consistency, which is fairly more complex than taking state in an AP system. Given that Disque targets workloads which are not stream oriented, where the order of messages is not very important, if not for the best-effort of trying to serve first who arrived first on the average case, to put the complexity of handling the state to the client (by managing the offset), or to the broker by solving a storage and consistency problem, seems a bad idea to me.
> Re-queuing invalidates total ordering.
This is a fundamental assumption of Disque: “causal/total order of messages is overrated”. There are a few use cases where it is a very important feature to have, there are a lot of use cases where it is not. When you don’t have to guarantee order, a lot of scalability and robustness can be added to the system since it can be AP, can handle the re-delivery of messages avoiding to put complexity to the client, can survive larger network issues, does not need any strongly consistent component which can make operations harder, and so forth.
> On the performance side, parallel distributed queue consumption (which also breaks total ordering) is directly at odds with this model.
I don’t agree with this statement. Because of this data model, different producers and consumers for the same huge queue, can split the load among many nodes in a completely scalable way. But this does not prevent scaling many unrelated queues as well. Different nodes will handle different queues, and Disque has mechanisms in order to improve affinity so that producers and consumers for the same queues will try to stay to the same nodes whenever possible.
Similarly not having to solve a storage problem (to commit clients offsets) makes a system easier to scale. To store something consistently is almost always going to cost some performance.
> Queues as opaque objects — you can only inspect by popping the top message, and you cannot access older, dequeued messages. Fortunately, Disque allows you to read the entire queue without mutating it, but it doesn't look like you can read old messages.
Disque has iterators in order to solve this problem. You can iterate, with filters, the whole messages space. However note that in the Kafka model you have the problem that the queue is a linar accessible object but without clues about what was processed and not, since the broker itself (AFAIK) has no clue about what the state of a job is: to be processed, already processed, processed 10 times with errors, and so forth. Again, this is a tradeoff, I’m much more happy with more state on the broker than on the client for the use cases Disque is designed for.
* Complicated queue topologies (fanouts, dead letter queues, etc.) become a logical necessity of the strict FIFO structure. (These topologies need to be declared every time the client starts up, and introduces the possibility of schema conflicts.)
Not sure about this since as said strict FIFO is not targeted nor possible with Disque.
* Logical de-duping is probably not possible.
This is true (or not) with all the messaging systems, basically. Storing the offset in the client side (or committing it to the broker) is the same: you need to have a consistent store, somewhere, in order to make sure after crash recovery events or network partitions you are not going to process the same messages again. Actually in order to guarantee single processing you have to store the offset as part of the transaction that produces the effects of processing the message. The same can be achieved with any messaging system that guarantees the delivery of the message, if you have a CP store somewhere. The trivial case is that you use unique IDs in order to make processing idempotent, or you use to store states in the CP store in order to make out of order delivery of messages not an issue since you ignore every message which does not match the current state. This is more the matter of moving things in some place or the other. For all the cases where single processing is desirable but not extremely important, Disque “cheap” best-effort single processing can be enough and is very scalable.
> Last point: The fact that Disque calls its messages "jobs" makes me a little disappointed that it is, in fact, not a job management system. I'd love a solid, distributed job manager.
Disque is a general messaging system, but certain design characteristics are biased towards the idea that messages will be jobs. However it is opinionated about what should be and what should not be inside the broker itself. If you want more, it’s up to the client library to implement a more full fledged job processing system on top of what Disque provides.
Last note: given that I wrote Disque to provide something to the OSS world, I was not very interested in competing with something in particular: Kafka or RabbitMQ or some other message queue. Actually the less overlap the better, so my attempt was to create something different. There are things at which existing technologies will be better and maybe there will be things at which Disque will be better.
[+] [-] sandstrom|10 years ago|reply
Would love to read antirez response to these points. Oversights, omissions, alternative design?
[+] [-] amirmansour|10 years ago|reply
[+] [-] bipin_nag|10 years ago|reply
[+] [-] deanclatworthy|10 years ago|reply
[+] [-] qopp|10 years ago|reply
[+] [-] unknown|10 years ago|reply
[deleted]
[+] [-] ksec|10 years ago|reply
[+] [-] yowmamasita|10 years ago|reply
[+] [-] joneholland|10 years ago|reply
[+] [-] willcodeforfoo|10 years ago|reply
[+] [-] navaneethkn|10 years ago|reply
Currently, we have a huge background processing system built using Sidekiq backed by Redis. The biggest problem we are facing today is to run machines with lot of in-memory storage because jobs are queued to Redis and Redis works in-memory. These machines costs a lot.
I think the same issue will happen even here because this is also in-memory store and persistence works like how Redis handles it.
[+] [-] Dowwie|10 years ago|reply
[+] [-] leeoniya|10 years ago|reply
How is this compared to 0mq or nanomsg?
[+] [-] lobster_johnson|10 years ago|reply
I believe the same applies to Nanomsg.
[1] https://github.com/zeromq/malamute, https://github.com/sintaxi/waterfront, https://github.com/zeromq/zbroker
[+] [-] vdfs|10 years ago|reply
[+] [-] bastawhiz|10 years ago|reply
It should also be noted that you could probably successfully use Redis for much of what Disque does (Disque is based on Redis). Disque adds nice features, though, and removes most of the features of Redis that are outside its scope.
[+] [-] AznHisoka|10 years ago|reply
[+] [-] kfunk|10 years ago|reply
[+] [-] BradRuderman|10 years ago|reply
[+] [-] niutech|10 years ago|reply
[+] [-] JSno|10 years ago|reply
[deleted]