<div>Hi Aisha,</div>
<div> </div>
<div>Hope you don't mind me butting in here.<br><br>2009/9/7 Aisha Fenton <span dir="ltr"><<a href="mailto:aisha.fenton@gmail.com">aisha.fenton@gmail.com</a>></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. </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 - 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>< 1K</div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><b>test_push.rb </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 => '08')</i></div>
<div><i>msg_server.start</i></div>
<div><i><br></i></div></div>
<div><i>msg_server.exchange(EXCHANGE, :type => :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> msg_server.exchange(EXCHANGE).publish("This is my msg")</i></div>
<div class="im">
<div><i> </i></div>
<div><i> count += 1</i></div>
<div><i> if count > 100</i></div>
<div><i> t = Time.now</i></div></div>
<div><i> puts("msgs pushes per sec: #{count / (t - prev_time)}")</i></div>
<div class="im">
<div><i> prev_time = t</i></div>
<div><i> count = 0</i></div>
<div><i> end</i></div>
<div><i> </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 </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 => '08')</div>
<div>@msg_server.start</div>
<div><br></div>
<div>def start</div>
<div> count ||= 0</div>
<div> prev_time ||= Time.now</div>
<div> queue = @msg_server.queue("process_telemetry")</div>
<div><br></div></div>
<div class="im">
<div> loop do</div>
<div> result = queue.pop</div>
<div> next if result == :queue_empty</div>
<div> </div>
<div> count += 1</div>
<div> if count > 100</div>
<div> t = Time.now</div>
<div> puts("msgs pops per sec: #{count / (t - prev_time)}")</div>
<div> prev_time = t</div>
<div> count = 0</div>
<div> end </div>
<div> end</div>
<div><br></div>
<div>end</div>
<div><br></div>
<div>begin</div>
<div> start()</div>
<div>ensure</div>
<div> puts "stopping"</div>
<div> @msg_server.stop</div>
<div>end</div>
<div></div></div></i> </div></div></div></div></blockquote></div>
<div></div>
<div> </div>
<div>I have some observations -</div>
<div> </div>
<div>1. In your test_push.rb you have the line -</div>
<div> </div>
<div><em>msg_server.exchange(EXCHANGE).publish("This is my msg")</em></div>
<div><em></em> </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> </div>
<div><em>my_exchange = msg_server.exchange(EXCHANGE, :type => :fanout)</em></div>
<div><em></em> </div>
<div>Then use the variable inside the loop -</div>
<div><em></em> </div>
<div><em>my_exchange.publish("This is my msg")</em></div>
<div><em></em> </div>
<div>I think Paolo has highlighted the same thing.</div>
<div> </div>
<div>2. In your test_pop.rb you don't need to specify <em>:spec => '08'.</em> Bunny.new defaults to the AMQP 0-8 spec version.</div>
<div> </div>
<div>Also, do you mean to have -</div>
<div> </div>
<div><em>next if result == :queue_empty</em></div>
<div><em></em> </div>
<div>How are you breaking out of the loop? Might you want to use 'break' instead of 'next'?</div>
<div> </div>
<div>3. A Bunny instance 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. </div>
<div><br>-- <br>Regards<br><br>Chris<br></div>