<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Go for it Chris</div><br><div><div>On 8/09/2009, at 11:36 AM, Chris Duncan wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi Aisha,</div>
<div>&nbsp;</div>
<div>Hope you don't mind me butting in here.<br><br>2009/9/7 Aisha Fenton <span dir="ltr">&lt;<a href="mailto:aisha.fenton@gmail.com">aisha.fenton@gmail.com</a>&gt;</span><br></div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div style="WORD-WRAP: break-word">
<div>Hi Chunk.</div>
<div>I don't know Suhail. And his problem may be different from mine.</div>
<div><br></div>
<div>
<div>To isolate the problem, I've reduce what I'm doing down to the attached code files. One pushes messages, the other pops them.</div>
<div><br></div>
<div>I see the problem even when only test_push.rb is running (as long as the queue is sufficiently pre-populated). Nothing else is using rabbitmq when I'm doing the test.</div>
<div><br></div>
<div>I'm getting the same problem on several different machines here -- my local MacOSX box and a server class Debian box.&nbsp;</div>
<div><br></div>
<div><br></div></div>
<div>
<blockquote type="cite">
<div style="WORD-WRAP: break-word">
<div>exchange - durable or not?</div></div></blockquote>
<div>not durable</div>
<div class="im"><br>
<blockquote type="cite">
<div style="WORD-WRAP: break-word">
<div>exchange - type? (Looks like "fanout" from the original post)</div></div></blockquote></div>
<div>fanout</div>
<div class="im"><br>
<blockquote type="cite">
<div style="WORD-WRAP: break-word">
<div>number of bindings per exchange</div></div></blockquote></div>
<div>1</div><br>
<blockquote type="cite">
<div style="WORD-WRAP: break-word">
<div>queue &nbsp;- durable?</div></div></blockquote>
<div>not durable</div>
<div class="im"><br>
<blockquote type="cite">
<div style="WORD-WRAP: break-word">
<div>publishing settings - require ack? persistent? immediate?</div></div></blockquote></div>
<div>no ack, non persistent, and non immediate.</div>
<div class="im"><br>
<blockquote type="cite">
<div style="WORD-WRAP: break-word">
<div>message size? 1K according to the original post</div></div></blockquote></div>
<div>&lt; 1K</div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><b>test_push.rb&nbsp;</b></div>
<div><b>---</b></div>
<div><br></div>
<div>
<div><i>require "rubygems"</i></div>
<div><i>require "bunny"</i></div>
<div><i><br></i></div>
<div><i>EXCHANGE = "raw_telemetry"</i></div>
<div><i>QUEUE = "process_telemetry"</i></div>
<div class="im">
<div><i><br></i></div>
<div><i>count ||= 0</i></div>
<div><i>prev_time ||= Time.now</i></div></div>
<div class="im">
<div><i>msg_server = Bunny.new(:spec =&gt; '08')</i></div>
<div><i>msg_server.start</i></div>
<div><i><br></i></div></div>
<div><i>msg_server.exchange(EXCHANGE, :type &nbsp;=&gt; :fanout)</i></div>
<div><i>msg_server.queue(QUEUE).bind(EXCHANGE)</i></div>
<div><i><br></i></div>
<div><i>loop do</i></div>
<div><i><br></i></div>
<div><i>&nbsp;&nbsp;msg_server.exchange(EXCHANGE).publish("This is my msg")</i></div>
<div class="im">
<div><i>&nbsp;&nbsp;</i></div>
<div><i>&nbsp;&nbsp;count += 1</i></div>
<div><i>&nbsp;&nbsp;if count &gt; 100</i></div>
<div><i>&nbsp;&nbsp; &nbsp;t = Time.now</i></div></div>
<div><i>&nbsp;&nbsp; &nbsp;puts("msgs pushes per sec: #{count / (t - prev_time)}")</i></div>
<div class="im">
<div><i>&nbsp;&nbsp; &nbsp;prev_time = t</i></div>
<div><i>&nbsp;&nbsp; &nbsp;count = 0</i></div>
<div><i>&nbsp;&nbsp;end</i></div>
<div><i>&nbsp;&nbsp; &nbsp;</i></div>
<div><i>end</i></div>
<div><i><br></i></div></div>
<div><i><span style="FONT-STYLE: normal">
<div><b>test_pop.rb&nbsp;</b></div>
<div><b>---</b></div>
<div><i><span style="FONT-STYLE: normal"><br></span></i></div></span></i></div>
<div><i>
<div class="im">
<div>require "rubygems"</div>
<div>require "bunny"</div>
<div><br></div>
<div>@msg_server = Bunny.new(:spec =&gt; '08')</div>
<div>@msg_server.start</div>
<div><br></div>
<div>def start</div>
<div>&nbsp;&nbsp;count ||= 0</div>
<div>&nbsp;&nbsp;prev_time ||= Time.now</div>
<div>&nbsp;&nbsp;queue = @msg_server.queue("process_telemetry")</div>
<div><br></div></div>
<div class="im">
<div>&nbsp;&nbsp;loop do</div>
<div>&nbsp;&nbsp; &nbsp;result = queue.pop</div>
<div>&nbsp;&nbsp; &nbsp;next if result == :queue_empty</div>
<div>&nbsp;&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp;count += 1</div>
<div>&nbsp;&nbsp; &nbsp;if count &gt; 100</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp;t = Time.now</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp;puts("msgs pops per sec: #{count / (t - prev_time)}")</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp;prev_time = t</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp;count = 0</div>
<div>&nbsp;&nbsp; &nbsp;end &nbsp; &nbsp;</div>
<div>&nbsp;&nbsp;end</div>
<div><br></div>
<div>end</div>
<div><br></div>
<div>begin</div>
<div>&nbsp;&nbsp;start()</div>
<div>ensure</div>
<div>&nbsp;&nbsp;puts "stopping"</div>
<div>&nbsp;&nbsp;@msg_server.stop</div>
<div>end</div>
<div></div></div></i>&nbsp;</div></div></div></div></blockquote></div>
<div></div>
<div>&nbsp;</div>
<div>I have some observations -</div>
<div>&nbsp;</div>
<div>1. In your test_push.rb you have the line -</div>
<div>&nbsp;</div>
<div><em>msg_server.exchange(EXCHANGE).publish("This is my msg")</em></div>
<div><em></em>&nbsp;</div>
<div>The exchange method declares an exchange, so you are doing this every time you publish a message which will slow things down. Declare the exchange using a variable outside the loop like this -</div>
<div>&nbsp;</div>
<div><em>my_exchange = msg_server.exchange(EXCHANGE, :type &nbsp;=&gt; :fanout)</em></div>
<div><em></em>&nbsp;</div>
<div>Then use the variable inside the loop -</div>
<div><em></em>&nbsp;</div>
<div><em>my_exchange.publish("This is my msg")</em></div>
<div><em></em>&nbsp;</div>
<div>I think Paolo has highlighted the same thing.</div>
<div>&nbsp;</div>
<div>2. In your test_pop.rb you don't need to specify <em>:spec =&gt; '08'.</em> Bunny.new defaults to the AMQP 0-8 spec version.</div>
<div>&nbsp;</div>
<div>Also, do you mean to have -</div>
<div>&nbsp;</div>
<div><em>next if result == :queue_empty</em></div>
<div><em></em>&nbsp;</div>
<div>How are you breaking out of the loop? Might you want to use 'break' instead of 'next'?</div>
<div>&nbsp;</div>
<div>3. A Bunny instance&nbsp;only ever uses 2 channels unless you explicitly create more. Since you don't seem to be creating more channels I don't think that's where your issue lies.&nbsp;</div>
<div><br>-- <br>Regards<br><br>Chris<br></div>
</blockquote></div><br></body></html>