Skip to main content

Benchmark Tool Guide

This document guides you through modifying configuration, building, and running the benchmark programs in the open-source edition.


Combined Stress Testing Workflow

Follow these steps to complete a combined "stress + sampling reliability/latency" benchmark:

  1. Start the server (OpenIMServer + components).
  • Adjust server instance counts based on the test scale (e.g., openim-push: 8, openim-msgtransfer: 8).
  1. Start the stress side (msgtest).
  • Modify the msgtest connection config first (see msgtest/module/pressure.go), then build and run.
  1. Start the sampling side (integration_test).
  • Modify the integration_test connection config file: integration_test/internal/config/config.go.
  • After the stress load stabilizes, start integration_test to run reliability and latency statistics with necessary consistency checks.

integration_test

Program path: openim-sdk-core/integration_test/

Parameters

ParameterDescriptionType
testWhether the SDK runs in test modebool
uNumber of usersint
suNumber of users with all friendsint
lgNumber of large groupsint
lgmNumber of large group membersint
cgNumber of regular groups created per userint
cgmNumber of regular group membersint
smNumber of private messages sent per userint
gmNumber of group messages sent per userint
msgitvMessage sending interval (ms)int
regWhether to register usersbool
imfWhether to import friendsbool
crgWhether to create groupsbool
semWhether to send messagesbool
ckgnWhether to check group countbool
ckconWhether to check conversation countbool
ckmsnWhether to check message countbool
ckuniWhether to simulate uninstall/reinstall and recheckbool
lgrLogin user ratio / login ratefloat

Configuration File

  • File: openim-sdk-core/integration_test/internal/config/config.go
  • Fields to modify: TestIP / APIAddr / WsAddr / AdminUserID / Secret / PlatformID / DataDir

Example Commands

  • Register users only (data preparation):
go run main.go -reg -u 100000
  • Sampling login + import friends + create groups + send messages + verification (common combined benchmark mode):
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 full pipeline verification (for quickly verifying the environment works):
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 -ckuni

msgtest

Program path: openim-sdk-core/msgtest/, entry point: msgtest/main/main.go

Build

cd openim-sdk-core/msgtest

go build -o main ./main

Configuration

msgtest connection configuration:

  • File: openim-sdk-core/msgtest/module/pressure.go
  • Fields to modify: TESTIP / APIADDR / WSADDR / MANAGERUSERID / SECRET / PLATFORMID

Parameters

ParameterDescriptionTypeDefault
-oTotal online usersint20000
-sStart user (used with -e)int0
-eEnd user (used with -s)int0
-srPrivate chat sampling ratefloat0.01
-rsNumber of random private chat sendersint0
-rrNumber of random recipients per senderint0
-cMessages per sender per recipientint0
-iSend interval per sender (ms)int1000
-rWhether to register usersboolfalse
-uStay online only, no message sendingboolfalse
-ppEnable pprof (0.0.0.0:6060)boolfalse
-gsrGroup chat sender ratiofloat0.1
-gorGroup chat online ratiofloat0.0
-htgNumber of 100K-member groupsint0
-ttgNumber of 10K-member groupsint0
-otgNumber of 1K-member groupsint0
-hogNumber of 100-member groupsint0
-fogNumber of 50-member groupsint0
-tegNumber of 10-member groupsint0

Example Commands

  • 50K online (stay online only):
nohup ./main -o 50000 -u >> openIM.log 2>&1 &
  • 50K online + private chat stress test (example: 300 senders, 300 recipients, 100 messages each):
nohup ./main -o 50000 -rs 300 -rr 300 -c 100 -i 1 -r >> openIM.log 2>&1 &

Important Notes

The following adjustments improve benchmark stability to prevent the "benchmark program's own overhead" from interfering with OpenIMServer (ChatServer) capacity assessment.

  1. Modify request timeout

    • Program: OpenIMClientSDK (openim-sdk-core)
    • Location: openim-sdk-core/pkg/network/http_client.go
    • Action: Search for Timeout and increase the default timeout appropriately.
  2. Modify SDK async pipeline timeout

    • Program: OpenIMClientSDK (openim-sdk-core)
    • Location: openim-sdk-core/pkg/common/trigger_channel.go
    • Action: Find const timeout and increase the pipeline timeout appropriately.
  3. Modify server notification timeout

    • Program: OpenIMServer
    • Location: open-im-server/pkg/notification/msg.go
    • Action: Search for WithTimeout and increase the context timeout appropriately.
  4. Lower server log level

    • Program: OpenIMServer
    • Location: open-im-server/config/log.yml
    • Action: Set remainLogLevel to 3.
  5. Notification message unread status (for consistent unread count metrics)

    • Program: OpenIMServer
    • Location: open-im-server/config/notification.yml
    • Action: Set unreadCount to true for groupCreated and friendApplicationApproved.
  6. Server max connection count (FD)

    • Program: OpenIMServer
    • Location: open-im-server/start-config.yml
    • Action: Increase maxFileDescriptors based on the number of users to be logged in.
  7. Client dynamic port range

    • Location: The benchmark machine running msgtest
sudo sysctl -w net.ipv4.ip_local_port_range="10000 65000"
  1. Enable full online cache
    • Program: OpenIMServer
    • Location: open-im-server/config/openim-push.yml
    • Action: Set fullUserCache to true.