Git Product home page Git Product logo

Comments (6)

garyrussell avatar garyrussell commented on April 27, 2024 2

Closing for now due to no response; please reopen if you still have an issue.

from spring-amqp.

garyrussell avatar garyrussell commented on April 27, 2024 1

I get 22,900/second with this app...

@SpringBootApplication
public class Gh644Application implements CommandLineRunner {

	public static void main(String[] args) {
		SpringApplication.run(Gh644Application.class, args).close();
	}

	@Autowired
	private RabbitTemplate template;

	@Autowired
	private RabbitListenerEndpointRegistry registry;

	private final CountDownLatch latch = new CountDownLatch(1_000_000);

	@Override
	public void run(String... arg0) throws Exception {
		for (int i = 0; i < 1_000_000; i++) {
			template.convertAndSend("perf", "foo");
		}
		StopWatch watch = new StopWatch();
		watch.start();
		this.registry.start();
		this.latch.await();
		watch.stop();
		System.out.println(watch.getTotalTimeMillis() + " rate: " + 1_000_000_000.0 / watch.getTotalTimeMillis());
	}

	@Bean
	public Queue perf() {
		return new Queue("perf", false, false, true);
	}

	@RabbitListener(queues = "perf")
	public void listen(Message message) {
		this.latch.countDown();
	}

}

and

spring.rabbitmq.listener.simple.prefetch=100
spring.rabbitmq.listener.simple.transaction-size=50
spring.rabbitmq.listener.simple.auto-startup=false

When I remove the transaction-size property (so we send an ack per message), I got 17,500/sec.

When I used the native consumer, I got very similar results (17k/sec).

...
//		this.registry.start();

		ConnectionFactory cf = new ConnectionFactory();
		Connection conn = cf.newConnection();
		Channel channel = conn.createChannel();
		channel.basicQos(100);
		channel.basicConsume("perf", new DefaultConsumer(channel) {

			@Override
			public void handleDelivery(String consumerTag, Envelope envelope, BasicProperties properties, byte[] body)
					throws IOException {
				latch.countDown();
				channel.basicAck(envelope.getDeliveryTag(), false);
			}

		});
		this.latch.await();
		watch.stop();
		System.out.println(watch.getTotalTimeMillis() + " rate: " + 1_000_000_000.0 / watch.getTotalTimeMillis());
		channel.close();
		conn.close();

So there must be something else going on in your code.

from spring-amqp.

garyrussell avatar garyrussell commented on April 27, 2024

You are not comparing apples with apples; there is no qos (prefetch limit) in your raw test.

There is some overhead when using @RabbitListener; there is also some overhead converting the raw data to a Message object, but I would not expect either of these to cause that amount of difference. If you can post complete projects (i.e. including your Producer object used in the spring version), I can take a look to see what's going on.

from spring-amqp.

darekmydlarz avatar darekmydlarz commented on April 27, 2024

@garyrussell thanks for reaching out. I was testing with prefetch set to 1, 100, 1000. Always had the same results

from spring-amqp.

garyrussell avatar garyrussell commented on April 27, 2024

That is with spring; what about the "official client code" (channel.basicQos()).

That said, it is odd you got the "same" results; qos=1 (default) is definitely much slower because it needs a round trip to the broker for each message - we are increasing the default in 2.0 (AMQP-748). It is currently 1.

If you see no difference between 1 and 100, it sounds like the configuration is not being applied for some reason.

Again, if you can share your project, I can take a look.

BTW, we use the same client under the covers.

from spring-amqp.

darekmydlarz avatar darekmydlarz commented on April 27, 2024

@garyrussell thanks for update! Let me check that in couple of days cause I am away from keyboard at the moment ;)

from spring-amqp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.