简体   繁体   English

并行化 Pulsar 消费者工作负载的最佳方式是什么?

[英]What is the best way to parallelize Pulsar consumer workload?

I want to use Pulsar as a message queue using shared consumers and the Java client.我想使用 Pulsar 作为消息队列,使用共享消费者和 Java 客户端。 For the moment being, there are no strict ordering requirements, and also no partitions.暂时没有严格的排序要求,也没有分区。 The tasks triggered by the messages usually take up to 2 seconds.消息触发的任务通常最多需要 2 秒。 Is there any clear preference which of the following two methods of splitting the work between threads in a single application instance should be picked:是否有任何明确的偏好应该选择以下两种在单个应用程序实例中的线程之间拆分工作的方法中的哪一种:

  1. 1 consumer with receive queue size 100 and 10 threads in a threadpool calling consumer.receive() in a loop. 1 个接收队列大小为 100 且线程池中有 10 个线程在循环中调用consumer.receive()的消费者。
  2. 10 consumers with receive queue size 10 each, using the MessageListener interface and running the task inside the original MessageListener.receive() call. 10 个接收队列大小为 10 的消费者,使用 MessageListener 接口并在原始MessageListener.receive()调用中运行任务。

The best answer should be - just measure it:) Saying that, the first approach should be more efficient since no broker communication overhead is involved.最好的答案应该是 - 只是衡量它:) 话虽如此,第一种方法应该更有效,因为不涉及代理通信开销。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM