[rabbitmq-discuss] performance

Ryan Pratt ryan.pratt at gmail.com
Fri Aug 29 23:20:03 BST 2008


...and the receiver code is:

package com.optionshouse.test;

import java.io.IOException;

import com.rabbitmq.client.*;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.AMQP;


public class TestReceiver {

    public static boolean doStop = false;

    public static void main(String[] args) {

        try {
            ConnectionParameters params = new ConnectionParameters();
            params.setUsername("guest");
            params.setPassword("guest");
            params.setVirtualHost("/");
            params.setRequestedHeartbeat(0);
            ConnectionFactory factory = new ConnectionFactory(params);
            Connection conn = factory.newConnection("localhost", 5672);

            Channel channel = conn.createChannel();
            int ticket = channel.accessRequest("/data");

            channel.exchangeDeclare(ticket, "TEST", "direct");
            channel.queueDeclare(ticket, "action.test");
            long count = 0;
            long start = 0;
            while (!doStop) {
                boolean noAck = false;
                GetResponse response = channel.basicGet(ticket,
"action.test", true);
                if (response == null) {

                } else {
                    if (start == 0)
                        start = System.currentTimeMillis();
                    else{
                        count++;
                        if (count % 1000 == 0) {
                            long now = System.currentTimeMillis();
                            double tis = (now-start)/1000d;
                            System.out.println("count:"+count+", tis:
"+tis+", MPS: "+(count/tis));
                        }
                    }
                    AMQP.BasicProperties props = response.getProps();
                    byte[] body = response.getBody();
                    long deliveryTag =
response.getEnvelope().getDeliveryTag();
                    //channel.basicAck(deliveryTag, false);
                }
            }
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }
    }

}

On Fri, Aug 29, 2008 at 5:17 PM, Ryan Pratt <ryan.pratt at gmail.com> wrote:

> 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.
>
> 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!"
> 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
>
> package com.optionshouse.test;
>
> import java.io.IOException;
> import com.rabbitmq.client.*;
> import com.rabbitmq.client.Channel;
> import com.rabbitmq.client.AMQP;
> import java.util.*;
>
> public class TestSender {
>
>     public static boolean doStop = false;
>
>     public static void main(String[] args) {
>
>         try {
>                 ConnectionParameters params = new ConnectionParameters();
>                 params.setUsername("guest");
>                 params.setPassword("guest");
>                 params.setVirtualHost("/");
>                 params.setRequestedHeartbeat(0);
>                 ConnectionFactory factory = new ConnectionFactory(params);
>                 Connection conn = factory.newConnection("localhost", 5672);
>
>                 Channel channel = conn.createChannel();
>                 int ticket = channel.accessRequest("/data");
>                 channel.exchangeDeclare(ticket, "TEST", "direct");
>                 channel.queueDeclare(ticket, "action.test");
>                 channel.queueBind(ticket, "action.test", "TEST",
> "action.test");
>
>                 byte[] messageBodyBytes = "Hello, world!".getBytes();
> int counter = 0;
>                 while (!doStop) {
>                     channel.basicPublish(ticket, "TEST", "action.test",
> null, messageBodyBytes);
>                     counter++;
>
>                     if (counter == 30) {
>                     try {
>                         counter = 0;
>                         Thread.sleep(5);
>                     }
>                     catch (InterruptedException ex) {
>                         ex.printStackTrace();
>                     }
>                     }
>                 }
>
>         }
>         catch (IOException ex) {
>             ex.printStackTrace();
>         }
>     }
>
> }
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20080829/8ca3b38b/attachment.htm 


More information about the rabbitmq-discuss mailing list