System Design (50 Qs)•Part 5: Back-of-the-Envelope Estimation & Production Calculations (44 - 50)
Back-of-the-Envelope: Daily Active Users (DAU) to QPS and Bandwidth.
In Simple Words: How to calculate Queries Per Second (QPS) and network egress during an interview:
typescript
// Back-of-the-envelope calculation helper
export function estimateQps(dailyActiveUsers: number, requestsPerUserPerDay: number) {
const secondsPerDay = 86400; // ~10^5 seconds for easy mental math
const totalDailyRequests = dailyActiveUsers * requestsPerUserPerDay;
const averageQps = Math.round(totalDailyRequests / secondsPerDay);
const peakQps = averageQps * 2; // Peak factor standard 2x-3x
return { averageQps, peakQps };
}
// Example: 100 Million DAU, each making 20 requests/day
// Total Requests = 2 Billion/day
// Average QPS = 2,000,000,000 / 86,400 ≈ 23,150 QPS
// Peak QPS ≈ 46,300 QPS