1 Star 0 Fork 33

qinjl / BitMQ

forked from 风尘叹 / BitMQ 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

BitMQ

BitMQ 是一款开源消息队列与消息代理服务端程序。

BitMQ 支持在 GNU/Linux 以及 Windows 上运行。BitMQ 目前在 Windows 下使用 select 模型,不建议用于高负载环境。

编译 BitMQ Build Status

编译 BitMQ 需要安装 openssl (>=1.0.2,用以支持 HTTPS),zlib (>=1.2.0.4,用以支持 GZIP)。您可以使用包管理工具安装或者下载源代码编译安装

centos/redhat# yum install openssl-devel openssl zlib-devel zlib
debian/ubuntu# apt-get install libssl-dev openssl zlib1g-dev zlib1g

BitMQ 使用 CMake (>=2.8) 进行构建。您可以在源码目录下使用以下命令构建

mkdir build
cd build
cmake ..
make

您也可以在 Winodws 下使用 CMake 以及 Visual Studio 进行构建,或者直接下载已经编译好的可执行文件。

使用 BitMQ

运行

使用当前工作路径下的配置文件 (bmq.conf) 启动

./bmq

使用指定的配置文件启动

./bmq -c /opt/bmq/1039.conf

注意,您可以使用多个配置文件在同一台服务器上启动多个 BitMQ 实例。但这些配置文件中设定的端口必须各不相同。

以后台模式启动

./bmq -d

停止

首先找到 master 进程的 pid,例如

root@localhost:~# ps -ef | grep bmq
root      118675   1553  0 14:36 ?        00:00:00 bmq: master process (/opt/bmq/bmq.conf)
www-data  118676 118675  0 14:36 ?        00:00:00 bmq: worker process

然后执行

kill 118675

注意,此时 worker 进程并不会立刻退出,而是停止 accept 新连接。直到所有已建立的连接处理完毕并正常关闭后, worker 进程才会退出。这最长需要等待 keep-alive-timeout 的时间。

注意,直接对 worker 进程执行 kill 并不能关闭 BitMQ。master 进程会在 worker 进程退出后立即重新 fork 出一个 worker 进程。

重启

首先找到 master 进程的 pid,然后执行

kill 118675
./bmq -d

执行该命令后会产生新的 master 进程和 worker 进程。旧进程会在所有已建立的连接处理完毕并正常关闭后退出。

平滑重启

首先找到 master 进程的 pid,然后执行

kill -USR2 118675 && kill 118675

注意:为了在不关闭程序的情况下更新二进制文件,您总是应当使用符号链接来启动 BitMQ。 注意:如果启用了数据持久化功能,请不要使用该方式重启程序,否则可能会造成数据丢失。

性能测试

以下测试结果在虚拟机环境下取得。

HTTP 短连接 ( ab -n 500000 -c 10 http://127.0.0.1/ ):

Server Software:        BitMQ
Server Hostname:        127.0.0.1
Server Port:            1039

Document Path:          /
Document Length:        2308 bytes

Concurrency Level:      10
Time taken for tests:   17.853 seconds
Complete requests:      500000
Failed requests:        0
Total transferred:      1280000000 bytes
HTML transferred:       1154000000 bytes
Requests per second:    28007.07 [#/sec] (mean)
Time per request:       0.357 [ms] (mean)
Time per request:       0.036 [ms] (mean, across all concurrent requests)
Transfer rate:          70017.68 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       7
Processing:     0    0   0.2      0      11
Waiting:        0    0   0.2      0      11
Total:          0    0   0.2      0      11

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      0
  75%      0
  80%      0
  90%      0
  95%      0
  98%      1
  99%      1
 100%     11 (longest request)


Server Software:        nginx/1.10.3
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /
Document Length:        2308 bytes

Concurrency Level:      10
Time taken for tests:   17.813 seconds
Complete requests:      500000
Failed requests:        0
Total transferred:      1275500000 bytes
HTML transferred:       1154000000 bytes
Requests per second:    28069.69 [#/sec] (mean)
Time per request:       0.356 [ms] (mean)
Time per request:       0.036 [ms] (mean, across all concurrent requests)
Transfer rate:          69927.52 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       8
Processing:     0    0   0.1      0       9
Waiting:        0    0   0.1      0       9
Total:          0    0   0.1      0       9

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      0
  75%      0
  80%      0
  90%      0
  95%      0
  98%      1
  99%      1
 100%      9 (longest request)

HTTP 长连接 ( ab -k -n 500000 -c 10 http://127.0.0.1/ ):

Server Software:        BitMQ
Server Hostname:        127.0.0.1
Server Port:            1039

Document Path:          /
Document Length:        2308 bytes

Concurrency Level:      10
Time taken for tests:   10.062 seconds
Complete requests:      500000
Failed requests:        0
Keep-Alive requests:    500000
Total transferred:      1282500000 bytes
HTML transferred:       1154000000 bytes
Requests per second:    49692.49 [#/sec] (mean)
Time per request:       0.201 [ms] (mean)
Time per request:       0.020 [ms] (mean, across all concurrent requests)
Transfer rate:          124473.86 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       1
Processing:     0    0   0.1      0      10
Waiting:        0    0   0.1      0      10
Total:          0    0   0.1      0      10

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      0
  75%      0
  80%      0
  90%      0
  95%      0
  98%      0
  99%      0
 100%     10 (longest request)


Server Software:        nginx/1.10.3
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /
Document Length:        2308 bytes

Concurrency Level:      10
Time taken for tests:   19.471 seconds
Complete requests:      500000
Failed requests:        0
Keep-Alive requests:    495003
Total transferred:      1277975015 bytes
HTML transferred:       1154000000 bytes
Requests per second:    25679.27 [#/sec] (mean)
Time per request:       0.389 [ms] (mean)
Time per request:       0.039 [ms] (mean, across all concurrent requests)
Transfer rate:          64096.61 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     0    0   1.3      0      28
Waiting:        0    0   1.3      0      28
Total:          0    0   1.3      0      28

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      0
  75%      0
  80%      0
  90%      0
  95%      0
  98%      1
  99%      7
 100%     28 (longest request)

注意:在以上测试中提供 nginx 的数据只是为硬件性能提供一个参考。两者并不具备可比较性。

消息发送 ( 关闭持久化与日志 ):

Time taken for tests:   3.21 seconds
Complete publish:       1000000
Failed publish:         0
Total transferred:      89.65 Mbytes
Message transferred:    86.78 Mbytes
Publish per second:     311817.91 [#/sec]
Time per publish:       0.00 [ms]
Transfer rate:          27.95 [Mbytes/sec]

$ redis-benchmark -q -t set -n 1000000
SET: 142267.75 requests per second

当开启日志或持久化功能时,消息吞吐量将主要受限于磁盘写入性能。

注意:在以上测试中提供 redis 的数据只是为硬件性能提供一个参考。两者并不具备可比较性。

更新日志

V0.7.0

  • Feature: 基于 snowflake 的分布式 ID 生成算法
  • Feature: 允许同时使用安全(SSL)连接与普通连接
  • Feature: 添加遗嘱消息支持
  • Feature: 添加压缩消息支持
  • Feature: 新的 BMTP 协议格式(不再兼容旧版本)

V0.6.0

  • Feature: 添加 WebSocket 协议支持
  • Feature: 添加授权认证和权限控制

V0.5.0

  • Feature: 添加 BMTP 协议支持
  • Feature: 添加对 Windows 的支持

V0.4.0

  • Feature: 新增 status 统计与运维接口
  • Feature: 优化了红黑树和定时器相关操作
  • Feature: 新增持久化支持
  • Feature: 新增 ACK 消息类型

授权协议

BitMQ 遵循 BSD 许可证。

获取 BitMQ

BSD 3-Clause License Copyright (c) 2017, The BitMQ Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

开源消息队列与消息代理 展开 收起
C
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C
1
https://gitee.com/andyhmy/Webit.git
git@gitee.com:andyhmy/Webit.git
andyhmy
Webit
BitMQ
master

搜索帮助