iamforrest opened a new issue #2207:
URL: https://github.com/apache/rocketmq/issues/2207


   我写了一个简单的性能测试,对比rabbitmq和rocketmq的发送吞吐量,令我意外的是,rocketmq竟然比rabbitmq差了10倍。
   
   1. rocketmq和rabbitmq都在一个局域网上
   2. rocketmq用的是同步刷盘,因为我们的要求是消息尽量不能丢失
   3. rocketmq的版本为 4.6.1
   
   测试代码
   
   ```
      private void rabbitmq(List<WuLiuXiTongEntity> wuLiuXiTongEntityList, int 
numOfThreads) throws Exception {
           ExecutorService executorService = 
Executors.newFixedThreadPool(numOfThreads);
           CountDownLatch countDownLatch = new CountDownLatch(numOfThreads);
           String content = JSON.toJSONString(wuLiuXiTongEntityList);
           for (int i = 1; i <= numOfThreads; i++) {
               executorService.execute(() -> {
                   Monitor monitor = MonitorFactory.start("rabbitmq");
                   rabbitMQSender.convertAndSend("testExchange", "foo", 
content);
                   monitor.stop();
                   countDownLatch.countDown();
               });
           }
           countDownLatch.await();
       }
   
   
       private void rocketmq(List<WuLiuXiTongEntity> wuLiuXiTongEntityList, int 
numOfThreads) throws Exception {
           SessionCredentials sessionCredentials = new SessionCredentials();
           sessionCredentials.setAccessKey(rocketmqAccessKey);
           sessionCredentials.setSecretKey(rocketmqSecretKey);
           AclClientRPCHook rpcHook = new AclClientRPCHook(sessionCredentials);
           DefaultMQProducer producer = new 
DefaultMQProducer("testProduceGroup", rpcHook);
           producer.setNamesrvAddr(rocketmqNameServer);
           producer.start();
           ExecutorService executorService = 
Executors.newFixedThreadPool(numOfThreads);
           CountDownLatch countDownLatch = new CountDownLatch(numOfThreads);
           byte[] content = 
JSON.toJSONString(wuLiuXiTongEntityList).getBytes("utf-8");
           for (int i = 1; i <= numOfThreads; i++) {
               executorService.execute(() -> {
                   Monitor monitor = MonitorFactory.start("rocketmq");
                   Message msg = new Message("testTopic" /* Topic */,
                           "testTag" /* Tag */,
                           content /* Message body */
                   );
                   //Call send message to deliver message to one of brokers.
                   try {
                       SendResult sendResult = producer.send(msg);
                   } catch (MQClientException e) {
                       e.printStackTrace();
                   } catch (RemotingException e) {
                       e.printStackTrace();
                   } catch (MQBrokerException e) {
                       e.printStackTrace();
                   } catch (InterruptedException e) {
                       e.printStackTrace();
                   }
                   countDownLatch.countDown();
                   monitor.stop();
               });
           }
           countDownLatch.await();
           producer.shutdown();
       }
   ```
   
   
   得到的测试结果如下:
   
   <img width="1778" alt="image" 
src="https://user-images.githubusercontent.com/2240276/88496636-69a8eb00-cff0-11ea-96ec-be56b6d36606.png";>
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to