Michael
Michael

Reputation: 606

spring-rabbit client using lots of cpu

I am running a spring-boot application in ec2 on a c3.large machine. It initializes a spring-rabbit client, which starts up its own thread.

After profiling my application using YourKit, I see that a lot of time is spent inside the rabbit client thread, inside: com.rabbitmq.client.impl.AMQConnection$MainLoop.run() specifically down in java.io.DataStream.readUnsignedByte()

To me this looks like there is a while loop that continuously blocks on getting some input on a socket from the RabbitMQ server.

Has anyone run into this? Am I reading the profiling results correctly? Is there a way to make the amqp client be non-blocking?

Upvotes: 1

Views: 685

Answers (1)

Gary Russell
Gary Russell

Reputation: 174584

That code (com.rabbitmq.client) is in the underlying amqp-client (RabbitMQ Java client) code used by Spring AMQP.

To me this looks like there is a while loop that continuously blocks on getting some input on a socket from the RabbitMQ server.

Yes, but when it blocks waiting for data, it does not use CPU - only when data is available does that method return. It's not spinning the cpu waiting for data.

Upvotes: 3

Related Questions