Cost Reduction Strategies
Cost Reduction Strategies
Step 1: Request Sampling
function shouldSample(samplingRate = 0.1): boolean {
return Math.random() < samplingRate;
}
// Use for non-critical telemetry
if (shouldSample(0.1)) { // 10% sample
await vercelClient.trackEvent(event);
}Step 2: Batching Requests
// Instead of N individual calls
await Promise.all(ids.map(id => vercelClient.get(id)));
// Use batch endpoint (1 call)
await vercelClient.batchGet(ids);Step 3: Caching (from P16)
- Cache frequently accessed data
- Use cache invalidation webhooks
- Set appropriate TTLs
Step 4: Compression
const client = new VercelClient({
compression: true, // Enable gzip
});