Guides
Benchmark Tools
Understand how to run the test tools, tune parameters, and verify results.
Benchmark tool guide
This guide explains how to configure, compile, and execute the OpenIMSDK benchmark suites in open-source self-hosted environments.
Combined benchmark workflow
A complete benchmark run combines background load generation with sampled statistical measurement:
- Start the backend stack:
- Launch OpenIMServer and dependent components (MongoDB, Redis, Kafka, Etcd, MinIO).
- Scale worker instances based on target throughput (for example,
openim-push: 8andopenim-msgtransfer: 8). - Start the stress generator (
msgtest): - Update connection parameters in
msgtest/module/pressure.go. - Compile and execute the binary to establish concurrent connections and generate message load.
- Start the sampling verifier (
integration_test): - Configure endpoints in
integration_test/internal/config/config.go. - After background load stabilizes, start
integration_testto record delivery rates, measure latency, and verify data consistency.
integration_test
Source directory: openim-sdk-core/integration_test/
CLI flags
| Flag | Description | Type |
|---|---|---|
test | Enable SDK test mode | bool |
u | Total simulated user count | int |
su | Number of users connected with full friend lists | int |
lg | Number of supergroups | int |
lgm | Member count per supergroup | int |
cg | Regular groups created per user | int |
cgm | Member count per regular group | int |
sm | Direct messages sent per user | int |
gm | Group messages sent per user | int |
msgitv | Message dispatch interval (ms) | int |
reg | Register new user accounts | bool |
imf | Import friendship relationships | bool |
crg | Create test groups | bool |
sem | Send test messages | bool |
ckgn | Assert total group count | bool |
ckcon | Assert conversation count | bool |
ckmsn | Assert message delivery count | bool |
ckuni | Simulate client reinstall and re-verify state | bool |
lgr | Ratio of simulated users logging in | float |
Configuration parameters
- File:
openim-sdk-core/integration_test/internal/config/config.go - Fields to review:
TestIP,APIAddr,WsAddr,AdminUserID,Secret,PlatformID, andDataDir
Example commands
- Pre-register users only (data preparation):
go run main.go -reg -u 100000- Sampled login, contact sync, group creation, messaging, and assertions:
go run main.go \
-lgr 0.8 -test \
-u 100 -su 3 -lg 0 -cg 4 -cgm 5 \
-sm 100 -gm 100 -msgitv 1500 \
-imf -crg -sem -ckgn -ckcon -ckmsn- Small-scale end-to-end smoke test (verifies environment health):
go run main.go \
-test \
-u 10 -su 3 -lg 2 -cg 4 -cgm 5 \
-sm 6 -gm 7 -msgitv 1000 \
-reg -lgr 0.7 -imf -crg -ckgn -ckcon -sem -ckmsn -ckunimsgtest
Source directory: openim-sdk-core/msgtest/ (entry point: msgtest/main/main.go)
Compile the binary
cd openim-sdk-core/msgtest
go build -o main ./mainConfiguration parameters
- File:
openim-sdk-core/msgtest/module/pressure.go - Fields to review:
TESTIP,APIADDR,WSADDR,MANAGERUSERID,SECRET, andPLATFORMID
CLI flags
| Flag | Description | Type | Default |
|---|---|---|---|
-o | Total concurrent online users | int | 20000 |
-s | Starting user ID index (used with -e) | int | 0 |
-e | Ending user ID index (used with -s) | int | 0 |
-sr | Direct message sampling ratio | float | 0.01 |
-rs | Number of randomized direct message senders | int | 0 |
-rr | Number of randomized recipients per sender | int | 0 |
-c | Message volume per sender-recipient pair | int | 0 |
-i | Dispatch interval per sender (ms) | int | 1000 |
-r | Register user accounts | bool | false |
-u | Hold online connections without publishing messages | bool | false |
-pp | Enable pprof profiling server (0.0.0.0:6060) | bool | false |
-gsr | Ratio of active group senders | float | 0.1 |
-gor | Ratio of online group members | float | 0.0 |
-htg | Number of 100,000-member groups | int | 0 |
-ttg | Number of 10,000-member groups | int | 0 |
-otg | Number of 1,000-member groups | int | 0 |
-hog | Number of 100-member groups | int | 0 |
-fog | Number of 50-member groups | int | 0 |
-teg | Number of 10-member groups | int | 0 |
Example commands
- Maintain 50,000 idle online connections:
nohup ./main -o 50000 -u >> openIM.log 2>&1 &- Maintain 50,000 online connections with direct message traffic:
nohup ./main -o 50000 -rs 300 -rr 300 -c 100 -i 1 -r >> openIM.log 2>&1 &Benchmark tuning considerations
Apply the following operating system and service adjustments to avoid bottlenecks in the benchmark client itself:
- Extend HTTP client timeout:
- Component: OpenIMClientSDK (
openim-sdk-core) - File:
openim-sdk-core/pkg/network/http_client.go - Action: Increase default
Timeoutto accommodate high server load under benchmark conditions. - Increase SDK async channel timeout:
- Component: OpenIMClientSDK (
openim-sdk-core) - File:
openim-sdk-core/pkg/common/trigger_channel.go - Action: Increase
const timeoutto avoid client-side channel drops during backpressure. - Extend server notification timeout:
- Component: OpenIMServer
- File:
open-im-server/pkg/notification/msg.go - Action: Adjust
WithTimeoutcontext timeouts to provide headroom during high-throughput message bursts. - Reduce server logging verbosity:
- Component: OpenIMServer
- File:
open-im-server/config/log.yml - Action: Set
remainLogLevelto3to minimize disk I/O contention. - Standardize unread count evaluation:
- Component: OpenIMServer
- File:
open-im-server/config/notification.yml - Action: Set
unreadCounttotrueforgroupCreatedandfriendApplicationApprovedevents to maintain consistent unread calculations across test iterations. - Raise server file descriptor limits:
- Component: OpenIMServer
- File:
open-im-server/start-config.yml - Action: Increase
maxFileDescriptorsproportionally to target concurrent client connections. - Expand local ephemeral port range on the client host:
- Host: Machine executing
msgtest - Command:
sudo sysctl -w net.ipv4.ip_local_port_range="10000 65000"- Enable complete online user caching:
- Component: OpenIMServer
- File:
open-im-server/config/openim-push.yml - Action: Set
fullUserCachetotrueto cache online presence states and optimize push routing efficiency.