Implement Perplexity load testing, auto-scaling, and capacity planning strategies. Use when running performance tests, configuring horizontal scaling, or planning capacity for Perplexity integrations. Trigger with phrases like "perplexity load test", "perplexity scale", "perplexity performance test", "perplexity capacity", "perplexity k6", "perplexity benchmark".
From perplexity-packnpx claudepluginhub nickloveinvesting/nick-love-plugins --plugin perplexity-packThis skill is limited to using the following tools:
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Details PluginEval's skill quality evaluation: 3 layers (static, LLM judge), 10 dimensions, rubrics, formulas, anti-patterns, badges. Use to interpret scores, improve triggering, calibrate thresholds.
Load testing, scaling strategies, and capacity planning for Perplexity integrations.
// perplexity-load-test.js
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
stages: [
{ duration: '2m', target: 10 }, // Ramp up
{ duration: '5m', target: 10 }, // Steady state
{ duration: '2m', target: 50 }, // Ramp to peak
{ duration: '5m', target: 50 }, // Stress test
{ duration: '2m', target: 0 }, // Ramp down
],
thresholds: {
http_req_duration: ['p(95)<500'], # HTTP 500 Internal Server Error
http_req_failed: ['rate<0.01'],
},
};
export default function () {
const response = http.post(
'https://api.perplexity.com/v1/resource',
JSON.stringify({ test: true }),
{
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${__ENV.PERPLEXITY_API_KEY}`,
},
}
);
check(response, {
'status is 200': (r) => r.status === 200, # HTTP 200 OK
'latency < 500ms': (r) => r.timings.duration < 500, # HTTP 500 Internal Server Error
});
sleep(1);
}
# Install k6
brew install k6 # macOS
# or: sudo apt install k6 # Linux
# Run test
k6 run --env PERPLEXITY_API_KEY=${PERPLEXITY_API_KEY} perplexity-load-test.js
# Run with output to InfluxDB
k6 run --out influxdb=http://localhost:8086/k6 perplexity-load-test.js # 8086 = configured value
# kubernetes HPA
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: perplexity-integration-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: perplexity-integration
minReplicas: 2
maxReplicas: 20
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Pods
pods:
metric:
name: perplexity_queue_depth
target:
type: AverageValue
averageValue: 100
import { Pool } from 'generic-pool';
const perplexityPool = Pool.create({
create: async () => {
return new PerplexityClient({
apiKey: process.env.PERPLEXITY_API_KEY!,
});
},
destroy: async (client) => {
await client.close();
},
max: 20,
min: 5,
idleTimeoutMillis: 30000, # 30000: 30 seconds in ms
});
async function withPerplexityClient<T>(
fn: (client: PerplexityClient) => Promise<T>
): Promise<T> {
const client = await perplexityPool.acquire();
try {
return await fn(client);
} finally {
perplexityPool.release(client);
}
}
| Metric | Warning | Critical |
|---|---|---|
| CPU Utilization | > 70% | > 85% |
| Memory Usage | > 75% | > 90% |
| Request Queue Depth | > 100 | > 500 |
| Error Rate | > 1% | > 5% |
| P95 Latency | > 1000ms | > 3000ms |
interface CapacityEstimate {
currentRPS: number;
maxRPS: number;
headroom: number;
scaleRecommendation: string;
}
function estimatePerplexityCapacity(
metrics: SystemMetrics
): CapacityEstimate {
const currentRPS = metrics.requestsPerSecond;
const avgLatency = metrics.p50Latency;
const cpuUtilization = metrics.cpuPercent;
// Estimate max RPS based on current performance
const maxRPS = currentRPS / (cpuUtilization / 100) * 0.7; // 70% target
const headroom = ((maxRPS - currentRPS) / currentRPS) * 100;
return {
currentRPS,
maxRPS: Math.floor(maxRPS),
headroom: Math.round(headroom),
scaleRecommendation: headroom < 30
? 'Scale up soon'
: headroom < 50
? 'Monitor closely'
: 'Adequate capacity',
};
}
## Perplexity Performance Benchmark
**Date:** YYYY-MM-DD
**Environment:** [staging/production]
**SDK Version:** X.Y.Z
### Test Configuration
- Duration: 10 minutes
- Ramp: 10 → 100 → 10 VUs
- Target endpoint: /v1/resource
### Results
| Metric | Value |
|--------|-------|
| Total Requests | 50,000 |
| Success Rate | 99.9% |
| P50 Latency | 120ms |
| P95 Latency | 350ms |
| P99 Latency | 800ms |
| Max RPS Achieved | 150 |
### Observations
- [Key finding 1]
- [Key finding 2]
### Recommendations
- [Scaling recommendation]
Write k6 test script with appropriate thresholds.
Set up HPA with CPU and custom metrics.
Execute test and collect metrics.
Record results in benchmark template.
| Issue | Cause | Solution |
|---|---|---|
| k6 timeout | Rate limited | Reduce RPS |
| HPA not scaling | Wrong metrics | Verify metric name |
| Connection refused | Pool exhausted | Increase pool size |
| Inconsistent results | Warm-up needed | Add ramp-up phase |
k6 run --vus 10 --duration 30s perplexity-load-test.js
const metrics = await getSystemMetrics();
const capacity = estimatePerplexityCapacity(metrics);
console.log('Headroom:', capacity.headroom + '%');
console.log('Recommendation:', capacity.scaleRecommendation);
set -euo pipefail
kubectl scale deployment perplexity-integration --replicas=5
kubectl get hpa perplexity-integration-hpa
For reliability patterns, see perplexity-reliability-patterns.