Prompt
How do I add DDoS protection to my delivery stack?
Latest observation
Adding DDoS protection to a delivery stack usually means protecting DNS, CDN, load balancers, APIs, app servers, and databases with layered controls so a traffic flood doesn’t take down the service or drive up cost.
1) Put a CDN in front of everything possible
Use a CDN/edge network for:
- Static assets
- Cacheable HTML/API responses
- Image/video delivery
- TLS termination at the edge
This absorbs a lot of volumetric traffic before it reaches your origin. Enable:
- Caching
- Origin shielding
- Request collapsing
- Brotli/gzip
- HTTP/2 or HTTP/3
2) Protect DNS
Your DNS is often the first target.
- Use a managed DNS provider with built-in DDoS resistance
- Enable anycast DNS
- Use short, sensible TTLs for failover, but not so short they create excess query load
- Avoid exposing origin IPs in DNS records
3) Hide and lock down origin servers
Make sure attackers can’t bypass the CDN and hit origin directly.
- Put origin behind firewall/security groups
- Allow inbound only from CDN/provider IP ranges
- Use authenticated origin pulls or mTLS if supported
- Don’t expose public IPs for app servers unless necessary
4) Use a DDoS-aware load balancer / reverse proxy
At the edge or entry layer:
- Enable connection limiting
- Enable request rate limiting
- Set sane timeouts
- Limit body sizes
- Protect against slowloris / slow POST attacks
- Prefer L7 protections for HTTP(S) abuse
5) Rate limit and throttle at the application layer
Apply limits per:
- IP
- ASN / region
- API key
- user account
- session
- endpoint
- device fingerprint if appropriate
Examples:
- Login: strict rate limits, CAPTCHAs, MFA challenges
- Search/API: quotas and burst limits
- Expensive endpoints: require auth and tighter limits
6) Cache aggressively
Reduce origin load by caching:
- Public content
- Computed responses
- Metadata
- Feature flags/config where safe
Use:
- Edge caching
- Application caching
- Redis/memcached
- Query/result caching for expensive DB queries
7) Protect databases and internal services
DDoS often becomes an app-layer flood that exhausts backend resources.
- Put databases on private networks only
- Limit connection counts and pool sizes
- Add circuit breakers and timeouts
- Cache read-heavy queries
- Queue background work instead of doing it inline
- Isolate critical services from noisy ones
8) Add bot and abuse detection
A lot of “DDoS” is actually abusive automation.
- Bot management / fingerprinting
- WAF rules for common attack patterns
- Challenge suspicious clients with CAPTCHA / JS challenge
- Block known bad IPs, proxies, TOR if appropriate for your product
9) Use a Web Application Firewall (WAF)
A WAF helps with L7 attacks and malformed requests. Typical rules:
- Block suspicious user agents or headers
- Restrict methods
- Validate content types
- Enforce schema/parameter constraints
- Protect known vulnerable endpoints
10) Plan for traffic spikes operationally
Have a runbook for:
- Turning up rate limits
- Enabling “under attack” mode
- Temporarily disabling expensive features
- Redirecting traffic to maintenance/static pages
- Contacting your CDN/DDoS provider’s emergency support
11) Monitor and alert
You need visibility to react quickly:
- Requests per second
- 4xx/5xx rates
- Origin latency
- Cache hit ratio
- CPU, memory, network, connection counts
- Top source IPs / ASNs / countries
- Request patterns by endpoint
Set alerts for:
- Sudden RPS spikes
- Origin saturation
- Cache hit drop
- Database connection exhaustion
12) Choose managed DDoS protection where possible
For most teams, the easiest path is:
- Managed DNS
- CDN with DDoS protection
- Cloud provider DDoS service
- WAF and bot management
- Managed load balancer
This is usually better than building everything yourself.
A practical baseline architecture
A common secure flow looks like:
Client → CDN/WAF/DDoS edge → Load balancer → App servers → Cache → Database
Hardening points:
- CDN caches static and public dynamic content
- WAF and rate limits at edge
- Origin only accepts CDN traffic
- App rate limits and auth checks
- DB private + pooled + cached
If you’re on a cloud provider
Look for:
- AWS: CloudFront, AWS Shield, WAF, Route 53, ALB/NLB, Security Groups
- GCP: Cloud CDN, Cloud Armor, Cloud DNS, External HTTP(S) Load Balancer
- Azure: Front Door, DDoS Protection, WAF, Azure DNS
Quick wins you can do today
- Put a CDN in front of your site/API
- Lock origin to only accept CDN IPs
- Enable WAF and rate limiting
- Cache public endpoints
- Add strict API quotas
- Monitor RPS, latency, and cache hit ratio
- Test failover and “under attack” mode
If you want, I can help you design a DDoS protection plan for your exact stack, like AWS + Kubernetes, Cloudflare + Nginx, or a bare-metal setup.