Parameters
Number of samples to return (default: 720)
Response
Array of performance sample objectsNumber of slots in the sample
Number of transactions in the sample
Number of non-vote transactions
Code Examples
Basic Request
curl https://rpc.orbitflare.com -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getRecentPerformanceSamples",
"params": []
}'
Request with Limit
curl https://rpc.orbitflare.com -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getRecentPerformanceSamples",
"params": [
100
]
}'
Using web3.js
import { Connection } from '@solana/web3.js';
const connection = new Connection('https://rpc.orbitflare.com');
// Get recent performance samples
const samples = await connection.getRecentPerformanceSamples();
console.log('Performance samples:', samples);
// Calculate average TPS
function calculateAverageTPS(samples: any[]): number {
const totalTransactions = samples.reduce(
(sum, sample) => sum + sample.numTransactions,
0
);
const totalSeconds = samples.reduce(
(sum, sample) => sum + sample.samplePeriodSecs,
0
);
return totalTransactions / totalSeconds;
}
Notes
- Returns recent performance samples from the network
- Each sample covers a period of time (typically 60 seconds)
- Samples include transaction counts and slot information
- The response is immediate as it reads from the current state
- The default limit is 720 samples (approximately 12 hours)
Best Practices
- Use appropriate limit based on your analysis needs
- Cache results when appropriate to reduce RPC load
- Monitor for significant changes in performance
- Consider using websocket subscription for real-time updates
- Handle network errors and retry when appropriate
Common Errors
| Code | Message | Solution |
| -32601 | Method not found | Verify you’re connected to a Solana RPC node |
| -32602 | Invalid params | Check limit parameter |
| -32007 | Performance samples unavailable | Node may be bootstrapping or syncing |
Use Cases
-
Performance Analysis
interface PerformanceMetrics {
averageTPS: number;
peakTPS: number;
totalTransactions: number;
totalSlots: number;
metadata: {
timestamp: number;
sampleCount: number;
};
}
async function analyzePerformance(
limit: number = 720
): Promise<PerformanceMetrics> {
const samples = await connection.getRecentPerformanceSamples(limit);
const totalTransactions = samples.reduce(
(sum, sample) => sum + sample.numTransactions,
0
);
const totalSeconds = samples.reduce(
(sum, sample) => sum + sample.samplePeriodSecs,
0
);
const peakTPS = Math.max(
...samples.map(sample => sample.numTransactions / sample.samplePeriodSecs)
);
return {
averageTPS: totalTransactions / totalSeconds,
peakTPS,
totalTransactions,
totalSlots: samples.reduce((sum, sample) => sum + sample.numSlots, 0),
metadata: {
timestamp: Date.now(),
sampleCount: samples.length
}
};
}
-
Performance Monitoring
interface PerformanceAlert {
type: 'high_tps' | 'low_tps' | 'anomaly';
currentTPS: number;
threshold: number;
metadata: {
timestamp: number;
slot: number;
};
}
class PerformanceMonitor {
private previousTPS: number | null = null;
private readonly threshold = 0.2; // 20% change threshold
async monitorPerformance(
interval: number = 60000
): Promise<PerformanceAlert | null> {
const samples = await connection.getRecentPerformanceSamples(1);
const currentSample = samples[0];
const currentTPS = currentSample.numTransactions / currentSample.samplePeriodSecs;
if (this.previousTPS === null) {
this.previousTPS = currentTPS;
return null;
}
const change = Math.abs(currentTPS - this.previousTPS) / this.previousTPS;
if (change > this.threshold) {
const alert: PerformanceAlert = {
type: change > 0 ? 'high_tps' : 'low_tps',
currentTPS,
threshold: this.threshold,
metadata: {
timestamp: Date.now(),
slot: currentSample.slot
}
};
this.previousTPS = currentTPS;
return alert;
}
return null;
}
}
-
Performance History
interface PerformanceHistory {
samples: Array<{
slot: number;
tps: number;
nonVoteTPS: number;
timestamp: number;
}>;
summary: {
averageTPS: number;
peakTPS: number;
totalTransactions: number;
};
metadata: {
startTime: number;
endTime: number;
sampleCount: number;
};
}
async function getPerformanceHistory(
limit: number = 720
): Promise<PerformanceHistory> {
const samples = await connection.getRecentPerformanceSamples(limit);
const processedSamples = samples.map(sample => ({
slot: sample.slot,
tps: sample.numTransactions / sample.samplePeriodSecs,
nonVoteTPS: sample.numNonVoteTransaction / sample.samplePeriodSecs,
timestamp: Date.now() - (samples.length - samples.indexOf(sample)) * sample.samplePeriodSecs * 1000
}));
const totalTransactions = samples.reduce(
(sum, sample) => sum + sample.numTransactions,
0
);
const totalSeconds = samples.reduce(
(sum, sample) => sum + sample.samplePeriodSecs,
0
);
return {
samples: processedSamples,
summary: {
averageTPS: totalTransactions / totalSeconds,
peakTPS: Math.max(...processedSamples.map(sample => sample.tps)),
totalTransactions
},
metadata: {
startTime: processedSamples[0].timestamp,
endTime: processedSamples[processedSamples.length - 1].timestamp,
sampleCount: samples.length
}
};
}