Skill站外收录 @skilllib/skill-2014279403063160835
windsurf-load-scale
执行 Windsurf 集成的负载测试与性能评估,动态调整服务实例规模以应对流量变化,基于系统指标进行容量预测和资源规划,确保高并发下的稳定性与响应效率。
商业与营销 AI 技能
Skills.MD
# Windsurf Load & Scale
## Overview
Load testing, scaling strategies, and capacity planning for Windsurf integrations.
## Prerequisites
- k6 load testing tool installed
- Kubernetes cluster with HPA configured
- Prometheus for metrics collection
- Test environment API keys
## Load Testing with k6
### Basic Load Test
```javascript
// windsurf-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_req_failed: ['rate<0.01'],
},
};
export default function () {
const response = http.post(
'https://api.windsurf.com/v1/resource',
JSON.stringify({ test: true }),
{
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${__ENV.WINDSURF_API_KEY}`,
},
}
);
check(response, {
'status is 200': (r) => r.status === 200,
'latency < 500ms': (r) => r.timings.duration < 500,
});
sleep(1);
}
```
### Run Load Test
```bash
# Install k6
brew install k6 # macOS
# or: sudo apt install k6 # Linux
# Run test
k6 run --env WINDSURF_API_KEY=${WINDSURF_API_KEY} windsurf-load-test.js
# Run with output to InfluxDB
k6 run --out influxdb=http://localhost:8086/k6 windsurf-load-test.js
```
## Scaling Patterns
### Horizontal Scaling
```yaml
# kubernetes HPA
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: windsurf-integration-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: windsurf-integration
minReplicas: 2
maxReplicas: 20
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Pods
pods:
metric:
name: windsurf_queue_depth
target:
type: AverageValue
averageValue: 100
```
### Connection Pooling
```typescript
import { Pool } from 'generic-pool';
const windsurfPool = Pool.create({
create: async () => {
return new WindsurfClient({
apiKey: process.env.WINDSURF_API_KEY!,
});
},
destroy: async (client) => {
await client.close();
},
max: 20,
min: 5,
idleTimeoutMillis: 30000,
});
async function withWindsurfClient<T>(
fn: (client: WindsurfClient) => Promise<T>
): Promise<T> {
const client = await windsurfPool.acquire();
try {
return await fn(client);
} finally {
windsurfPool.release(client);
}
}
```
## Capacity Planning
### Metrics to Monitor
| Metric | Warning | Critical |
|--------|---------|----------|
| CPU Utilization | > 70% | > 85% |
| Memory Usage | > 75% | > 90% |
| Request Queue Depth | > 100 | > 500 |
| Error Rate | > 1% | > 5% |
| P95 Latency | > 1000ms | > 3000ms |
### Capacity Calculation
```typescript
interface CapacityEstimate {
currentRPS: number;
maxRPS: number;
headroom: number;
scaleRecommendation: string;
}
function estimateWindsurfCapacity(
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',
};
}
```
## Benchmark Results Template
```markdown
## Windsurf 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]
```
## Instructions
### Step 1: Create Load Test Script
Write k6 test script with appropriate thresholds.
### Step 2: Configure Auto-Scaling
Set up HPA with CPU and custom metrics.
### Step 3: Run Load Test
Execute test and collect metrics.
### Step 4: Analyze and Document
Record results in benchmark template.
## Output
- Load test script created
- HPA configured
- Benchmark results documented
- Capacity recommendations defined
## Error Handling
| 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 |
## Examples
### Quick k6 Test
```bash
k6 run --vus 10 --duration 30s windsurf-load-test.js
```
### Check Current Capacity
```typescript
const metrics = await getSystemMetrics();
const capacity = estimateWindsurfCapacity(metrics);
console.log('Headroom:', capacity.headroom + '%');
console.log('Recommendation:', capacity.scaleRecommendation);
```
### Scale HPA Manually
```bash
kubectl scale deployment windsurf-integration --replicas=5
kubectl get hpa windsurf-integration-hpa
```
## Resources
- [k6 Documentation](https://k6.io/docs/)
- [Kubernetes HPA](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/)
- [Windsurf Rate Limits](https://docs.windsurf.com/rate-limits)
## Next Steps
For reliability patterns, see `windsurf-reliability-patterns`.
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「windsurf-load-scale」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次