Browse OpenIMSDK Guides
Guides

Benchmark Tools

Understand how to run the test tools, tune parameters, and verify results.

Copy

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:

  1. Start the backend stack:
  2. Launch OpenIMServer and dependent components (MongoDB, Redis, Kafka, Etcd, MinIO).
  3. Scale worker instances based on target throughput (for example, openim-push: 8 and openim-msgtransfer: 8).
  4. Start the stress generator (msgtest):
  5. Update connection parameters in msgtest/module/pressure.go.
  6. Compile and execute the binary to establish concurrent connections and generate message load.
  7. Start the sampling verifier (integration_test):
  8. Configure endpoints in integration_test/internal/config/config.go.
  9. After background load stabilizes, start integration_test to record delivery rates, measure latency, and verify data consistency.

integration_test

Source directory: openim-sdk-core/integration_test/

CLI flags

FlagDescriptionType
testEnable SDK test modebool
uTotal simulated user countint
suNumber of users connected with full friend listsint
lgNumber of supergroupsint
lgmMember count per supergroupint
cgRegular groups created per userint
cgmMember count per regular groupint
smDirect messages sent per userint
gmGroup messages sent per userint
msgitvMessage dispatch interval (ms)int
regRegister new user accountsbool
imfImport friendship relationshipsbool
crgCreate test groupsbool
semSend test messagesbool
ckgnAssert total group countbool
ckconAssert conversation countbool
ckmsnAssert message delivery countbool
ckuniSimulate client reinstall and re-verify statebool
lgrRatio of simulated users logging infloat

Configuration parameters

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

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 -ckuni

msgtest

Source directory: openim-sdk-core/msgtest/ (entry point: msgtest/main/main.go)

Compile the binary

cd openim-sdk-core/msgtest
go build -o main ./main

Configuration parameters

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

CLI flags

FlagDescriptionTypeDefault
-oTotal concurrent online usersint20000
-sStarting user ID index (used with -e)int0
-eEnding user ID index (used with -s)int0
-srDirect message sampling ratiofloat0.01
-rsNumber of randomized direct message sendersint0
-rrNumber of randomized recipients per senderint0
-cMessage volume per sender-recipient pairint0
-iDispatch interval per sender (ms)int1000
-rRegister user accountsboolfalse
-uHold online connections without publishing messagesboolfalse
-ppEnable pprof profiling server (0.0.0.0:6060)boolfalse
-gsrRatio of active group sendersfloat0.1
-gorRatio of online group membersfloat0.0
-htgNumber of 100,000-member groupsint0
-ttgNumber of 10,000-member groupsint0
-otgNumber of 1,000-member groupsint0
-hogNumber of 100-member groupsint0
-fogNumber of 50-member groupsint0
-tegNumber of 10-member groupsint0

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:

  1. Extend HTTP client timeout:
  2. Component: OpenIMClientSDK (openim-sdk-core)
  3. File: openim-sdk-core/pkg/network/http_client.go
  4. Action: Increase default Timeout to accommodate high server load under benchmark conditions.
  5. Increase SDK async channel timeout:
  6. Component: OpenIMClientSDK (openim-sdk-core)
  7. File: openim-sdk-core/pkg/common/trigger_channel.go
  8. Action: Increase const timeout to avoid client-side channel drops during backpressure.
  9. Extend server notification timeout:
  10. Component: OpenIMServer
  11. File: open-im-server/pkg/notification/msg.go
  12. Action: Adjust WithTimeout context timeouts to provide headroom during high-throughput message bursts.
  13. Reduce server logging verbosity:
  14. Component: OpenIMServer
  15. File: open-im-server/config/log.yml
  16. Action: Set remainLogLevel to 3 to minimize disk I/O contention.
  17. Standardize unread count evaluation:
  18. Component: OpenIMServer
  19. File: open-im-server/config/notification.yml
  20. Action: Set unreadCount to true for groupCreated and friendApplicationApproved events to maintain consistent unread calculations across test iterations.
  21. Raise server file descriptor limits:
  22. Component: OpenIMServer
  23. File: open-im-server/start-config.yml
  24. Action: Increase maxFileDescriptors proportionally to target concurrent client connections.
  25. Expand local ephemeral port range on the client host:
  26. Host: Machine executing msgtest
  27. Command:
     sudo sysctl -w net.ipv4.ip_local_port_range="10000 65000"
  1. Enable complete online user caching:
  2. Component: OpenIMServer
  3. File: open-im-server/config/openim-push.yml
  4. Action: Set fullUserCache to true to cache online presence states and optimize push routing efficiency.