by mryall · 15y ago · 0 comments
If this unbounded message generation is happening within the system, again there is something wrong. You shouldn't be in a situation where a process is producing messages which other parts of the system cannot consume.
That's attractive in general, but is it necessarily possible?
Assume a planar grid with O(N2) nodes of which O(N) edge nodes that can accept a message for a given node somewhere near the center. In other words, that "given node" is O(N) steps away from any edge node.
Suppose that said given node has limited capacity. How can it keep those edge nodes aware of its capacity without wasting capacity or requiring O(N2) queuing at said given node? Remember - it takes O(N) time to get a message from the given node to any edge node and during that time and there are O(N2) places for a message to be in the network at any moment in time.
Now repeat for the other O(N2) interior nodes.
For real time traffic, where queuing doesn't make sense, there isn't anything else you can do really.
Let's assume that we have 5 edge nodes and that each is configured to send t traffic. The total amount of traffic that they can send is 5t. If the inner node can handle 5t, you won't need to drop traffic in the network. However, you're likely to drop traffic unnecessarily at an edge node.
Suppose that you have 4t worth of traffic continuously. Clearly the inner node can handle that.
However, consider what happens if all of the traffic during hour n tries to enter the network at edge node n.
For example, during hour 0, node 1-5 see no traffic and node 0 sees 4t worth of traffic. By configuration, node 0 drops 3t and sends t to the inner node. Since none of the other nodes are sending any traffic, the inner node only sees t worth of traffic even though it could handle 5t.
You can try to get around this problem by dynamically configuring the edge nodes, but since they're as much as N apart and they're responding to presented demand, that configuration is always stale.
You can guarantee that you don't overload the inner node, but only if you're willing to waste some of its capability in some circumstances.
Edit: Here's one (http://www.haskell.org/pipermail/haskell-cafe/2006-January/0...):
"Regarding the issue of why a logger process in Erlang does not get overwhelved, this is the reply I got from Raimo Niskanen (Erlang team at Ericsson):
There is a small fix in the scheduler for the standard producer/consumer problem: A process that sends to a receiver having a large receive queue gets punished with a large reduction (number of function calls) count for the send operation, and will therefore get smaller scheduling slots."
Sending to a mailbox costs reductions proportional to how many messages are already queued. While this isn't a perfect solution, it should influence the scheduler quite a bit. (Imagine trying to do that sort of thing in node.js!)