This commit is contained in:
2026-04-25 16:36:34 +08:00
commit db90e7579b
1876 changed files with 189777 additions and 0 deletions

View File

@@ -0,0 +1,112 @@
---
sidebar_position: 1
title: 命令行工具测试方式
---
首先需要确保已经安装了 `tailchat-cli`, 版本在 `1.5.8` 以上, 安装方式见: [命令行工具 tailchat-cli](../cli/tailchat-cli.md)
你可以在 Tailchat 的 Help 指令看到benchmark支持的如下命令:
```
tailchat benchmark
Tailchat Benchmark Test
Commands:
tailchat benchmark message Stress testing through Tailchat network
requests (suitable for pure business
testing)
tailchat benchmark connections <url> Test Tailchat Connections
tailchat benchmark register <url> Create Tailchat temporary account and
output token
Options:
--version Show version number [boolean]
-h, --help Show help [boolean]
```
其中我们主要使用的是`connections`命令与`register`命令
## 批量注册测试用户
首先我们需要批量注册测试用户, 这里我们需要用到`register`命令
```
tailchat benchmark register <url>
Create Tailchat temporary account and output token
Options:
--version Show version number [boolean]
--file Account Token Path [string] [required] [default: "./accounts"]
--count Register Count [number] [required] [default: 100]
--invite Invite Code [string]
-h, --help Show help [boolean]
--url [required]
```
如我们需要在本地批量注册账号
```bash
tailchat benchmark register http://127.0.0.1:11000
```
该命令会在`http://127.0.0.1:11000`服务下注册100个临时用户。注意结尾不需要'/'。
命令执行完毕后,会将用于登录的 token 保存到本地文件,默认是`./accounts`文件。
我们可以用`--count`指定注册的数量, 以及用`--invite` 来让其在注册后自动加入某个测试群组
如:
```bash
tailchat benchmark register http://127.0.0.1:11000 --count 10000 --invite <invite-code>
```
> 注意: 为了保证服务质量,注册操作是以串行方式进行发送的,即前一个注册操作完成后后一个注册操作才会开始。因此如果设定数量过大的话可能会导致耗时很长。
其中`<invite-code>`需要用户自行创建群组并创建一个邀请链接。一个邀请链接的格式形如: `http://localhost:11011/invite/<invite-code>`
完成后我们就可以获得对应数量的测试用户加入群组。
## 用户批量登录
我们要测试服务器在允许多人在线情况下的表现,我们需要使用`connections`命令来登录并建立连接。
`connections`命令会自动读取上个操作批量注册后的token文件作为需要登录的用户
```
tailchat benchmark connections <url>
Test Tailchat Connections
Options:
--version Show version number [boolean]
--file Account Token Path
[string] [required] [default: "./accounts"]
--groupId Group Id which send Message [string]
--converseId Converse Id which send Message [string]
-h, --help Show help [boolean]
--url [required]
```
如我们要直接登录到本地的服务:
```bash
tailchat benchmark connections http://127.0.0.1:11000
```
此时我们可以通过服务端的资源检测工具查看当测试用户都上线后服务端的内存占用与cpu占用情况。
### 消息推送用时检测
为了测试Tailchat聊天服务器在实际会话中的表现我们可以检测一条消息从客户端发送给服务端并且服务端将消息广播到所有用户所需要的用时。
这里我们需要指定要发送消息的目标,如下
```bash
tailchat benchmark connections http://127.0.0.1:11000 --groupId <groupId> --converseId <converseId>
```
在群组会话中的地址栏格式形如: `http://localhost:11011/main/group/<groupId>/<converseId>`
当所有会话接受完毕后,会打印出期间的耗时

View File

@@ -0,0 +1,239 @@
---
sidebar_position: 2
title: 压测报告
---
## 集群压测
:::info
测试版本: v1.7.6
测试集群基本信息:
- mongo: **0.2**cpu **256**Mi内存 单实例
- redis: **0.1**cpu **64**Mi内存 单实例
- minio: **0.1**cpu **128**Mi内存 单实例
- tailchat: **0.2**cpu **512**Mi内存 3实例
> 测试服务为完整服务即加载了service和plugins的完整服务没有进行任何为数据好看而做的任何定向优化(可以通过控制减少加载的服务以及关闭部分不必要的能力来获得更好的性能)
>
> 其中, cpu型号为: `Intel(R) Xeon(R) CPU @ 2.20GHz`
>
> 服务器网络使用的是`新加坡 谷歌云`,测试机器是使用的 `电信 上海`. 实际有一定网络损耗. 本次压测由 sealos 提供集群服务.
:::
### 测试方式
测试方式由一个实际观察者 + 若干个由cli启动的虚拟用户构成。测试方法见: [cli](./cli.md)
主要命令如下:
```
tailchat benchmark register https://<xxxxxx>.cloud.sealos.io --invite <inviteCode>
tailchat benchmark connections https://<xxxxxx>.cloud.sealos.io
tailchat benchmark connections https://<xxxxxx>.cloud.sealos.io --groupId <groupId> --converseId <converseId> --messageNum 5
```
> 以下关于cpu/内存的描述都是多个实例的平均值
### 百人在线测试
#### 在线情况
仅登录一个实际用户的情况下,系统占用情况为:
- cpu: 0.90 %
- 内存: 176.3 Mi
登录 100 个在线用户以后,系统占用情况为:
- cpu: 14.80 % -> 8.89% -> 1.33%(因为实际观察者一次性获取了所有的100个用户在线信息)
- 内存: 179.37 Mi
#### 消息发送情况
测试5次所有消息发送与接收情况
```
✔ 100 clients has been create.
Start send message test: 1
Start message receive test, message: 0c55e168904f02a3
✔ All client received, usage: 420ms
Start send message test: 2
Start message receive test, message: 6f000fb91dc85fe1
✔ All client received, usage: 89ms
Start send message test: 3
Start message receive test, message: 79cce2beee015c5f
✔ All client received, usage: 89ms
Start send message test: 4
Start message receive test, message: 8df7c58fdadb30aa
✔ All client received, usage: 96ms
Start send message test: 5
Start message receive test, message: 97c782b36312022c
✔ All client received, usage: 98ms
```
### 500人在线测试
#### 在线情况
不登录任何用户的情况下,系统占用情况为:
- cpu: 0.92 %
- 内存: 208.5533 Mi
登录 500 个在线用户以后,系统占用情况为:
- cpu: 3.30%
- 内存: 241.1933 Mi
#### 消息发送情况
测试5次所有消息发送与接收情况
```
✔ 500 clients has been create.
Start send message test: 1
Start message receive test, message: ef39144e96ce3ab8
✔ All client received, usage: 497ms
Start send message test: 2
Start message receive test, message: 5a86b397aab8ff92
✔ All client received, usage: 406ms
Start send message test: 3
Start message receive test, message: 69066c6d4a4402b0
✔ All client received, usage: 403ms
Start send message test: 4
Start message receive test, message: 3b066befc54b4835
✔ All client received, usage: 424ms
Start send message test: 5
Start message receive test, message: 3a6ef9cc7e8e6eac
✔ All client received, usage: 752ms
```
### 千人在线测试
#### 在线情况
不登录任何用户的情况下,系统占用情况为:
- cpu: 0.88 %
- 内存: 202.978 Mi
> 当我建立800以上的连接的时候会触发大量的`transport close`错误无法建立连接
>
> 为了让能够同时承载1000人我选择进行水平扩容将实例数拓展成5个实例
登录 1000 个在线用户以后,系统占用情况为:
- cpu: 3.27%
- 内存: 210.876 Mi
#### 消息发送情况
测试5次所有消息发送与接收情况
```
✔ 1000 clients has been create.
Start send message test: 1
Start message receive test, message: e65050aa6d4237bb
✔ All client received, usage: 2194ms
Start send message test: 2
Start message receive test, message: a7b02d30e25f02d0
✔ All client received, usage: 954ms
Start send message test: 3
Start message receive test, message: 75aa655a94cb308f
✔ All client received, usage: 988ms
Start send message test: 4
Start message receive test, message: 106b8830443002d9
✔ All client received, usage: 733ms
Start send message test: 5
Start message receive test, message: 0593646f9c7da288
✔ All client received, usage: 738ms
```
## 单机压测
:::info
测试版本: v1.7.6
测试环境基本信息:
- NAS部署依赖(DS220plus): Intel Celeron J4025, 2GB DDR4
- mongo
- redis
- minio
- 家用机, cpu: i7-8700K, 32G内存
- tailchat
:::
### 2000人在线测试
#### 消息发送情况
测试5次所有消息发送与接收情况
```
✔ 2000 clients has been create.
Start send message test: 1
Start message receive test, message: 8f4edd63886d80eb
✔ All client received, usage: 244ms
Start send message test: 2
Start message receive test, message: 20e0bc3e2ea1365c
✔ All client received, usage: 246ms
Start send message test: 3
Start message receive test, message: 7bed6a2cb12238a5
✔ All client received, usage: 248ms
Start send message test: 4
Start message receive test, message: 6f49353efa2467fc
✔ All client received, usage: 245ms
Start send message test: 5
Start message receive test, message: 850bed7ed8fa860c
✔ All client received, usage: 248ms
```
### 5000人在线测试
#### 消息发送情况
测试5次所有消息发送与接收情况
```
✔ 5000 clients has been create.
Start send message test: 1
Start message receive test, message: 85e2624234b8c66a
✔ All client received, usage: 933ms
Start send message test: 2
Start message receive test, message: ae025dd881ef5ae7
✔ All client received, usage: 714ms
Start send message test: 3
Start message receive test, message: 55a6c359fe74c90f
✔ All client received, usage: 691ms
Start send message test: 4
Start message receive test, message: 9eaefcc761c77c8c
✔ All client received, usage: 644ms
Start send message test: 5
Start message receive test, message: 856a49a1528ad5e1
✔ All client received, usage: 787ms
```
### 万人在线测试
#### 消息发送情况
测试5次所有消息发送与接收情况
```
✔ 10000 clients has been create.
Start send message test: 1
Start message receive test, message: 06b6bf829b66cca9
✔ All client received, usage: 1219ms
Start send message test: 2
Start message receive test, message: 3a544d3c0e6d8a14
✔ All client received, usage: 1189ms
Start send message test: 3
Start message receive test, message: b1d0ea01481b6717
✔ All client received, usage: 1089ms
Start send message test: 4
Start message receive test, message: af3512e57ce2ad0e
✔ All client received, usage: 1142ms
Start send message test: 5
Start message receive test, message: d09db4b9a348b32a
✔ All client received, usage: 1232ms
```