What are Monitors?
Monitors are separate background processes that run during tests to collect additional metrics and data beyond standard load testing metrics. They provide insights into the blockchain node’s behavior and performance characteristics.Monitors currently only work in headless mode. They are not available when running in web UI mode.
Available Monitors
sync-lag-monitor
The sync-lag monitor tracks how far behind real-time the node is by comparing block timestamps to the current time. What it measures:- Sync lag in seconds
- Block number being served
- Timestamp of measurements
- Fetches the latest block from the node every 10 seconds
- Extracts the block timestamp
- Calculates the difference between current time and block timestamp
- Records the lag to a CSV file
Using Monitors
Add monitors to your test using the-m or --monitor flag:
You can specify multiple monitors by using the
-m flag multiple times:Sync Lag Monitor
Use Cases
Testing Sync Performance:- Monitor if a node stays in sync during heavy load
- Identify if load testing impacts sync performance
- Track recovery after network partitions
- Verify archive nodes serve historical data correctly
- Confirm nodes aren’t falling behind under query load
- Compare sync lag across different node implementations
- Evaluate infrastructure impact on sync performance
Output Format
The monitor creates async_lag.csv file in the results directory:
timestamp: When the measurement was takenlag (s): Sync lag in seconds (minimum 0)block number: Block number that was queried
Implementation Details
Sync Lag Monitor Implementation
Sync Lag Monitor Implementation
The monitor uses different RPC methods depending on the blockchain:For EVM chains:For Solana:Lag calculation:
Example Results
A well-synced node will show consistently low lag:Monitor Lifecycle
Monitors run for the entire duration of the test:- Test starts: Monitor process launches
- During test: Monitor collects data every 10 seconds
- Test ends: Monitor stops and closes output file
Interpreting Sync Lag Data
Good Sync Performance
- Lag consistently between 0-5 seconds
- Block numbers increment regularly
- No correlation with load test intensity
Potential Issues
Increasing lag over time:- Node may not have sufficient resources
- Network connectivity issues
- Node falling behind due to load
- Correlated with test load changes
- May indicate node struggling under specific query types
- Could suggest need for optimization
- Node stopped syncing
- Connection issues
- Node crashed or stalled
Combining with Load Shapes
Monitors are especially useful with load shapes:- Does sync lag increase during the spike?
- How long does recovery take after the spike ends?
- Is there a correlation between RPS and sync lag?
Example Analysis Workflow
Example Analysis Workflow
-
Run test with monitor:
-
Collect results:
sync_lag.csvfrom monitorstats.csvfrom load test results
-
Analyze correlation:
- Plot sync lag over time
- Overlay with RPS from stats
- Identify when lag increases
-
Draw conclusions:
- Which load levels cause sync issues?
- Does the node recover?
- Are certain operations more impactful?
Error Handling
The monitor includes error handling for common issues:- Node returns invalid JSON
- Block missing expected fields
- Network timeout
If you see repeated errors in monitor logs, check that the node is accessible and responding correctly to RPC calls.
Future Monitors
The monitor system is extensible. Potential future monitors could track:- Resource usage (CPU, memory, disk I/O)
- Peer count and network health
- Database query performance
- Cache hit rates
- Custom metrics specific to node implementations
Technical Details
Monitor Registration
Monitors are registered inchainbench/util/monitor.py:
Monitor Function Signature
Sampling Interval
The sync-lag monitor samples every 10 seconds. This balances:- Sufficient data points for analysis
- Minimal overhead on the node
- Reasonable file sizes
Monitors run independently of the load test and do not interfere with benchmark results.