rabbitmq / rabbitmq-common

Common library used by rabbitmq-server and rabbitmq-erlang-client
Other
66 stars 112 forks source link

optimisation for 'delegate' #348

Closed tomyouyou closed 4 years ago

tomyouyou commented 4 years ago

%% 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. Above description is copied from delegate.erl.

If a message is sent to only one queue(in most application scenarios), passing through the 'delegate' is meaningless. Otherwise, it increases the delay of the message and the possibility of 'delegate' congestion.

The PR is based on the following considerations:

  1. It does not affect the operation that must go through the 'delegate', for example: {Mem, _BadNodes} = delegate:invoke(Pids, {erlang, process_info, [memory]}) or {Results, Errors} = delegate:invoke(MemberPids, ?DELEGATE_PREFIX, FunOrMFA)
  2. If there is only one PID for each node of the target, the safe_invoke is directly called without passing through the 'delegate'.
michaelklishin commented 4 years ago

It would also be very nice to see what kind of measurable improvements this leads to. Have you observed delegate process congestion in metrics of sorts? What kind of difference does this change make there? And for your real world RabbitMQ client workload throughput?

Collecting some numbers would help both convince our team and for you to prove that the change indeed does what it promises to do.

michaelklishin commented 4 years ago

(PR closed because this branch contains rejected changes and reverts, not because the idea is something we would not consider; specific feedback was submitted above)