Does caching actually reduce database load by 90%?
Yes, if you do it right. A typical distributed cache like Redis hits 90-95% of requests, and cutting database reads by that much drops CPU usage 70-90% (AWS). That's not a fantasy—it's the kind of number you see when you put a cache in front of a hot database. The catch: you have to actually use it correctly. Slap a cache on without thinking about invalidation, and you'll serve stale data and wonder why everything broke.
Do I need a load balancer and a CDN?
Short answer: yes, but they do different jobs. A CDN caches static content at the edge—Cloudflare alone has PoPs in 348 cities (Cloudflare). That keeps your images and HTML close to users. A load balancer distributes requests across your origin servers. You need both. The CDN absorbs maybe 70% of requests (AWS), and the load balancer handles the rest, spreading them across your app instances. Without the load balancer, your origin still dies under a spike. Without the CDN, you're paying for bandwidth you don't need.
What's the best cache eviction policy?
Stop using LRU. I know it's the default, but for a cache, you want allkeys-lru at minimum, and allkeys-lfu is often better (Redis, AWS). LRU evicts the least recently used key—fine for a simple workload. LFU evicts the least frequently used, which keeps hot keys around longer. Redis has supported LFU since 4.0 (Redis). But here's the thing: if you don't set an eviction policy, you get noeviction, and Redis just starts returning errors when memory fills (Redis). That's not a cache, that's a time bomb. Pick a policy that evicts, and pick one that matches your access pattern.
Do I need to purge my CDN cache manually?
No, and you shouldn't rely on it. HTTP gives you tools to invalidate caches without a manual purge button. When you send a PUT, POST, or DELETE, caches must invalidate the stored URI (RFC 9111). That's automatic. And you can use ETags or Last-Modified to revalidate with the origin. But sometimes you need a nuke: Cloudflare lets you purge by single-file, instantly removing it from every edge (Cloudflare). Use that for emergencies, not as your normal workflow.
Should I use Redis or Memcached?
Redis. Period. Memcached is multithreaded and uses multiple cores (AWS), but it's a dumb key-value store. Redis gives you lists, sets, hashes, sorted sets, and even pub/sub and Lua scripting (Redis, AWS). You can build a rate limiter with INCR, a leaderboard with sorted sets, and a message queue with streams. That's not just a cache—it's a Swiss Army knife. The only reason to pick Memcached is if you need raw multithreaded throughput and nothing else. But for most systems, Redis's data structures are worth the extra complexity.
Bottom line
Start with a layered cache: browser, CDN, app-level, Redis, and a load balancer in front of your origin. Use Redis with allkeys-lfu or allkeys-lru, let HTTP headers handle invalidation, and stop overthinking it. You'll cut database load by 70-90%, and your users won't feel a thing.
Sources
- AWS - https://aws.amazon.com/caching/
- Cloudflare - https://developers.cloudflare.com/cache/concepts/default-cache-behavior/
- Redis - https://redis.io/docs/latest/develop/reference/eviction/
- RFC 9111 - https://httpwg.org/specs/rfc9111.html
- Nginx - https://nginx.org/en/docs/http/load_balancing.html
Comments (0)
Please sign in to post a comment.
Don't have an account? Create one
No comments yet. Be the first to comment!