getRecentPerformanceSamples
Explore getRecentPerformanceSamples: Use Cases, Code Examples, Parameters, Response Format, and Pro Tips
The getRecentPerformanceSamples
RPC method delivers a time‑series snapshot of Solana’s network performance, sampling roughly every 60 seconds. Each sample records the number of transactions processed and slots produced during that interval—critical metrics for assessing throughput and network health.
Key Use Cases
Network Health Monitoring Track transaction rates and slot production over time to detect congestion or slowdowns.
Performance Analysis Examine historical samples to identify trends, peak load periods, and capacity limits.
Dashboarding & Alerts Display TPS (transactions per second) and slots‑per‑minute on monitoring dashboards or trigger alerts when performance dips.
Capacity Planning Use sampled data to forecast resource needs for application scaling and infrastructure provisioning.
Request Parameters
limit
(optional, usize): Number of most recent samples to return (max 720, ~12 hours of data). Omittinglimit
returns the provider’s default sample count.
Response Structure
An array of performance sample objects in reverse chronological order:
slot
u64
Slot at which this sample was recorded
numTransactions
u64
Total transactions (including votes) in the period
numSlots
u64
Slots produced during the sample interval
samplePeriodSecs
u16
Actual duration of the sample (usually ~60 seconds)
numNonVoteTransactions
u64
Transactions excluding consensus votes
Get the Last 5 Performance Samples
{
"jsonrpc": "2.0",
"id": 1,
"method": "getRecentPerformanceSamples",
"params": [5]
}
Get Default Number of Performance Samples
{
"jsonrpc": "2.0",
"id": 1,
"method": "getRecentPerformanceSamples"
}
Code Examples
const fetch = require('node-fetch');
async function getRecentPerformanceSamples(rpcUrl) {
try {
const response = await fetch(rpcUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'getRecentPerformanceSamples'
}),
});
const data = await response.json();
// Print the exact full response
console.log('Full RPC Response:');
console.log(JSON.stringify(data, null, 2));
return data;
} catch (error) {
console.error('Error getting health:', error.message);
return null;
}
}
// Example usage
const RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key';
getRecentPerformanceSamples(RPC_URL);
Example Response
{
"jsonrpc": "2.0",
"result": [
{
"slot": 348125,
"numTransactions": 126,
"numSlots": 126,
"samplePeriodSecs": 60,
"numNonVoteTransactions": 1
},
{
"slot": 347999,
"numTransactions": 126,
"numSlots": 126,
"samplePeriodSecs": 60,
"numNonVoteTransactions": 1
}
],
"id": 1
}
Developer Tips
Interval Variance: Samples aim for ~60‑second intervals; check
samplePeriodSecs
to see the exact duration.Data Retention: Up to 720 samples (~12 hours). For longer-term analysis, combine with external logging.
Vote vs. User Activity: Use
numNonVoteTransactions
to focus on user‑driven load apart from voting traffic.Node Differences: Slight variations may occur between RPC nodes based on synchronization and local timing.
Last updated