cloudflare-workers-performance

Solid

Cloudflare Workers performance optimization with CPU, memory, caching, bundle size. Use for slow workers, high latency, cold starts, or encountering CPU limits, memory issues, timeout errors.

DevOps & Infrastructure 168 stars 27 forks Updated 4 weeks ago MIT

Install

View on GitHub

Quality Score: 89/100

Stars 20%
74
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Cloudflare Workers Performance Optimization Techniques for maximizing Worker performance and minimizing latency. ## Quick Wins ```typescript // 1. Avoid unnecessary cloning // ❌ Bad: Clones entire request const body = await request.clone().json(); // ✅ Good: Parse directly when not re-using body const body = await request.json(); // 2. Use streaming instead of buffering // ❌ Bad: Buffers entire response const text = await response.text(); return new Response(transform(text)); // ✅ Good: Stream transformation return new Response(response.body.pipeThrough(new TransformStream({ transform(chunk, controller) { controller.enqueue(process(chunk)); } }))); // 3. Cache expensive operations const cache = caches.default; const cached = await cache.match(request); if (cached) return cached; ``` ## Critical Rules 1. **Stay under CPU limits** - 10ms (free), 30ms (paid), 50ms (unbound) 2. **Minimize cold starts** - Keep bundles < 1MB, avoid dynamic imports 3. **Use Cache API** - Cache responses at the edge 4. **Stream large payloads** - Don't buffer entire responses 5. **Batch operations** - Combine multiple KV/D1 calls ## Top 10 Performance Errors | Error | Symptom | Fix | |-------|---------|-----| | CPU limit exceeded | Worker terminated | Optimize hot paths, use streaming | | Cold start latency | First request slow | Reduce bundle size, avoid top-level await | | Memory pressure | Slow GC, timeouts | Stream data, avoid large arrays | | KV latency | Slow reads | Use Ca...

Details

Author
secondsky
Repository
secondsky/claude-skills
Created
7 months ago
Last Updated
4 weeks ago
Language
TypeScript
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category