docs: add document about benckmark test guide

pull/90/head
moonrailgun 2 years ago
parent d09682139f
commit a9ea4f50bb

@ -1,6 +1,6 @@
{
"name": "tailchat-cli",
"version": "1.5.7",
"version": "1.5.8",
"description": "A Command line interface of tailchat",
"bin": {
"tailchat": "./bin/cli"

@ -0,0 +1,4 @@
{
"label": "Benchmark",
"position": 50
}

@ -0,0 +1,112 @@
---
sidebar_position: 1
title: cli Test Method
---
First of all, you need to make sure that `tailchat-cli` has been installed, and the version is above `1.5.8`. For the installation method, see: [tailchat-cli](../cli/tailchat-cli.md)
You can see the following commands supported by benchmark in the Help command of Tailchat:
```
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]
```
Among them, we mainly use the `connections` command and the `register` command
## Register test users in batches
First of all, we need to register test users in batches, here we need to use the `register` command
```
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
```
If we need to register accounts locally in batches
```bash
tailchat benchmark register http://127.0.0.1:11000
```
This command will register 100 temporary users under `http://127.0.0.1:11000` service. Note that the '/' is not required at the end.
After the command is executed, the token used for login will be saved to a local file, the default is `./accounts` file.
We can use `--count` to specify the number of registrations, and `--invite` to let it automatically join a test group after registration
like:
```bash
tailchat benchmark register http://127.0.0.1:11000 --count 10000 --invite <invite-code>
```
> Note: In order to ensure the quality of service, the register operation is sent in a serial manner, that is, the subsequent register operation will start after the previous register operation is completed. Therefore, if the number of settings is too large, it may take a long time.
Among them, `<invite-code>` requires the user to create a group and create an invitation link. The format of an invite link is: `http://localhost:11011/invite/<invite-code>`
After completion, we can get the corresponding number of test users to join the group.
## User batch login
We want to test the performance of the server when multiple people are allowed online, we need to use the `connections` command to log in and establish a connection.
The `connections` command will automatically read the token file after batch registration in the previous operation as the user who needs to log in
```
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]
```
If we want to log in directly to the local service:
```bash
tailchat benchmark connections http://127.0.0.1:11000
```
At this point, we can use the resource detection tool on the server to check the memory usage and CPU usage of the server after all test users are online.
### Message push/receive time detection
In order to test the performance of the Tailchat chat server in an actual session, we can measure the time it takes for a message to be sent from the client to the server and for the server to broadcast the message to all users.
Here we need to specify the target to send the message, as follows:
```bash
tailchat benchmark connections http://127.0.0.1:11000 --groupId <groupId> --converseId <converseId>
```
The format of the address bar in a group session is: `http://localhost:11011/main/group/<groupId>/<converseId>`
When all sessions are accepted, the time spent during the period will be printed

@ -0,0 +1,6 @@
---
sidebar_position: 2
title: Benchmark Report
---
Coming Soon

@ -50,5 +50,13 @@
"sidebar.tutorialSidebar.category.Guide": {
"message": "指南",
"description": "The label for category Guide in sidebar tutorialSidebar"
},
"sidebar.tutorialSidebar.category.Kubernetes": {
"message": "Kubernetes",
"description": "The label for category Kubernetes in sidebar tutorialSidebar"
},
"sidebar.tutorialSidebar.category.Benchmark": {
"message": "压力测试",
"description": "The label for category Benchmark in sidebar tutorialSidebar"
}
}

@ -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>`
当所有会话接受完毕后,会打印出期间的耗时

@ -0,0 +1,6 @@
---
sidebar_position: 2
title: 压测报告
---
Coming Soon
Loading…
Cancel
Save