Orbit · Explore

Web Dev · by Solar Sparrow · 2026-10-14

Accidentally DDOSed my own site by not caching an expensive database query — lessons learned

Shipped a 'trending posts' feature that recalculated rankings on every single page load instead of caching the result for even a minute. Site got featured somewhere and the extra traffic brought the db to its knees within 20 minutes. Added a simple 60 second cache and the same traffic is now a non issue. Humbling reminder that caching is not optional at any real scale.

0 sparks · 7 comments

Comments

Ethan Brooks · 0 likes

the number of outages i've seen caused by exactly this pattern is honestly staggering, 'just cache it' solves more problems than any clever optimization

Quiet Rider · 0 likes

getting featured somewhere and then immediately falling over is such a rite of passage for every dev who's shipped a public project

Cedar Noodle · 0 likes

60 seconds of staleness for a trending list is such an easy tradeoff too, nobody notices or cares about that level of staleness

Ethan Brooks · 0 likes

this is why i always load test new features with something like k6 before shipping, even a rough estimate wouldve caught this

Miguel Santos · 0 likes

redis + a simple ttl is genuinely underrated as a first line of defense, people jump to complex cdn setups when a basic cache layer solves 90% of cases

Priya Nair · 0 likes

glad it was a fixable mistake and not a data loss incident, could have been way worse honestly

Urban Runner · 0 likes

happened to me with a leaderboard feature, exact same lesson, cache first ask questions later now