This document provides an overview of the Yorkie load test script and how to profile the Yorkie server using pprof.
Install k6: Ensure you have k6 installed on your machine. You can download it from k6.io.
There are three types of load tests available:
- Tests basic presence functionality without streaming
- Simulates users updating their presence data via Document API
- Ideal for testing presence update latency and throughput in
PushPull
- Tests real-time presence streaming capabilities via Document API
- Simulates both watchers (who observe changes) and updaters (who make changes)
- Tests watch stream performance and resource usage
- Tests the dedicated Channel API (AttachChannel, DetachChannel)
- Simulates clients repeatedly attaching and detaching from channels
- Ideal for testing channel presence count accuracy and attach/detach performance
- Verifies that presence count increments/decrements correctly under load
Start the Yorkie server with pprof enabled:
yorkie server --mongo-connection-uri mongodb://localhost:27017 --pprof-enabledRun the basic presence load test in even mode (distributed across multiple documents):
k6 run -e DOC_KEY_PREFIX=even-1 -e TEST_MODE=even -e CONCURRENCY=500 -e VU_PER_DOCS=10 presence.tsThis runs the test with 50 documents, each with 10 virtual users, for a total of 500 concurrent users.
Run the test in skew mode (all users on a single document):
k6 run -e DOC_KEY_PREFIX=skew-1 -e TEST_MODE=skew -e CONCURRENCY=500 presence.tsThis runs the test with a single document with 500 virtual users.
Run the advanced presence test with streaming in even mode:
k6 run -e DOC_KEY_PREFIX=stream-1 -e TEST_MODE=even -e CONCURRENCY=500 -e VU_PER_DOCS=10 -e WATCHER_RATIO=0.5 presence-with-stream.tsThis test simulates a realistic scenario with both watchers and updaters:
- Watchers: Connect to documents and watch for presence changes via streaming
- Updaters: Continuously make presence updates to documents
Run the stream test in skew mode (high-contention scenario):
k6 run -e DOC_KEY_PREFIX=stream-skew-1 -e TEST_MODE=skew -e CONCURRENCY=500 -e WATCHER_RATIO=0.3 presence-with-stream.tsThis creates a high-contention scenario with 150 watchers and 350 updaters all on the same document.
Run the channel API test in even mode (distributed across multiple channels):
k6 run -e CHANNEL_KEY_PREFIX=channel-1 -e TEST_MODE=even -e CONCURRENCY=500 -e VU_PER_CHANNEL=10 -e ATTACH_ITERATIONS=5 channel-presence.tsThis runs the test with 50 channels, each with 10 virtual users, where each user performs 5 attach/detach cycles.
Run the test in skew mode (all users on a single channel for high contention):
k6 run -e CHANNEL_KEY_PREFIX=channel-skew-1 -e TEST_MODE=skew -e CONCURRENCY=500 -e ATTACH_ITERATIONS=5 channel-presence.tsThis creates a high-contention scenario with 500 users all attaching/detaching from the same channel, ideal for testing presence count accuracy under heavy concurrent access.
DOC_KEY_PREFIX: Prefix for document keys (creates unique keys for each test run)TEST_MODE: Choose betweenskew(single document) oreven(multiple documents)CONCURRENCY: Number of concurrent users to simulate
VU_PER_DOCS: Number of virtual users per document (only inevenmode)
WITH_VERSION_VECTOR: If true, update presence including explicit version vectors
WATCHER_RATIO: Ratio of watchers to total users (0.0 to 1.0). Example: 0.5 = 50% watchers, 50% updaters
CHANNEL_KEY_PREFIX: Prefix for channel keys (creates unique keys for each test run)VU_PER_CHANNEL: Number of virtual users per channel (only inevenmode)ATTACH_ITERATIONS: Number of attach/detach cycles each user performs (default: 5)
The Yorkie server runs with pprof enabled on port 8081.
Collect CPU profile data:
curl http://localhost:8081/debug/pprof/profile\?seconds\=150 --output cpu.outOpen the interactive pprof web tool:
go tool pprof -http=:9090 cpu.outCollect heap memory profile data (during load test):
curl http://localhost:8081/debug/pprof/heap --output mem.outOpen the interactive pprof web tool:
go tool pprof -http=:9090 mem.out