Apusic文档中心
首页
  • 应用服务器 AAS
  • 负载均衡器 ALB
  • 分布式消息队列 ADMQ
  • 分布式缓存 AMDC
  • 分布式配置中心 ADCC
  • Java开发工具包软件 AJDK
  • 搜索引擎 ASE
  • 中间件云平台 ACP
  • 统一管理平台 AUMP
  • 云原生中间件管理 ACMP
  • DevOps平台 ADOP
  • 许可授权中心 ACLS
  • Copilot智能问答系统 ACS
  • 监控平台 AMP
  • 智能日志 AILP
  • 应用性能管理 AAPM
  • 智能告警 AAlarm
  • 金蝶Apusic AI 极光
  • 主数据管理 AMDM
  • 数据交换平台 ADXP
  • 企业服务总线 AESB
  • 数据智脑 ADPR
  • 服务治理 ASGP
  • 统一身份管理 AIDM
  • 标准模板
  • Markdown教程 (opens new window)
  • VuePress官方社区 (opens new window)
  • 帮助
贡献文档 (opens new window)
首页
  • 应用服务器 AAS
  • 负载均衡器 ALB
  • 分布式消息队列 ADMQ
  • 分布式缓存 AMDC
  • 分布式配置中心 ADCC
  • Java开发工具包软件 AJDK
  • 搜索引擎 ASE
  • 中间件云平台 ACP
  • 统一管理平台 AUMP
  • 云原生中间件管理 ACMP
  • DevOps平台 ADOP
  • 许可授权中心 ACLS
  • Copilot智能问答系统 ACS
  • 监控平台 AMP
  • 智能日志 AILP
  • 应用性能管理 AAPM
  • 智能告警 AAlarm
  • 金蝶Apusic AI 极光
  • 主数据管理 AMDM
  • 数据交换平台 ADXP
  • 企业服务总线 AESB
  • 数据智脑 ADPR
  • 服务治理 ASGP
  • 统一身份管理 AIDM
  • 标准模板
  • Markdown教程 (opens new window)
  • VuePress官方社区 (opens new window)
  • 帮助
贡献文档 (opens new window)
文档中心
  • 金蝶Apusic应用服务器

  • 金蝶Apusic负载均衡器

  • 金蝶Apusic分布式消息队列

    • 产品白皮书
    • Product Whitepaper
    • 產品白皮書
    • 产品更新说明
    • 统一管控台

    • V2.0.6(最新)

    • V2.0.6_for_kafka

    • V2.0.6_for_rabbitmq

      • 产品简介
      • 功能与技术规格
      • 安装手册
      • 快速使用手册
      • 管控台用户手册
      • 消息引擎用户手册
      • 开发手册
      • 迁移手册
      • 运维手册
      • 性能优化手册
      • 极简运维手册
      • English

        • Product Introduction
        • Technical Specification
        • Installation Manual
        • Quick Start
        • Console User Manual
        • Core Engine User Manual
        • Development Manual
        • Migration Manual
        • Operations Manual
        • Performance Tuning
        • Quick Operation Guide
      • 繁體中文

    • V2.0.6_for_rocketmq

    • V2.0.6_for_MQTT

    • V2.0.5

    • V2.0.4

    • V2.0.3

  • 金蝶Apusic分布式缓存

  • 金蝶Apusic分布式配置中心

  • 金蝶Apusic Java开发工具包软件

  • 金蝶Apusic全文检索

Performance Tuning

# Preface

This document describes the best practices for performance optimization of Kingdee Apusic Distributed Message Queue for RabbitMQ (Apusic Distributed Message Queue, abbreviated as: ADMQ for RabbitMQ), helping users fully leverage system performance.

# Target Audience

This document is applicable to IT information business leaders, R&D managers, software project managers, software architects, and operations engineers.

# Related Documents

For more information about ADMQ for RabbitMQ products, please refer to the following ADMQ for RabbitMQ product documentation set:

No. Document Description
1 Kingdee Apusic Distributed Message Queue for RabbitMQ Quick Start Guide Briefly introduces how to get started with ADMQ for RabbitMQ.
2 Kingdee Apusic Distributed Message Queue for RabbitMQ Installation Guide Details how to install ADMQ for RabbitMQ on various operating systems, as well as service start/stop operations.
3 Kingdee Apusic Distributed Message Queue for RabbitMQ Message Engine User Guide Details the usage, configuration, management, and supporting tools of the ADMQ for RabbitMQ message engine.
4 Kingdee Apusic Distributed Message Queue for RabbitMQ Management Console User Guide Details the usage and operation instructions of the ADMQ for RabbitMQ management console.
5 Kingdee Apusic Distributed Message Queue for RabbitMQ Developer Guide Details the development of ADMQ for RabbitMQ client applications using various programming languages.
6 Kingdee Apusic Distributed Message Queue for RabbitMQ Migration Guide Details the migration from RabbitMQ to ADMQ for RabbitMQ.
7 Kingdee Apusic Distributed Message Queue for RabbitMQ Operations Manual Details monitoring, operations, security hardening, and other operational aspects of ADMQ for RabbitMQ.
8 Kingdee Apusic Distributed Message Queue for RabbitMQ Performance Optimization Guide Details performance tuning for ADMQ for RabbitMQ.

# Technical Support

ADMQ for RabbitMQ provides comprehensive technical support services. You can obtain technical support through the following channels:

  • Website: www.apusic.com
  • Phone: 400-855-5800
  • Email: support@apusic.com
  • Kingdee Cloud Community: https://vip.kingdee.com/?productId=73&productLineId=14&lang=zh-CN

When contacting technical support, please provide the following information:

  1. Your name

  2. Company information and contact details

  3. Operating system and its version

  4. Product version number

  5. Detailed information such as error logs and screenshots

# System-Level Optimization

# Operating System Optimization

# File Descriptors

# View current limits
ulimit -n

# Modify limits (/etc/security/limits.conf)
* soft nofile 65535
* hard nofile 65535
1
2
3
4
5
6

# Kernel Parameters

# /etc/sysctl.conf

# Increase port range
net.ipv4.ip_local_port_range = 1024 65535

# TCP connection optimization
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
net.core.somaxconn = 65535

# Memory optimization
vm.swappiness = 10
vm.dirty_ratio = 40
vm.dirty_background_ratio = 10

# Apply configuration
sysctl -p
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

# Disk Optimization

Optimization Item Recommendation
File System Use XFS file system
Mount Options noatime,nodiratime
Disk Scheduler Use noop or deadline
RAID Configuration Use RAID 10 or RAID 0
SSD Optimization Enable TRIM, reserve over-provisioning
# View disk scheduler algorithm
cat /sys/block/sda/queue/scheduler

# Set to deadline
echo deadline > /sys/block/sda/queue/scheduler

1
2
3
4
5
6

# Network Optimization

# Network buffers
net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
net.ipv4.tcp_rmem = 4096 87380 134217728
net.ipv4.tcp_wmem = 4096 65536 134217728

# TCP optimization
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_no_metrics_save = 1
1
2
3
4
5
6
7
8
9
10
11

# RabbitMQ Configuration Optimization

# Memory Management

Parameter Default Recommended Description
vm_memory_high_watermark.relative 0.4 0.6-0.7 Memory usage upper limit ratio
vm_memory_high_watermark_paging_ratio 0.5 0.5 Memory ratio to start paging
vm_memory_high_watermark.absolute - 4G Absolute memory limit
# rabbitmq.conf
vm_memory_high_watermark.relative = 0.6
vm_memory_high_watermark_paging_ratio = 0.5
1
2
3

# Disk Management

Parameter Default Recommended Description
disk_free_limit.relative 2.0 1.5 Disk space lower limit ratio
disk_free_limit.absolute 50MB 1GB Absolute disk space lower limit
# rabbitmq.conf
disk_free_limit.relative = 1.5
disk_free_limit.absolute = 1GB
1
2
3

# Connection and Channel Optimization

Parameter Default Recommended Description
channel_max 2047 Adjust as needed Maximum channels per connection
connection_max infinity Adjust as needed Maximum connections
heartbeat 60 30-60 Heartbeat interval (seconds)
handshake_timeout 10000 10000 Handshake timeout (milliseconds)
# rabbitmq.conf
channel_max = 2047
heartbeat = 30
handshake_timeout = 10000
1
2
3
4

# Queue Optimization

# Queue Type Selection

Queue Type Throughput Reliability Applicable Scenario
Classic Queue Medium Medium (mirroring required) General business scenarios
Quorum Queue Medium High High availability scenarios
Stream Queue Very High High High throughput, logging scenarios

# Queue Parameter Optimization

Map<String, Object> args = new HashMap<>();

# Queue length limit, prevent infinite backlog
args.put("x-max-length", 100000);
args.put("x-max-length-bytes", 1073741824);  # 1GB

# Message TTL
args.put("x-message-ttl", 3600000);  # 1 hour

# Queue TTL
args.put("x-expires", 7200000);  # Delete after 2 hours with no consumers

# Lazy queue (reduce memory usage)
args.put("x-queue-mode", "lazy");

channel.queueDeclare("optimized.queue", true, false, false, args);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

# Message Persistence Optimization

# When to Use Persistence

Scenario Recommendation
Critical business messages Must persist (delivery_mode=2)
Log messages Can be non-persistent
High throughput scenarios Trade off reliability and performance

# Batch Persistence

Use Confirm mode + batch acknowledgment to improve persistence performance:

channel.confirmSelect();
channel.setConfirmCallback(...);

# Batch send
for (int i = 0; i < 1000; i++) {
    channel.basicPublish(EXCHANGE, ROUTING_KEY, 
        MessageProperties.PERSISTENT_TEXT_PLAIN, 
        message.getBytes());
}

# Wait for all confirmations
channel.waitForConfirmsOrDie(5000);
1
2
3
4
5
6
7
8
9
10
11
12

# Client Optimization

# Connection Management

# Connection Pool

# Use connection pool to manage connections
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
factory.setConnectionTimeout(30000);
factory.setRequestedHeartbeat(30);
factory.setAutomaticRecoveryEnabled(true);

# Single connection, multiple channels (recommended)
Connection connection = factory.newConnection();
for (int i = 0; i < 10; i++) {
    Channel channel = connection.createChannel();
    # Use channel to process messages
}
1
2
3
4
5
6
7
8
9
10
11
12
13

# Automatic Recovery

factory.setAutomaticRecoveryEnabled(true);
factory.setNetworkRecoveryInterval(5000);
factory.setTopologyRecoveryEnabled(true);
factory.setChannelRpcTimeout(10000);
1
2
3
4

# Producer Optimization

# Batch Sending

# Batch send messages
List<Message> messages = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
    messages.add(new Message(...));
}

# Use transaction or Confirm mode to ensure reliability
channel.confirmSelect();
for (Message msg : messages) {
    channel.basicPublish(EXCHANGE, ROUTING_KEY, null, msg.toBytes());
}
channel.waitForConfirmsOrDie();
1
2
3
4
5
6
7
8
9
10
11
12

# Async Sending

# Use thread pool for async sending
ExecutorService executor = Executors.newFixedThreadPool(10);
for (Message msg : messages) {
    executor.submit(() -> {
        channel.basicPublish(EXCHANGE, ROUTING_KEY, null, msg.toBytes());
    });
}
1
2
3
4
5
6
7

# Consumer Optimization

# QoS Prefetch

# Set QoS, control unacknowledged message count
channel.basicQos(100);  # Maximum 100 unacknowledged messages per consumer

# Global QoS
channel.basicQos(0, 100, true);  # Maximum 100 across entire channel
1
2
3
4
5

# Batch Acknowledgment

# Consume and batch acknowledge
List<Long> deliveryTags = new ArrayList<>();
for (int i = 0; i < 100; i++) {
    GetResponse response = channel.basicGet(QUEUE, false);
    if (response != null) {
        deliveryTags.add(response.getEnvelope().getDeliveryTag());
        processMessage(response);
    }
}

# Batch acknowledge
if (!deliveryTags.isEmpty()) {
    channel.basicAck(deliveryTags.get(deliveryTags.size() - 1), true);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

# Multiple Consumers

# Create multiple consumers for parallel processing
for (int i = 0; i < 10; i++) {
    Channel channel = connection.createChannel();
    channel.basicQos(50);
    
    DeliverCallback callback = (tag, delivery) -> {
        processMessage(delivery);
        channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
    };
    
    channel.basicConsume(QUEUE, false, callback, tag -> {});
}
1
2
3
4
5
6
7
8
9
10
11
12

# Cluster Optimization

# Node Deployment Strategy

Deployment Strategy Description Applicable Scenario
Same Datacenter All nodes in same datacenter Low latency, high throughput
Cross-Datacenter Nodes distributed across datacenters High availability, disaster recovery
Heterogeneous Mixed nodes with different configurations Cost optimization

# Mirrored Queue Optimization

# Optimize mirror sync strategy
bin/admq rabbitmq admin ctl set_policy ha-optimized "^important-.*" '
{
    "ha-mode": "exactly",
    "ha-params": 2,
    "ha-sync-mode": "automatic",
    "ha-promote-on-shutdown": "when-synced"
}'
1
2
3
4
5
6
7
8

# Quorum Queue Optimization

# Adjust Raft parameters
bin/admq rabbitmq admin ctl eval 'application:set_env(rabbit, quorum_commands_soft_limit, 256).'
bin/admq rabbitmq admin ctl eval 'application:set_env(rabbit, quorum_commands_hard_limit, 512).'
1
2
3

# Stream Queue Optimization

Map<String, Object> args = new HashMap<>();
# Segment file size
args.put("x-stream-max-segment-size-bytes", 104857600);  # 100MB

# Retention policy
args.put("x-stream-max-retention-size-bytes", 10737418240L);  # 10GB
args.put("x-stream-max-retention-time", 604800000);  # 7 days

channel.queueDeclare("stream.queue", true, false, false, args);
1
2
3
4
5
6
7
8
9

# Monitoring and Tuning

# Performance Metrics

Metric Healthy Range Optimization Suggestion
CPU Usage < 70% Scale up or optimize business logic
Memory Usage < vm_memory_high_watermark Increase memory or optimize queue configuration
Disk Usage < 80% Scale up or clean data
Message Publish Rate Based on business needs Optimize producers or scale up
Message Consume Rate Close to publish rate Optimize consumers or add more consumers
Unacknowledged Messages < QoS prefetch count Optimize consumer processing speed
Connection Count < connection_max Optimize connection usage or use connection pool

# Performance Testing

# Test using perf-test tool
rabbitmq-perf-test -x 10 -y 10 -u "test-queue" -a --auto-delete false

# Parameter description
# -x: Number of producers
# -y: Number of consumers
# -u: Queue name
# -a: Auto acknowledgment
# --auto-delete: Whether to auto-delete queue
1
2
3
4
5
6
7
8
9

# Bottleneck Analysis

  1. CPU Bottleneck: Complex message processing logic, encryption/decryption, large number of connections
  2. Memory Bottleneck: Queue backlog, large number of connections, lazy queues not enabled
  3. Disk Bottleneck: Large volume of persistent messages, insufficient disk I/O
  4. Network Bottleneck: Cross-datacenter deployment, large data transfer

# Common Issue Optimization

# Message Backlog Optimization

  1. Increase consumer count
  2. Optimize consumer processing logic
  3. Set queue length limits
  4. Use dead letter queue to handle expired messages

# Insufficient Memory Optimization

  1. Increase physical memory
  2. Adjust vm_memory_high_watermark
  3. Enable lazy queues
  4. Clean up unnecessary queues and messages
  5. Reduce connection count

# High Latency Optimization

  1. Use auto acknowledgment (non-critical messages)
  2. Reduce persistence frequency
  3. Optimize network configuration
  4. Use closer nodes
  5. Reduce message size

# Performance Optimization Checklist

# System Level

  • [ ] File descriptor limits adjusted
  • [ ] Kernel parameters optimized
  • [ ] Disk using XFS file system
  • [ ] Network parameters optimized
  • [ ] System resources sufficient (CPU, memory, disk)

# RabbitMQ Configuration

  • [ ] Memory watermark set appropriately
  • [ ] Disk space limit set appropriately
  • [ ] Heartbeat interval appropriate
  • [ ] Connection and channel limits appropriate
  • [ ] Queue leader allocation strategy appropriate

# Client Optimization

  • [ ] Use connection pool
  • [ ] Use single connection with multiple channels
  • [ ] Enable automatic recovery
  • [ ] Set QoS appropriately
  • [ ] Use batch acknowledgment
  • [ ] Choose appropriate acknowledgment mode

# Cluster Optimization

  • [ ] Nodes select appropriate queue types
  • [ ] Mirrored queue policy reasonable
  • [ ] Quorum Queue parameters optimized
  • [ ] Stream Queue retention policy reasonable
  • [ ] Cluster scale meets business requirements
编辑页面 (opens new window)
#性能优化手册

← Operations Manual Quick Operation Guide→

  • 浅色模式