Comments (6)
Closing for now due to no response; please reopen if you still have an issue.
from spring-amqp.
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.
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.
@garyrussell thanks for reaching out. I was testing with prefetch set to 1, 100, 1000. Always had the same results
from spring-amqp.
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.
@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)
- Get rid of `synchronized` in `RabbitAdmin`
- Get rid of `synchronized` in `RabbitTemplate` HOT 1
- Get rid of `synchronized` in the `BlockingQueueConsumer`
- Get rid of `synchronized` in `spring-rabbit-test` module
- Get rid of the rest of `synchronized` in the ListenerContainer infrastructure
- Improve Extensibility of RepublishMessageRecovererWithConfirms by supporting SpEL expressions HOT 1
- AmqpRejectAndDontRequeueException completely restarts Consumer HOT 2
- The `SimpleMessageListenerContainer` does not shutdown properly
- The `SimpleMessageListenerContainer` does not shutdown properly HOT 1
- Swallowed exception 'AmqpTimeoutException: No available channels' HOT 4
- Add batchReceiveTimeout in SimpleMessageListenerContainer HOT 3
- MessageProperties setDelay maximum value problem HOT 3
- ImmediateAcknowledgeAmqpException keeps the message in the queue HOT 10
- TraceId propagation to the new thread local HOT 4
- Wrong ClassLoader is used for message deserialization when devtools are active
- Wrong ClassLoader is used for message deserialization when devtools are active HOT 1
- Kotlin suspend functions return type is incorrect HOT 3
- Kotlin suspend functions return type is incorrect HOT 1
- Channel cache leak when no answers from broker for pending confirms
- Channel cache leak when no answers from broker for pending confirms HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-amqp.