[rabbitmq-discuss] RabbitMQ C library function amqp_simple_wait_frame takes 400 ms

Jim Irrer irrer at umich.edu
Thu Jul 1 19:08:59 BST 2010


I suggest modifying the C client to set TCP_NODELAY in the amqp_open_socket
function.  The
Java version of the code seems to do this in the SocketFrameHandler class
with the setTcpNoDelay
call.  It seems like this would be the preferred mode in most situations and
should be the default
behavior.  If the user does not like it, they can always turn it off by
calling setsockopt.

Thanks,

- Jim

Jim Irrer     irrer at umich.edu       (734) 647-4409
University of Michigan Hospital Radiation Oncology
519 W. William St.             Ann Arbor, MI 48103


On Thu, Jul 1, 2010 at 2:08 PM, Jim Irrer <irrer at umich.edu> wrote:

> I had tried setting TCP_NODELAY before but did it this way:
>
> setsockopt(socketFD, SOL_SOCKET, TCP_NODELAY, &one, sizeof(one));
>
> and instead it needed to be done like this:
>
> setsockopt(socketFD, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
>
> Yes, that's it.  Runs really fast now.  1.4294 milliseconds per round
> trip.  It seems like it would be
> faster than that, but it's way better than 400ms and is sufficient for our
> purposes.  I suppose it's
> doing program context switches  If I bump into
> any
>
> Thanks for not reading the part of my post that said that I had already
> tried this, and then posting the
> correct version of the call.  :)    And as a bonus you don't have to be
> root do to make the call, which
> was also suspicious because you can do it in Java without being root.
>
> - Jim
>
> Jim Irrer     irrer at umich.edu       (734) 647-4409
>
> University of Michigan Hospital Radiation Oncology
> 519 W. William St.             Ann Arbor, MI 48103
>
>
> On Wed, Jun 30, 2010 at 9:53 PM, Tony Garnock-Jones <tonyg at lshift.net>wrote:
>
>> Hi Jim,
>>
>> I think it's possible that Brett is on the right track with his suggestion
>> of
>> the Nagle algorithm being responsible for the delays. You could try the
>> following:
>>
>>  int one = 1;
>>  setsockopt(amqp_get_sockfd(conn),
>>             IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
>>
>> Cheers,
>>  Tony
>>
>>
>> Jim Irrer wrote:
>> > Hi All -
>> >
>> > I'm working on two functions that act as a client-server pair.  They
>> > use two amq.direct queues to communicate.  When ever either of
>> > them calls the amqp_simple_wait_frame function, it does not return
>> > for 436618 microseconds.
>> >
>> > Some other background info that might be relevant:
>> >
>> > If I only send messages in one direction it's really fast.
>> >
>> > Both processes are using separate connectors and different sockets.
>> >
>> > I used the amqp_consumer.c amqp_producer.c code in
>> > the examples directory as a reference.
>> >
>> > Is there a way to avoid this delay?
>> >
>> > Also ...
>> >
>> > Could I use the same socket in each program as long as it was only
>> > used by one thread at a time?
>> >
>> > Could I use the same connection in each program if it was only
>> > used by one thread at a time?
>> >
>> > Thanks for any insights,
>> >
>> > - Jim
>> >
>> > Jim Irrer     irrer at umich.edu <mailto:irrer at umich.edu>       (734)
>> 647-4409
>> > University of Michigan Hospital Radiation Oncology
>> > 519 W. William St.             Ann Arbor, MI 48103
>> >
>> >
>> > ------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > rabbitmq-discuss mailing list
>> > rabbitmq-discuss at lists.rabbitmq.com
>> > https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20100701/2688fe01/attachment.htm>


More information about the rabbitmq-discuss mailing list