首页 > 其他分享 >rabbitmq单机安装及性能测试

rabbitmq单机安装及性能测试

时间:2024-06-09 23:34:07浏览次数:33  
标签:单机 -- rabbitmq msg 测试 test consumer id

RabbitMQ单机安装及性能测试

本文使用CentOS7.9安装RabbitMQ单机环境,并进行性能测试。

1. 安装RabbitMQ

RabbitMQ依赖Erlang,版本配套关系参考官网:https://www.rabbitmq.com/docs/which-erlang

本文安装RabbitMQ3.8.21,Erlang版本要求为23.2~24.2。

# 卸载通过yum源安装的erlang,版本不满足
$ sudo yum remove erlang-*
# 安装erlang
$ sudo yum install -y make gcc gcc-c++ m4 openssl openssl-devel ncurses-devel unixODBC unixODBC-devel java java-devel
$ sudo mkdir /usr/local/erlang
$ wget https://github.com/erlang/otp/releases/download/OTP-23.3.4.20/otp_src_23.3.4.20.tar.gz
$ tar xf otp_src_23.3.4.20.tar.gz
$ cd otp_src_23.3.4.20/
$ sudo ./configure --prefix=/usr/local/erlang
$ sudo make && sudo make install
# 配置环境变量
$ sudo vim /etc/profile
#########   添加如下内容   ###############
PATH=$PATH:/usr/local/erlang/bin
$ sudo source /etc/profile
# 查看erlang版本
$ sudo erl -version
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 11.2.2.18

# 安装rabbitmq-server
$ wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.21/rabbitmq-server-generic-unix-3.8.21.tar.xz
$ tar xf rabbitmq-server-generic-unix-3.8.21.tar.xz
$ sudo mv rabbitmq_server-3.8.21/  /usr/local/

# 添加环境变量
$ sudo vim /etc/profile
export RABBITMQ_HOME=/usr/local/rabbitmq_server-3.8.21/sbin
export PATH=$RABBITMQ_HOME:$PATH

# 重载一下环境变量
$ sudo source /etc/profile
 
# 添加web管理插件
$ sudo rabbitmq-plugins enable rabbitmq_management

# 找到rabbitmq.conf.example和advanced.config.example文件,将.example去掉,拷贝到/usr/local/rabbitmq_server-3.8.21/etc/rabbitmq目录下。
# 配置文件实例:https://www.rabbitmq.com/docs/configure#config-file
$ mv rabbitmq.conf.example rabbitmq.conf
$ mv advanced.config.example advanced.config

# 修改rabbitmq.conf文件,取消注释如下两行(91、97行),并将geust从loopback_users中移除。
$ sudo vim rabbitmq.conf
{loopback_users, []},
loopback_users.guest = false

# 后台启动
$ sudo rabbitmq-server -detached

# 停止
$ sudo rabbitmqctl stop

2. PerfTest测试Rabbitmq性能

2.1 PerfTest安装

PerfTest也是从Bintray和GitHub发布的二进制版本库中分发的。如果需要将它作为库,也可以在Maven Central上使用。

参考:

官网:https://perftest.rabbitmq.com/

GitHub:https://github.com/rabbitmq/rabbitmq-perf-test/releases

Maven Central: https://central.sonatype.com/artifact/com.rabbitmq/perf-test

# 下载解压
$ wget https://github.com/rabbitmq/rabbitmq-perf-test/releases/download/v2.20.0/rabbitmq-perf-test-2.20.0-bin.zip
$ unzip rabbitmq-perf-test-2.20.0-bin.zip
$ cd rabbitmq-perf-test-2.20.0/bin/
# 帮助文档
$ ./runjava com.rabbitmq.perf.PerfTest --help
usage: <program>
 -?,--help                           show usage
 -A,--multi-ack-every <arg>          multi ack every
 -a,--autoack                        auto ack
 -ad,--auto-delete <arg>             should the queue be auto-deleted,
                                     default is true
 -B,--body <arg>                     comma-separated list of files to use
                                     in message bodies
 -b,--heartbeat <arg>                heartbeat interval
 -C,--pmessages <arg>                producer message count
 -c,--confirm <arg>                  max unconfirmed publishes
 -ct,--confirm-timeout <arg>         waiting timeout for unconfirmed
                                     publishes before failing (in seconds)
 -D,--cmessages <arg>                consumer message count
 -d,--id <arg>                       test ID
 -e,--exchange <arg>                 exchange name
 -f,--flag <arg>                     message flag
 -H,--uris <arg>                     connection URIs (separated by commas)
 -h,--uri <arg>                      connection URI
 -i,--interval <arg>                 sampling interval in seconds
 -K,--random-routing-key             use random routing key per message
 -k,--routing-key <arg>              routing key
 -L,--consumer-latency <arg>         consumer latency in microseconds
 -l,--legacy-metrics                 display legacy metrics (min/avg/max
                                     latency)
 -M,--framemax <arg>                 frame max
 -m,--ptxsize <arg>                  producer tx size
 -ms,--use-millis                    should latency be collected in
                                     milliseconds, default is false. Set to true if producers are consumers run
                                     on different machines.
 -n,--ctxsize <arg>                  consumer tx size
 -o,--output-file <arg>              output file for timing results
 -p,--predeclared                    allow use of predeclared objects
 -Q,--global-qos <arg>               channel prefetch count
 -q,--qos <arg>                      consumer prefetch count
 -qa,--queue-args <arg>              queue arguments as key/pair values,
                                     separated by commas
 -R,--consumer-rate <arg>            consumer rate limit
 -r,--rate <arg>                     producer rate limit
 -S,--slow-start                     start consumers slowly (1 sec delay
                                     between each)
 -s,--size <arg>                     message size in bytes
 -sb,--skip-binding-queues           don't bind queues to the exchange
 -T,--body-content-type <arg>        body content-type
 -t,--type <arg>                     exchange type
 -u,--queue <arg>                    queue name
 -udsc,--use-default-ssl-context     use JVM default SSL context
 -X,--producer-channel-count <arg>   channels per producer
 -x,--producers <arg>                producer count
 -Y,--consumer-channel-count <arg>   channels per consumer
 -y,--consumers <arg>                consumer count
 -z,--time <arg>                     run duration in seconds (unlimited by
                                     default)

2.2 测试rabbitmq性能

# 使用2个发布者和4个消费者,消费者自动确认。测试10s
$ ./runjava com.rabbitmq.perf.PerfTest -x 2 -y 4 -u "throughput-test-2" -a --id "test 2" -z 10
id: test 2, starting consumer #0
id: test 2, starting consumer #0, channel #0
id: test 2, starting consumer #1
id: test 2, starting consumer #1, channel #0
id: test 2, starting consumer #2
id: test 2, starting consumer #2, channel #0
id: test 2, starting consumer #3
id: test 2, starting consumer #3, channel #0
id: test 2, starting producer #0
id: test 2, starting producer #0, channel #0
id: test 2, starting producer #1
id: test 2, starting producer #1, channel #0
id: test 2, time 1.003 s, sent: 127999 msg/s, received: 15782 msg/s, min/median/75th/95th/99th consumer latency: 5713/307891/402582/528289/582712 µs
id: test 2, time 2.001 s, sent: 131113 msg/s, received: 26712 msg/s, min/median/75th/95th/99th consumer latency: 492458/927258/1076558/1200196/1224838 µs
id: test 2, time 3.002 s, sent: 70270 msg/s, received: 27921 msg/s, min/median/75th/95th/99th consumer latency: 1231947/1636103/1762087/1911254/1961337 µs
id: test 2, time 4.004 s, sent: 65868 msg/s, received: 32514 msg/s, min/median/75th/95th/99th consumer latency: 1871274/2289855/2447511/2573695/2638878 µs
id: test 2, time 5.010 s, sent: 71051 msg/s, received: 47652 msg/s, min/median/75th/95th/99th consumer latency: 2558754/2876891/2982484/3254060/3317619 µs
id: test 2, time 6.002 s, sent: 59422 msg/s, received: 61646 msg/s, min/median/75th/95th/99th consumer latency: 2759697/3160876/3333301/3550598/3577079 µs
id: test 2, time 7.002 s, sent: 51860 msg/s, received: 62923 msg/s, min/median/75th/95th/99th consumer latency: 2821628/3221174/3346806/3479463/3500692 µs
id: test 2, time 8.001 s, sent: 69568 msg/s, received: 64028 msg/s, min/median/75th/95th/99th consumer latency: 2815461/3220554/3359531/3509414/3540637 µs
id: test 2, time 9.001 s, sent: 60874 msg/s, received: 56448 msg/s, min/median/75th/95th/99th consumer latency: 2810135/3187379/3422998/3547960/3569557 µs
id: test 2, time 10.006 s, sent: 52246 msg/s, received: 58175 msg/s, min/median/75th/95th/99th consumer latency: 2871297/3260717/3463882/3582327/3608431 µs
id: test 2, time 11.001 s, sent: 2.0 msg/s, received: 60551 msg/s, min/median/75th/95th/99th consumer latency: 2933013/3275629/3448953/3585931/3630662 µs
id: test 2, time 12.001 s, sent: 0 msg/s, received: 70372 msg/s, min/median/75th/95th/99th consumer latency: 2767204/3282635/3474078/3678657/3719987 µs
id: test 2, time 13.001 s, sent: 0 msg/s, received: 65454 msg/s, min/median/75th/95th/99th consumer latency: 2552693/3090484/3276141/3544581/3585066 µs
test stopped (Reached time limit)
id: test 2, sending rate avg: 58506 msg/s
id: test 2, receiving rate avg: 49985 msg/s
id: test 2, consumer latency min/median/75th/95th/99th 14918/3156722/3342902/3541320/3615540 µs
$ bin/runjava com.rabbitmq.perf.PerfTest -x 2 -y 4 -u "throughput-test-2" -a --id "test 2"

# 将消费者切换到手动确认:
$ ./runjava com.rabbitmq.perf.PerfTest -x 1 -y 2 -u "throughput-test-3" --id "test 3"

# 修改将消息大小从默认(12字节)更改为4 kB:
$ ./runjava com.rabbitmq.perf.PerfTest -x 1 -y 2 -u "throughput-test-4" --id "test 4" -s 4000

# 使用持久队列和持久消息:
$ ./runjava com.rabbitmq.perf.PerfTest -x 1 -y 2 -u "throughput-test-5" --id "test-5" -f persistent

# 队列数400,生产者200,消费者200,消息大小12bytes(默认),消息自动确认,持久化,持续生产消费5分钟。建议测试客户端和被测试机器分开部署。
$ ./runjava com.rabbitmq.perf.PerfTest -x 200 -y 200 -u "max-throughput-test" -s 12 -a --id "test 2" -z 300 -f persistent
id: test 2, sending rate avg: 116797 msg/s
id: test 2, receiving rate avg: 29674 msg/s
id: test 2, consumer latency min/median/75th/95th/99th 7504371/104831283/114120030/121894266/124635729 µs

标签:单机,--,rabbitmq,msg,测试,test,consumer,id
From: https://www.cnblogs.com/lldhsds/p/18240235

相关文章

  • “【SpringBoot】SpringBoot整合RabbitMQ消息中间件,实现延迟队列和死信队列”文章说了
    在SpringBoot中整合RabbitMQ以实现延迟队列和死信队列的功能,主要涉及以下几个关键步骤:1.引入依赖:首先,在项目的pom.xml文件中添加RabbitMQ的依赖。2.配置RabbitMQ:在application.properties或application.yml文件中配置RabbitMQ的相关参数,包括连接信息、交换机名称、队列名......
  • 领导给你一个项目,如何开展性能测试工作?
     怎么开展性能测试01测试的一般步骤性能测试的工作是基于系统功能已经完备或者已经趋于完备之上的,在功能还不够完备的情况下没有多大的意义(后期功能完善上会对系统的性能有影响,过早进入性能测试会出现测试结果不准确、浪费测试资源);因此,性能测试首先是基于功能测试的,你必......
  • 软件测试————Bug的定义及生命周期
    目录一、Bug的定义二、Bug的生命周期   三、Bug的等级划分一、Bug的定义    定义:⼀个计算机bug指在计算机程序中存在的⼀个错误(error)、缺陷(flaw)、疏忽(mistake)或者故障(fault),这些bug使程序⽆法正确的运⾏。二、Bug的生命周期    1、New(新......
  • SMS - 基于阿里云实现手机短信验证码登录(无需备案,非测试)
    目录SMS环境调试从阿里云云市场中购买第三方短信服务调试短信验证码功能实战开发 封装组件对外接口调用演示SMS环境调试从阿里云云市场中购买第三方短信服务a)进入阿里云首页,然后从云市场中找到“短信” (一定要从云市场去找短信服务,否则需要企业证明,备案) ......
  • RDK X3(arm64) 测试国产双目摄像头Astra Pro Plus
    0.环境-亚博智能的ROSMASTER-X3标准版(双目是AstraProPlus)-RDKX31.01.RDKX31.0串口通信波特率921600root/rootmobaterm->Session->VNC   ->192.168.8.108:5900   ->runrise2.是否识别到设备2.1USB扩展版上电前:root@ubuntu:~#lsusbB......
  • CMake:构建、打包和测试的跨平台工具系列软件
    介绍CMake是一个开源、跨平台的构建系统,旨在管理软件构建过程。它通过使用简洁的脚本语言描述项目的构建规则,自动生成适用于各种平台的构建文件,如UnixMakefiles、VisualStudio项目和Xcode项目。CMake不仅支持多种编译器和操作系统,还提供了丰富的功能,用于软件的构建、打包和......
  • RabbitMQ笔记
     端午无聊,就来学学MQ吧消息队列消息指的是两个应用之间传递的数据消息队列是在消息传递中保存消息的容器生成者:只负责发送数据消费者:只负责读取数据(数据就是消息)为什么要用消息队列解耦如果一个系统(系统a)的需求是共享自己系统的数据,而其他系统(系统BCD)是需求者。而......
  • jest 单元测试
    jest单元测试关键词解释describe用于对测试用例进行逻辑分组,使得测试代码更加有组织、易读expect用于验证代码的行为是否符合预期test用于定义测试用例toBe相当于===,即全等toEqual相当于==运行命令//index.test.jsdescribe('group',()=>{test('sumfunction......
  • 《手把手教你》系列练习篇之15-python+ selenium自动化测试 -番外篇 - 最后一波啊!!!(详细
    1.简介 本来上一篇就是练习篇的最后一篇文章了,但是有的小伙伴私下反映说是做了那么多练习,没有一个比较综合的demo练练手。因此宏哥在这里又补存了一些常见的知识点进行练习,在文章最后也通过实例给小伙伴们或者童鞋们进行了一个登录模块的自动化测试的实例,其他的你可以照......
  • 《手把手教你》系列练习篇之14-python+ selenium自动化测试 -压台篇(详细教程)
    1.简介 本文是练习篇的最后一篇文章,虽然练习篇的文章到此就要和大家说拜拜了,但是我们的学习之路才刚刚开始。不要停下你的脚步,大步朝前走吧!比你优秀的人还在走着,我们有什么理由停下自己的脚步了,生命不止,学习亦是如此。好了,宏哥的毒鸡汤好喝吧,喝够了就开始学习吧。......