[rabbitmq-discuss] Unexpected Behavior When Using the "X-Consistent-Hash" Exchange Type
Simon MacMullen
simon at rabbitmq.com
Mon Oct 21 16:30:44 BST 2013
On 17/10/2013 12:13AM, Richard Raseley wrote:
> This leaves me with the following questions:
>
> 1) Is it true to say that it is now just a matter of choosing what
> tradeoff we want to make in terms of performance vs. uniformity of
> distribution?
Yes.
> 2) Can anyone comment on Michael's previous comment on how using a
> UUID would be handled as the value in the hashed header? The numbers
> above don't seem to show a large difference between using a random
> integer and a UUID.
No, they don't. The actual hashing is done by the Erlang function
phash2, which will hash a UUID or an integer or any Erlang term.
> As a final question, can anyone on the engineering team provide a
> recommendation as to the best way to generate a header value for
> hashing use in terms of what will implicitly provide the most even
> distribution?
It doesn't matter.
Yeah, this confused me too when I first started looking at the hashing
exchange. As long as you use something that tends towards unique-ish
values then any unevenness in the routing displayed by the CHX is caused
by the distribution of the buckets in its routing table - this is
influenced by the number of points each binding has (as you have already
noted) *and nothing else*.
You can observe this easily - create some queues and bindings with 1
point each. Then publish some messages with random integers as the
routing keys. Observe the uneven distribution. Then purge all the queues
(but don't delete and start again) and re-run the test with UUIDs or
message sequence IDs or whatever. Not only will the distribution still
be uneven, but it will be uneven in exactly the same way.
Cheers, Simon
--
Simon MacMullen
RabbitMQ, Pivotal
More information about the rabbitmq-discuss
mailing list