diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2015-02-04 12:17:29 +0000 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2015-02-04 12:17:29 +0000 |
| commit | 9a167fe6b2d12bd453f4f80d70b1e57ab594e754 (patch) | |
| tree | 0ff7fbd12c609f6ffc457e817845eaef6c342eaa /src/delegate.erl | |
| parent | ccc25f1bf21acaef8ae834745ce4c3c42420baa5 (diff) | |
| parent | 09cbb31bc7c1d437804c90f6c83d8b3904b9615a (diff) | |
| download | rabbitmq-server-git-9a167fe6b2d12bd453f4f80d70b1e57ab594e754.tar.gz | |
Merge bug26573
Diffstat (limited to 'src/delegate.erl')
| -rw-r--r-- | src/delegate.erl | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/delegate.erl b/src/delegate.erl index 378759a64b..1a0df98220 100644 --- a/src/delegate.erl +++ b/src/delegate.erl @@ -16,6 +16,35 @@ -module(delegate). +%% delegate is an alternative way of doing remote calls. Compared to +%% the rpc module, it reduces inter-node communication. For example, +%% if a message is routed to 1,000 queues on node A and needs to be +%% propagated to nodes B and C, it would be nice to avoid doing 2,000 +%% remote casts to queue processes. +%% +%% An important issue here is preserving order - we need to make sure +%% that messages from a certain channel to a certain queue take a +%% consistent route, to prevent them being reordered. In fact all +%% AMQP-ish things (such as queue declaration results and basic.get) +%% must take the same route as well, to ensure that clients see causal +%% ordering correctly. Therefore we have a rather generic mechanism +%% here rather than just a message-reflector. That's also why we pick +%% the delegate process to use based on a hash of the source pid. +%% +%% When a function is invoked using delegate:invoke/2, delegate:call/2 +%% or delegate:cast/2 on a group of pids, the pids are first split +%% into local and remote ones. Remote processes are then grouped by +%% node. The function is then invoked locally and on every node (using +%% gen_server2:multi/4) as many times as there are processes on that +%% node, sequentially. +%% +%% Errors returned when executing functions on remote nodes are re-raised +%% in the caller. +%% +%% RabbitMQ starts a pool of delegate processes on boot. The size of +%% the pool is configurable, the aim is to make sure we don't have too +%% few delegates and thus limit performance on many-CPU machines. + -behaviour(gen_server2). -export([start_link/1, invoke_no_result/2, invoke/2, |
