← All guides
PERFORMANCE · 504 Gateway Timeout
Server Overload: When Traffic Spikes Take a Site Down
$ curl -I https://example.com
HTTP/1.1 504 Gateway Timeout
Sometimes a site isn't misconfigured at all — it's just getting more traffic than the server can handle at once, and requests start timing out or failing under the load.
What this tends to look like
- The site loads slowly before eventually failing, rather than failing immediately
- Errors like 502 Bad Gateway or 504 Gateway Timeout, especially from a reverse proxy in front of the actual application
- The timing lines up with a traffic spike — a link going viral, a marketing push, or a bot crawl
How to confirm it
If you have access to server monitoring, check CPU usage, memory usage, and open connection counts around the time the issue started. A sudden climb to the ceiling on any of these, correlated with a traffic increase in your analytics, is a strong signal.
What helps, from quick fixes to longer-term ones
Immediate relief
- Restart the application process if it's become unresponsive rather than genuinely out of capacity
- Temporarily scale up server resources if your host allows it on demand
- Enable or check caching so repeat requests for the same page don't each hit the application server
Structural fixes
- Put a CDN in front of static content so images, CSS, and unchanging pages are served without touching your origin server at all.
- Add caching at the application or page level for content that doesn't change on every request.
- Move to auto-scaling infrastructure if traffic spikes are a recurring pattern rather than a one-off.
- Optimize slow database queries or endpoints that are disproportionately expensive per request, since those are often the real bottleneck rather than raw traffic volume.
Quick checklist
- Check CPU, memory, and connection counts around the failure window
- Correlate the timing against a traffic spike in analytics
- Add or verify caching and a CDN for static content
- Consider auto-scaling if spikes recur