load testing
Guide for load testing
Load Testing Guide
This guide details how to perform mass simulations and stress tests on the
loh-game server using the load-test-client.Prerequisites
- Game Server Running: Ensure
loh-gameis running (defaultws://localhost:8080/ws). - Observability Stack: (Optional but recommended) Run Prometheus/Grafana to visualize metrics. See
observability.md.
Load Test Client
The load test client is a headless bot harness capable of simulating thousands of players with scripted behaviors.
Location:
loh-backend/rust-engine/crates/load-test-client/Features
- Headless: No rendering overhead.
- WebSocket: Connects to game server like a real client.
- State Machine: Bots have states (
Idle,Moving,Combat,Interacting). - Roles: Bots are assigned logic roles (
Miner,Woodcutter,Pker,PveAttacker).
Running Mass Simulations
Use the
spawn_bots.sh script to launch multiple instances of the client. This is necessary because OS thread limits might bottleneck a single process before the server is stressed.Script Location:
loh-backend/rust-engine/spawn_bots.shUsage
./spawn_bots.sh <total_bots> <bots_per_instance> <server_url> <scenario>total_bots: Total number of connected clients to simulate.bots_per_instance: How many bots each OS process should handle (Recommend 50-100).server_url: WebSocket URL of the game server.scenario: The behavior pattern to test (see below).
Scenarios
Example Commands
1. General Stress Test (1000 players)
./spawn_bots.sh 1000 100 ws://localhost:8080/ws mixed2. PvP Clan War Simulation (500 players)
./spawn_bots.sh 500 50 ws://localhost:8080/ws pvp_multiMonitoring Results
Use the SRE Dashboard in Grafana (
http://localhost:6006) to monitor:- Game Tick Duration: Should remain near target (e.g., 600ms or 400ms). Spikes indicate logic bottlenecks.
- Connected Players: Verify the server handles the concurrent connections.
- Messages Processed: Throughput of the networking layer.
- Database Query Duration: Latency of persistence (saving player state).
See
observability.md for setup details.