If desktop is fast but mobile is slow, Iโd throttle to Slow 4G + low CPU, then check JS bundle size, image optimization, render performance, and third-party scripts. Mobile bottlenecks are usually frontend + network constraints.
Feature flags. Same codebase, but behavior is conditionally enabled per user, % rollout, region, or tier. Enables gradual rollouts, A/B tests, and instant rollback no redeploy needed.
Use replicas for reads with lag monitoring. Critical reads go to primary; non critical can tolerate slight staleness. Combine with caching, connection pools, and fallback to avoid overloading primary.
Your app uses a read-replica DB for performance.
One day, the replica lags behind by 15 seconds.
Users see outdated info.
You switch all reads to the primary and now it crashes from load.
How do you design a safe, resilient read strategy under failure?
Use a write behind cache: Redis INCR for speed + durable queue/AOF for safety, then batch-flush counts to MySQL asynchronously. High throughput, no row lock storm, no data loss.
You are designing a 'Like' button for a viral post.
Expected traffic: 100,000 likes per second.
Database: MySQL.
Problem: Updating a single row (`UPDATE posts SET likes = likes + 1 WHERE id = 1`) locks that row. All 100,000 requests serialize, killing performance.
Solution: You use Redis `INCR`.
But if Redis crashes, you lose the likes.
What 'Write-Behind' or 'Buffering' pattern allows you to capture high-speed writes in memory and persist them to SQL in batches safely?
Design per client rate limits (API key/IP), use token bucket in Redis, enforce tier-based quotas, and dynamically tighten limits under high load. Return 429 with Retry After. Fairness > global throttling.
Youโre running a public API.
Everything is fineโฆ
Until one client sends 5,000 requests in 10 seconds.
Other users start timing out.
Your infra is under attack or just badly throttled.
How do you design dynamic rate limiting for fairness?
If 10k users crash your app, itโs a scalability issue.
Fix with load balancing, horizontal scaling, Redis caching (sessions), DB optimization, queues for heavy tasks, and proper load testing before prod.
Interviewer- Your product works perfectly in development but crashes when 10000 users log in at once.
Same code and Same features.
What would you use to fix this?
Interviewer- Your product works perfectly in development but crashes when 10000 users log in at once.
Same code and Same features.
What would you use to fix this?
You donโt stop users from breaking your system.
You design it assuming they will.
Validate inputs, enforce server side auth, rate limit, apply least privilege, and log everything. Defensive design > trusting users.