Overview
Twilio enforces per-resource rate limits. At scale, 429 errors are expected behavior — not bugs. This skill teaches the patterns that prevent production failures: exponential backoff, throughput management, and resilient callback handling.
429 concurrency errors are not well documented — implement exponential backoff with ±10% jitter.
Prerequisites
- A working Twilio integration (any product)
- Understanding of your expected volume (messages/sec, calls/sec)
- StatusCallback URLs configured — see
twilio-messaging-services,twilio-sms-send-message
Key Patterns
1. Exponential Backoff with Jitter
When you receive a 429 (Too Many Requests), wait and retry. Naive fixed-interval retry creates thundering herds. Use exponential backoff with randomized jitter.
Python
Node.js
Parameters:
- Initial delay: 100ms
- Multiplier: 2x per attempt
- Jitter: ±10% of base delay (randomized)
- Max delay: 30 seconds
- Max retries: 5 (covers up to ~3.2 second base delay)
2. Per-Number Throughput Limits
These limits are not prominently documented:
Throughput opacity: Sending velocity and queue depth are opaque — there is no dashboard showing messages per second. Use Messaging Services to multiply throughput by pooling numbers. A pool of 10 long codes = ~10 SMS/sec.
3. Bulk Send Pattern
For sending to large lists, use a rate-limited dispatch loop:
Python
Key: Set rate_per_second based on your number pool size, not your desired speed. Sending faster than your pool supports just generates 429s.
Compliance: Before bulk sending, verify recipient consent (opt-in records), respect quiet hours, and implement maximum batch size limits. Monitor for anomalous send patterns that could indicate abuse.
4. StatusCallback Resilience
At scale, StatusCallbacks create their own load problem.
The math: 50 concurrent calls × 6 status events per call = 300 webhook invocations per second. Twilio Functions allow 30 concurrent executions per service.
Thin-receiver pattern — receive, queue, respond immediately:
Node.js (Express)
Python (Flask + Celery)
Idempotency key: Use {CallSid}-{CallStatus} as a composite key. Twilio retries on timeout, which can cause duplicate callbacks. Deduplicate before processing.
5. Fallback Chains
When delivery on one channel fails, escalate to the next:
Python
6. Voice Concurrency Limits
For outbound campaigns, request CPS increase before launch — not during.
7. Webhook Timeout Handling
Twilio expects a response within 15 seconds for voice webhooks and 15 seconds for messaging webhooks. If your endpoint doesn't respond:
- Voice: Twilio hangs up or falls back to
voiceFallbackUrl - Messaging: Twilio retries the callback
Always configure fallback URLs:
Monitoring Checklist
Set up these alerts before going to production:
Twilio's built-in alerting systems are under-used — end-users often discover issues before developers do. Configure StatusCallbacks + Event Streams for delivery failure alerts on every integration.
CANNOT
- Cannot avoid 429 errors on any Twilio API — Backoff patterns apply to all APIs (Messaging, Voice, Verify, Lookup)
- Cannot increase per-number throughput — Add more numbers via Messaging Services instead
- Cannot configure StatusCallback retry behavior — Twilio retries on timeout automatically; not configurable
- Cannot exceed Twilio Functions limits — 30 concurrent executions/service, 10-second timeout, 256 MB memory
- Cannot use a native Twilio rate limiting API — You must implement rate limiting in your application
Next Steps
- Messaging at scale:
twilio-messaging-services - Monitor delivery:
twilio-sms-send-message(StatusCallbacks) - Debug failures:
twilio-debugging-observability - Compliance for bulk sends:
twilio-compliance-traffic