Cloudflare Limits
Cloudflare Workers has certain limits you should be aware of when building your Cloudwerk application.
Workers Limits
Section titled “Workers Limits”Request Limits
Section titled “Request Limits”| Limit | Free | Paid |
|---|---|---|
| Requests per day | 100,000 | Unlimited |
| Request body size | 100 MB | 100 MB |
| Response body size | No limit (streaming) | No limit (streaming) |
Execution Limits
Section titled “Execution Limits”| Limit | Free | Paid |
|---|---|---|
| CPU time per request | 10 ms | 30 s (Unbound) |
| Duration (wall clock) | No explicit limit | No explicit limit |
| Memory per request | 128 MB | 128 MB |
| Environment variables | 64 | 64 |
| Environment variable size | 5 KB each | 5 KB each |
Script Limits
Section titled “Script Limits”| Limit | Value |
|---|---|
| Script size (compressed) | 10 MB |
| Script size (uncompressed) | 30 MB |
| Number of scripts | Unlimited |
D1 Database Limits
Section titled “D1 Database Limits”Database Limits
Section titled “Database Limits”| Limit | Value |
|---|---|
| Maximum databases | 50,000 per account |
| Maximum storage per database | 10 GB |
| Maximum rows read per query | 1,000,000 |
| Maximum rows written per query | 1,000 |
| Maximum query duration | 30 seconds |
Query Limits
Section titled “Query Limits”| Limit | Value |
|---|---|
| Maximum SQL statement size | 100 KB |
| Maximum bound parameters | 100 |
| Maximum columns per table | 2,000 |
| Maximum row size | 1 MB |
Performance
Section titled “Performance”| Metric | Value |
|---|---|
| Reads per second | ~10,000 |
| Writes per second | ~1,000 |
| Typical read latency | 5-50 ms |
| Typical write latency | 50-200 ms |
KV Limits
Section titled “KV Limits”Storage Limits
Section titled “Storage Limits”| Limit | Free | Paid |
|---|---|---|
| Maximum namespaces | 100 | 100 |
| Maximum keys per namespace | Unlimited | Unlimited |
| Maximum value size | 25 MB | 25 MB |
| Maximum key size | 512 bytes | 512 bytes |
| Maximum metadata size | 1 KB | 1 KB |
Operation Limits
Section titled “Operation Limits”| Limit | Free | Paid |
|---|---|---|
| Reads per day | 100,000 | Unlimited |
| Writes per day | 1,000 | Unlimited |
| Deletes per day | 1,000 | Unlimited |
| Lists per day | 1,000 | Unlimited |
Performance
Section titled “Performance”| Metric | Value |
|---|---|
| Read latency | < 60 ms (95th percentile) |
| Write propagation | Up to 60 seconds (eventually consistent) |
R2 Limits
Section titled “R2 Limits”Storage Limits
Section titled “Storage Limits”| Limit | Value |
|---|---|
| Maximum object size | 5 TB |
| Maximum bucket count | 1,000 per account |
| Maximum objects per bucket | Unlimited |
Request Limits
Section titled “Request Limits”| Limit | Free | Paid |
|---|---|---|
| Class A operations (writes) | 1,000,000/month | $4.50 per million |
| Class B operations (reads) | 10,000,000/month | $0.36 per million |
| Data transfer (egress) | Free | Free |
Performance
Section titled “Performance”| Metric | Value |
|---|---|
| Put latency | < 100 ms |
| Get latency | < 50 ms |
| Multipart upload parts | 10,000 max |
Queues Limits
Section titled “Queues Limits”Queue Limits
Section titled “Queue Limits”| Limit | Value |
|---|---|
| Maximum queues per account | 100 |
| Maximum message size | 128 KB |
| Maximum batch size | 100 messages |
| Maximum in-flight messages | 10,000 |
Rate Limits
Section titled “Rate Limits”| Limit | Value |
|---|---|
| Messages per second (send) | 400 per queue |
| Messages per second (receive) | 5,000 per consumer |
Retention
Section titled “Retention”| Limit | Value |
|---|---|
| Message retention | 4 days |
| Retry attempts | Configurable (default: 3) |
| Maximum delay | 12 hours |
Durable Objects Limits
Section titled “Durable Objects Limits”Storage Limits
Section titled “Storage Limits”| Limit | Value |
|---|---|
| Storage per object | 10 GB |
| Key size | 2 KB |
| Value size | 128 KB |
| Total storage per account | No explicit limit |
Performance
Section titled “Performance”| Metric | Value |
|---|---|
| Requests per object | ~500/second |
| Alarm precision | 1 second |
WebSocket Limits
Section titled “WebSocket Limits”| Limit | Value |
|---|---|
| Max connections per object | 32,768 (hibernatable) |
| Max message size | 1 MB |
Cron Triggers Limits
Section titled “Cron Triggers Limits”| Limit | Value |
|---|---|
| Triggers per Worker | 3 |
| Minimum interval | 1 minute |
| Execution time (Free) | 30 seconds |
| Execution time (Paid) | 15 minutes |
Bindings Limits
Section titled “Bindings Limits”| Limit | Value |
|---|---|
| Total bindings per Worker | 200 |
| Service bindings | 20 |
Subrequest Limits
Section titled “Subrequest Limits”| Limit | Free | Paid |
|---|---|---|
| Subrequests per request | 50 | 1,000 |
| Recursive subrequests | 16 | 16 |
Best Practices
Section titled “Best Practices”Optimize for Limits
Section titled “Optimize for Limits”- CPU Time: Use streaming for large responses, offload heavy work to Queues
- Database: Use indexes, paginate results, batch writes
- KV: Cache frequently accessed data, use appropriate TTLs
- R2: Use multipart uploads for large files
- Queues: Use batching for high-volume message sending
Monitor Usage
Section titled “Monitor Usage”// Track request timingexport const middleware: Middleware = async (request, next, context) => { const start = Date.now(); const response = await next(request); const duration = Date.now() - start;
// Log for monitoring console.log(`Request took ${duration}ms`);
// Alert if approaching limits if (duration > 8000) { // 8s warning for 10ms limit console.warn('Request approaching CPU limit'); }
return response;};Handle Errors Gracefully
Section titled “Handle Errors Gracefully”export async function loader({ context }: LoaderArgs) { try { const data = await context.db.selectFrom('items').execute(); return { data }; } catch (error) { if (error.message.includes('D1_ERROR')) { // Handle D1-specific errors console.error('Database error:', error); return { data: [], error: 'Database temporarily unavailable' }; } throw error; }}Pricing Reference
Section titled “Pricing Reference”For current pricing, see the Cloudflare Workers Pricing page.
| Service | Free Tier | Paid (Workers Paid) |
|---|---|---|
| Workers | 100K requests/day | $5/month + $0.50/million |
| D1 | 5M rows read/day, 100K writes/day | $0.001/million rows read |
| KV | 100K reads/day, 1K writes/day | $0.50/million reads |
| R2 | 10M Class B, 1M Class A/month | $0.36/million reads |
| Queues | Included | $0.40/million messages |
| Durable Objects | Included | $0.15/million requests |
Next Steps
Section titled “Next Steps”- Configuration - Optimize your config
- Deployment Guide - Deploy efficiently
- Database Guide - Optimize D1 queries