[rabbitmq-discuss] New exchange type

Matthias Radestock matthias at lshift.net
Wed Apr 23 06:18:57 BST 2008


Kyle,

Kyle wrote:
> Matthias,
>     - use a flag in the process dictionary to indicate whether the
>     random number generator has been seeded. Check/set that flag in your
>     current code that invokes random:uniform. This has the same effect
>     as the previous approach but is a less intrusive change since you
>     don't need to touch any other modules.
> 
> 
> Got this working, and less intrusive wins out in my mind. I'll send out 
> another version of the diff when I get to the above change, or if I 
> leave that on the back burner for too long.

Btw, if you look at the code (and docs) of the 'random' module you'll 
see it is using the process dictionary already to remember the last 
seed. So, to save duplication of work, I'd use something like the following:

random_uniform(N) ->
     Seed = case get(random_seed) of
                undefined -> erlang:now();
                Tuple -> Tuple
            end,
     {V, NewSeed} = random:uniform_s(N, Seed),
     put(random_seed, NewSeed),
     V.

>  From what I could tell from the RabbitMQ docs,  even if I have a single 
> exchange, messages can be routed through any node in the cluster. 
> Therefore there should be no significant bottleneck with a single 
> exchange, because there is no single node that all messages must go 
> through. With a single queue, however, every message has to be sent to 
> the machine on which that queue lives, after which different subscribers 
> can pull messages off. This looks like a bottleneck to me, where all 
> messages go through one machine, whereas a single exchange does not have 
> that problem (unless I missed something).

That analysis is correct. I think what Martin is getting at is that this 
is really an implementation issue - in principle AMQP queues do what you 
want, it just so happens that in RabbitMQ they are implemented as a 
single (Erlang) process rather than being distributed. The latter is 
something we are looking into, but it will take a while to implement. 
Meanwhile your solution is an excellent way of addressing the problem.


Matthias.




More information about the rabbitmq-discuss mailing list