<div dir="ltr">...and the receiver code is:<br><br>package com.optionshouse.test;<br><br>import java.io.IOException;<br><br>import com.rabbitmq.client.*;<br>import com.rabbitmq.client.Channel;<br>import com.rabbitmq.client.AMQP;<br>
<br><br>public class TestReceiver {<br><br> public static boolean doStop = false;<br><br> public static void main(String[] args) {<br><br> try {<br> ConnectionParameters params = new ConnectionParameters();<br>
params.setUsername("guest");<br> params.setPassword("guest");<br> params.setVirtualHost("/");<br> params.setRequestedHeartbeat(0);<br> ConnectionFactory factory = new ConnectionFactory(params);<br>
Connection conn = factory.newConnection("localhost", 5672);<br><br> Channel channel = conn.createChannel();<br> int ticket = channel.accessRequest("/data");<br><br> channel.exchangeDeclare(ticket, "TEST", "direct");<br>
channel.queueDeclare(ticket, "action.test");<br> long count = 0;<br> long start = 0;<br> while (!doStop) {<br> boolean noAck = false;<br> GetResponse response = channel.basicGet(ticket, "action.test", true);<br>
if (response == null) {<br><br> } else {<br> if (start == 0)<br> start = System.currentTimeMillis();<br> else{<br> count++;<br>
if (count % 1000 == 0) {<br> long now = System.currentTimeMillis();<br> double tis = (now-start)/1000d;<br> System.out.println("count:"+count+", tis: "+tis+", MPS: "+(count/tis));<br>
}<br> }<br> AMQP.BasicProperties props = response.getProps();<br> byte[] body = response.getBody();<br> long deliveryTag = response.getEnvelope().getDeliveryTag();<br>
//channel.basicAck(deliveryTag, false);<br> }<br> }<br> }<br> catch (IOException ex) {<br> ex.printStackTrace();<br> }<br> }<br> <br>}<br>
<br><div class="gmail_quote">On Fri, Aug 29, 2008 at 5:17 PM, Ryan Pratt <span dir="ltr"><<a href="mailto:ryan.pratt@gmail.com">ryan.pratt@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">I have been running some small performance tests and have not seen the throughput I was expecting. I want to see if my numbers are similar to what others have seen, or if something else (setup, etc) is causing my performance to be not so good.<br>
<br>I have a single broker running with a sender and receiver all on the same machine. The machine is a dual quad core 2.66 GHz Xeon with 8 gigs of memory. I have to throttle the sender to keep the queue from backing way up, which then causes the broker to basically go to a crawl. The sender sends 40 messages then sleeps for 5 millseconds, and loops doing this continually. If a run a receiver that continuously calls basicGet I am seeing a max of about 4000 messages per second. The message I am sending is "Hello, World!"<br>
If I add a second Receiver on the same queue I end up getting it up to about 6000 messages per second. 3 Receivers is about the same as 2. Maybe my expectations are off but I was hoping to see at least 20000 messages per second going through. The sender and receiver code is attached. Is there anything obviously wrong with my setup, or is this throughput what I should expect to see? Thanks<br>
<br>package com.optionshouse.test;<br><br>import java.io.IOException;<br>import com.rabbitmq.client.*;<br>import com.rabbitmq.client.Channel;<br>import com.rabbitmq.client.AMQP;<br>import java.util.*;<br><br>public class TestSender {<br>
<br> public static boolean doStop = false;<br><br> public static void main(String[] args) {<br><br> try {<br> ConnectionParameters params = new ConnectionParameters();<br> params.setUsername("guest");<br>
params.setPassword("guest");<br> params.setVirtualHost("/");<br> params.setRequestedHeartbeat(0);<br> ConnectionFactory factory = new ConnectionFactory(params);<br>
Connection conn = factory.newConnection("localhost", 5672);<br><br> Channel channel = conn.createChannel();<br> int ticket = channel.accessRequest("/data");<br>
channel.exchangeDeclare(ticket, "TEST", "direct");<br> channel.queueDeclare(ticket, "action.test");<br> channel.queueBind(ticket, "action.test", "TEST", "action.test");<br>
<br> byte[] messageBodyBytes = "Hello, world!".getBytes();<br>int counter = 0;<br> while (!doStop) {<br> channel.basicPublish(ticket, "TEST", "action.test", null, messageBodyBytes);<br>
counter++;<br><br> if (counter == 30) {<br> try {<br> counter = 0;<br> Thread.sleep(5);<br> }<br>
catch (InterruptedException ex) {<br>
ex.printStackTrace();<br> }<br> }<br> }<br><br> }<br> catch (IOException ex) {<br> ex.printStackTrace();<br> }<br>
}<br><br>}<br><br><br><br><br><br></div>
</blockquote></div><br></div>