Repository navigation
Simulating Real Users
Normal benchmarking just blasts requests as fast as possible. But real users don't work that way — they click a link, read the page, click another link, wait a bit, and so on.
User simulation mode makes your test behave like real people browsing your site.
Each "virtual user":
- Sends a request
- Waits for the response
- Pauses for a bit (this is called "think time" — like a person reading the page)
- Sends another request
- Repeats until the test ends
# Simulate 100 users browsing for 60 seconds
pywrkr http://localhost:8080/ -u 100 -d 60The -u flag switches pywrkr from "blast mode" to "user simulation mode."
By default, each user waits 1 second between requests. You can change this:
# Users wait 2 seconds between requests (slow browsing)
pywrkr http://localhost:8080/ -u 100 -d 60 --think-time 2.0
# Users wait 0.5 seconds (fast clicking)
pywrkr http://localhost:8080/ -u 100 -d 60 --think-time 0.5
# No waiting at all (back to stress test, but with user count)
pywrkr http://localhost:8080/ -u 100 -d 60 --think-time 0In real life, users don't all arrive at the same second. Use --ramp-up to start users gradually:
# 500 users, but start them over 30 seconds (not all at once)
pywrkr http://localhost:8080/ -u 500 -d 120 --ramp-up 30This means:
- At second 0: ~0 users active
- At second 15: ~250 users active
- At second 30: all 500 users active
- Seconds 30-120: all 500 users running
Why ramp up? Starting all users at once creates a "thundering herd" — a huge spike that can crash your server before it even warms up. Ramp-up is more realistic and gives your server time to scale up (auto-scaling, connection pools, etc).
Real users don't all wait exactly the same amount of time. Jitter adds randomness:
# Think time: 1 second +/- 50% (so 0.5 to 1.5 seconds randomly)
pywrkr http://localhost:8080/ -u 200 -d 60 --think-time 1.0 --think-jitter 0.5The default jitter is 0.5 (50%), which is usually fine. Set it to 0 for perfectly uniform think time.
Here's a test that closely simulates real traffic:
# 300 users, 5-minute test, 30-second ramp-up, 1.5s think time
pywrkr http://localhost:8080/ \
-u 300 \
-d 300 \
--ramp-up 30 \
--think-time 1.5 \
--think-jitter 0.5User simulation results include extra info:
Mode: 300 virtual users, 300.0s
Virtual Users: 300
Ramp-up: 30.00s
Think Time: 1.50s (+/-50%)
Avg Reqs/User: 120.5
Avg Reqs/User tells you how many pages each virtual user visited during the test.
| Scenario | Use this |
|---|---|
| "How many requests/sec can my server handle?" | Regular mode: pywrkr url -c 100 -d 30
|
| "Can my server handle 500 concurrent users?" | User simulation: pywrkr url -u 500 -d 60
|
| "What happens during a traffic spike?" | User sim + ramp-up: pywrkr url -u 1000 -d 120 --ramp-up 10
|
| "What's the experience like for real users?" | User sim + think time: pywrkr url -u 200 -d 300 --think-time 1.5
|