4 ms·
> For non-trivial distributed systems, behaviors that are correct for network transport use cases that are built into ZeroMQ are pathological for distributed sy
by snprbob86 14y ago
> For non-trivial distributed systems, behaviors that are correct for network transport use cases that are built into ZeroMQ are pathological for distributed system use cases.
I'm not sure what you mean. Please provide one or more concrete examples.
> ZeroMQ is a good for moving bits over a network but it is often not a correct choice for distributed systems.
It seems to me that distributed systems are defined by moving bits over a network.
You're right that there is some confusion regarding what ZeroMQ actually us. This is in no small part due to it's unfortunate name: ZeroMQ isn't a queue. It is implemented with queues, but that's because it sends and receives discrete messages instead of bytes, like it's underlying protocols. The underlying transport protocols use "buffers" to store bytes on their way from your application to their destination. When you have a buffer of messages, that's called a queue!
ZeroMQ is a network protocol for messaging. If you need custom scheduling, load balancing, etc, you can send and receive control messages on a secondary channel. The ZeroMQ Guide [1] is extremely enlightening in this regard. It's worth reading even if you never use ZeroMQ because all of the underlying principals apply to any network transport.
[1] http://zguide.zeromq.org/page:all http://zguide.zeromq.org/page:all
- scott_s 14y agoIt seems to me that distributed systems are defined by moving bits over a network. Sorta. People say "distributed system" to mean a single, logical system - typically an application, or maybe some middleware that executes applications - that runs on many machines. So, yes, a distributed system will have bits moving over the network. But the point that jandrewrogers is making is that in a distributed system, the network connections are often dependent on each other. That is, sending data on one connection will impact the sending of data on another connection. When someone says "distributed systems," you're probably thinking of a client application talking to a server, and maybe that server talking to some backend. That's not what people mean when they use the term. They mean, in the large case, thousands of processes running across hundreds of hosts, and all of those processes may communicate with each other. In the client-server-backend case, it's okay to assume that each of those connections are independent, and to reason about them as such. In the thousand-to-thousand case in a distributed system, it's often not okay to assume that each of those connections is independent.
- snprbob86 14y agoI've worked on more than one thousand+ machine distributed systems. These systems all use unix sockets extensively. Unix sockets are pretty much independent from each other from the developer's perspective. Scheduling and coordination is not a concern of the socket layer of the stack. In most production distributed systems, there is an agreed upon common RPC protocol and a variety of ad-hoc messaging protocols. Often, this is HTTP for RPC coupled with a variety of job worker systems, maybe an "enterprise" message broker, and line-oriented protocol or two, and a few other custom services. ZeroMQ isn't trying to replace unix sockets. Nor is it trying to be a panacea for distributed systems. It's trying to standardize a set of sound topology patterns with robust implementations over a common protocol. It's a damn useful tool for distributed systems. If you're system has everyone all chatting at once and saturating your links, that's not ZeroMQ's problem any more than it's unix sockets' problem.
- scott_s 14y agoIf you think "enterprise" when someone says "distributed system," then you are not talking about the same kind of thing that jandrewrogers and I are talking about. We're talking about high performance computing (HPC), where the communication patterns among nodes in a cluster can be complex and dominate performance. I disagree with his strong statement that if something like ZMQ works for you, it's not a distributed system, but otherwise, everything he has said is spot on.
- jandrewrogers 14y agoAny non-trivial distributed system will exhibit pathological feedback loops due to random events throughout the system synchronizing on each other and interacting in strange ways. It is a very common design problem for parallel systems. It manifests as suboptimal throughput in the best cases and total meltdown in the worst. The "cost" of a message operation is not fixed, and pathological operations are much more expensive by definition, so always selecting the least expensive operation that can be run at any point in time from the perspective of the node maximizes the aggregate throughput of the system. Of course, it also has the side effect of applying negative feedback to pathological positive feedback loops. This is actually a mathematics consequence, so there are limited workarounds. Nor is it intuitive. Making parts of the system slower, with no other changes, can increase the aggregate throughput of the distributed system. For non-trivial distributed systems, you are unlikely to produce a robustly optimal design by accident.
- jandrewrogers 14y agoYou are not understanding the nature of the problem. I have not only used ZMQ extensively in distributed systems but have modified the internals for some purposes. The problem is intrinsic to its design. Robust, high-throughput distributed systems are built around the concept of Nash equilibria. To ensure that, there is an optimal ordering to the set of possible message operations over those queues. It gives them a priority and you attempt to schedule operations in approximately optimal order. The ordering is not fixed; every message operation on a queue may have side effects that alters the total ordering of message operations for any process associated with that queue. Consequently, the schedule of operations over the entire set of message queues must be adaptively and dynamically imposed in order to approximate a good Nash behavior. In real software, this is usually just a simple state machine that adaptively prioritizes operations based on the aggregate state of those messages and queues. Also, we usually approximate ideal scheduling for performance reasons (and good approximations are usually good enough). Priority modifying side effects propagate throughout the distributed system; local modifications in priority provide stabilizing negative feedback to the global behavior. (See also: greedy routing optimization problems etc. This is a pretty complex area of mathematics.) Consequently, there are some popular design choices for network server systems that tend to work poorly for distributed systems, either because they prevent the creation of an effective operation scheduler or because they hinder the propagation of negative feedback that prevents pathological interactions. Giving every socket its own OS thread or similar is right out. That lets the operating system decide when operations are scheduled and the operating system has no concept of prioritization in the sense that is important for distributed systems. Trying to use thread interlocks to impose an order leads to pathological context-switching storms. High-performance schedulers are cooperative. (You can design a schedule with multiple threads that executes with minimal interlocks, but it is not trivial.) Unlimited buffering and hard-limited buffering are also poor abstractions because they obscure the state of a queue. Robust schedulers often prioritize queues based in part on how it reduces total buffering. For some good designs, you can prove the existence of a reasonable upper bound on the total buffers required for a node or queue with no hard limits on any particular buffer. It is an elegant side effect of scheduling interactions in a distributed system but requires a scheduler that is aware of many aspects of buffer state. In principle, it should be possible to design a message queue abstraction designed for the requirements of distributed systems. It would not be as simple as ZMQ though. ZMQ is not designed to support that use case, so in cases where I am building a non-trivial distributed system protocol, we build on top of epoll directly. It is not a knock against ZMQ, it was designed for other purposes.