[rabbitmq-discuss] dropped messages on low volume

Joel Reymont joelr1 at gmail.com
Wed Jul 1 12:48:15 BST 2009


I'm running Erlang R13B01 and RabbitMQ 1.5.3 server with the Erlang  
client library.

I start 100 Erlang processes that subscribe to a single topic and  
publish a single message once all the client processes are ready. Only  
a random number of my client processes receive the message and the  
number is less than 50.

Is there an explanation?

More detail...

Client processes synchronize by monitoring a single Erlang process  
(barrier). Every client subscribes to the topic only when notified  
that the barrier is open ({'DOWN', _, process, Pid, normal}). Clients  
bump a counter in the barrier when they are up and running and the  
barrier opens once the target # of bumps has been reached.

In other words, I don't publish until everyone is ready and subscribed.

The client subscription process looks like this, where  
common:random_token() returns a 16-digit hash as a string:

     QS = [$t, $h, $q|common:random_token()],
     Q = list_to_binary(QS),
     Tok1 = common:random_token(),
     Tag = list_to_binary([QS, Tok1]),
     lib_amqp:declare_exchange(State#state.channel, Topic, <<"topic">>),
     lib_amqp:declare_queue(State#state.channel, Q),
     lib_amqp:bind_queue(State#state.channel, Topic, Q,  
State#state.type),
     lib_amqp:subscribe(State#state.channel, Q, self(), Tag),

Publishing a message then looks like this:

     Con = lib_amqp:start_connection(Rabbit),
     Chan = lib_amqp:start_channel(Con),
     Exch = list_to_binary(Topic),
     #'exchange.declare_ok'{} = lib_amqp:declare_exchange(Chan, Exch,  
<<"topic">>),
     ...
     lib_amqp:publish(Chan, Exch, <<"raw">>, MsgWithId),
     lib_amqp:publish(Chan, Exch, <<"http">>, HttpMsg),
     lib_amqp:publish(Chan, Exch, <<"flash">>, FlashMsg),
     lib_amqp:teardown(Con, Chan),

The name of the exchange is always the topic.

I know that 100 clients have subscribed and received messages because  
I trace in Erlang and count the 'basic.consume_ok' and 'basic.deliver'  
messages, e.g.

grep "basic.consume_ok" /tmp/foo|wc -l
grep "basic.deliver" /tmp/foo|wc -l

What am I doing wrong and is there a way to do it better?

All I want is to push a single message to hundreds of thousands of  
subscribers with minimum latency.

	Thanks, Joel

---
Mac hacker with a performance bent
http://www.linkedin.com/in/joelreymont





More information about the rabbitmq-discuss mailing list