On this page
What you need first
This lesson uses ideas from these earlier lessons. Read them first if any idea is new to you.
01Why interviewers ask this
In many interviews in India, the estimate question uses a local event. "On the 1st of the month, many people pay with UPI. How many payments per second?" UPI (Unified Payments Interface) is the way to send money from one bank account to another with a phone app. Another question: "A cricket final is live. How much data leaves your system?" "A train booking window opens at 10 am. What happens in the first minute?"
These questions test one skill. Can you turn a story into three or four numbers, fast, and stay calm? Lessons 14 and 15 gave you the formulas. Here you practise them until they are easy.
A weak answer is a guess such as "crores of requests". A strong answer states each assumption, does the arithmetic aloud, and ends with the one number that decides the design.
At SDE-1 level you should finish a drill when the assumptions are given. At SDE-2 level you should choose the assumptions yourself. At SDE-3 level you should also say which number is the limit, and check your answer against a size you know.
02The idea in plain words
Think about a batter in the nets. The nets are the practice area where a batter faces many balls. The batter does not learn from one ball. The coach throws many balls of the same kind, and after a while the shot is automatic. Estimation is the same. The formulas are short. Speed comes from using the same steps on many different situations.
The five steps of a drill
- Name the load. Say what you count: payments, viewers or booking requests.
- Write the assumptions with numbers. Say the word "assumption" each time. Change lakh and crore into plain numbers at once. 1 lakh = 100,000. 10 lakh = 1 million. 1 crore = 10,000,000 (10 million).
- Choose the shape of the load. There are three shapes, below.
- Do the sums. Work out the load per second on average and at the peak. Then work out the data, the writes and the servers, with the formulas of lessons 14 and 15.
- Check, then name the limit. Compare the answer with a size you know. Then say which part runs out first: requests, data leaving, or writes.
Three shapes of load
Shape 1: a day with a rush. People use the system all day, and a share of the requests arrive in the busiest hours. You use the peak formula of lesson 14:
- peak per second = (share of the day x requests per day) / (hours x 3,600)
Example: UPI on the 1st. On this day many people get their salary. They pay rent, bills and loan payments.
Shape 2: a crowd that stays. Many people are connected at the same time, and each person keeps receiving data for hours. Concurrent users are the people connected at the same moment. A bitrate is the number of bits per second that a video needs. You need two numbers:
- Joins per second: how fast the crowd arrives.
- Data per second: concurrent users x bitrate. Divide bits by 8 to get bytes (lesson 15). 1 Tbps (terabit per second) = 1,000 Gbps.
Example: the IPL final. The IPL (Indian Premier League) is the big Indian cricket league. Millions of people watch the final live on their phones, and many join at the toss.
Shape 3: a burst. A crowd arrives at an exact time and acts at once. Take the requests in the window and divide by the seconds of the window. The peak factor can be in the hundreds, not 3. For a window of one minute:
- peak factor = share of the day's requests in that minute x 1,440 (there are 1,440 minutes in a day)
Example: Tatkal at 10 am. The Indian Railways booking site is run by IRCTC (the Indian Railway Catering and Tourism Corporation). On it, Tatkal is a quick-booking window for next-day train tickets. It opens at 10 am for the air-conditioned classes. The rules differ by class and can change, so here it is only the scenario. Many people try in the same second, for few seats.
Tools for checking
- An anchor. 1 crore requests a day is 10,000,000 / 86,400 = 115.7, so about 116 per second. Then 20 crore a day is about 20 x 116 = 2,320 per second.
- Reads and writes. Count them apart (lesson 14). A burst of looking is different from a burst of saving.
- Bits and bytes. Network speed is in bits. Storage is in bytes. Divide by 8.
- A known size. The photo app in lesson 14 had 14,583 requests per second at its peak. If your answer is 1,000 times that, check your inputs.
Stuck on something? The AI tutor has read this lesson. Ask it with a free account
03Pause and predict
Pause. Guess first.
10 lakh people open a booking site at 10:00:00. Each sends 6 requests in the first 60 seconds. Is the load closer to 1,000, 10,000 or 100,000 requests per second?
Write your guess before you read on. The answer is in the worked example.
04Worked example
We do three drills. All the numbers are assumptions made up to teach with. They are not real traffic.
Drill 1: UPI on the 1st (shape 1)
Assumptions:
- A payment app has 5 crore (50,000,000) users who pay on the 1st. Each makes 4 payments, so 200,000,000 payments (20 crore).
- Half of the payments arrive in the busiest 4 hours.
- Each payment saves 3 records of 1 KB each in the database, the part of the system that keeps the data (lesson 2). A payment takes 20 ms of CPU time.
- Assumption: one database server takes 1,000 writes per second.
- Servers: 4 cores, 70% busy at peak (lesson 15). Copies: 3.
Sums:
- Average = 200,000,000 / 86,400 = 2,315 per second (rounded from 2,314.8). Check with the anchor: 20 x 116 = 2,320.
- Peak = (0.5 x 200,000,000) / (4 x 3,600) = 100,000,000 / 14,400 = 6,944 per second. The peak factor is 0.5 x 24 / 4 = 3.
- Writes at peak = 6,944 x 3 records = 20,833 per second. 20,833 / 1,000 = 20.8 times more than one database server takes.
- Storage for the day = 200,000,000 x 3 x 1 KB = 600,000,000 KB = 600 GB. With 3 copies, 1,800 GB = 1.8 TB.
- One server does 4 x 1,000 / 20 = 200 per second, and 140 at 70%. Servers = 6,944 / 140 = 49.6, so 50, plus 1 spare = 51.
The limit: writes. One database server is not enough by our assumption, and no payment record may be lost.
Drill 2: the IPL final (shape 2)
Assumptions:
- 3 crore (30,000,000) people watch at the same time at the peak.
- Each stream needs a bitrate of 2 megabits per second (Mbps).
- 80% of the viewers join in the 10 minutes before the toss. Each join sends 3 requests. A request takes 8 ms of CPU time.
- A server has a 1 Gbps link, used up to 70%.
Sums:
- Joins = 0.8 x 30,000,000 = 24,000,000 in 600 seconds = 40,000 joins per second.
- Join requests = 40,000 x 3 = 120,000 per second. A server does 4 x 1,000 / 8 = 500, and 350 at 70%. Servers = 120,000 / 350 = 342.9, so 343, plus 1 = 344.
- Data out = 30,000,000 x 2 Mbps = 60,000,000 Mbps = 60,000 Gbps = 60 Tbps. In bytes: 60,000,000 / 8 = 7,500,000 MB per second = 7.5 TB per second.
- Check with one viewer: 2 Mbps / 8 = 0.25 MB per second, and x 3,600 = 900 MB in one hour. All viewers: 30,000,000 x 900 MB = 27,000,000 GB = 27 PB in one hour. Also 7.5 TB x 3,600 = 27,000 TB. The two agree.
- Servers, if only their links carry the data: 60,000 Gbps / (1 Gbps x 0.7) = 85,714.3, so 85,715.
The limit: the data leaving. 85,715 / 344 = 249, so the data needs about 250 times more machines than the requests. The request count is the wrong number to lead with.
Drill 3: Tatkal at 10 am (shape 3)
Assumptions:
- A normal day on the site has 5 crore (50,000,000) requests.
- 10 lakh (1,000,000) users arrive at 10:00:00. Each sends 6 requests in the first 60 seconds.
- 50,000 Tatkal seats open for all trains together. Each booking is one write.
- Servers as in drill 2: 350 requests per second each at 70%. Rent: Rs 10 per server-hour (lesson 13, an assumption).
Sums:
- Requests in the minute = 1,000,000 x 6 = 6,000,000. Per second = 6,000,000 / 60 = 100,000. This answers the predict box: about 100,000 per second.
- Normal average = 50,000,000 / 86,400 = 579 per second (rounded from 578.7).
- The share of the day in this minute = 6,000,000 / 50,000,000 = 12%. Peak factor = 0.12 x 1,440 = 172.8. Check: 100,000 / 578.7 = 172.8.
- At most 50,000 users get a seat, which is 50,000 / 1,000,000 = 5%. Assume the best case for writes: every seat sells inside this minute. Then writes are 50,000 / 60 = 833 per second, and the other requests are reads: 6,000,000 - 50,000 = 5,950,000. The ratio is 5,950,000 : 50,000 = 119 : 1.
- Servers = 100,000 / 350 = 285.7, so 286, plus 1 = 287.
- Cost for one hour = 287 x Rs 10 = Rs 2,870. Cost for a whole year = 287 x 8,760 x Rs 10 = Rs 25,141,200 (about Rs 2.5 crore). The year costs 8,760 times more than the hour.
The limit: the first minute. The average of 579 per second is 173 times too small. The servers must already be running at 10:00:00, because one minute is too short to add them.
05Trade-offs
- A quick drill solves guessing: you reach a number with steps that anyone can check. It costs accuracy. Every input is an assumption, so the answer can be wrong by 2 times or more. I would redo it when the interviewer gives a real number.
- Sizing for the peak solves failure in the busiest minute. It costs money for machines that sit unused. In drill 3, the peak needs 287 servers and the average needs 579 / 350 = 1.7, so 2. Renting for one hour keeps the cost small (Rs 2,870). I would size for less than the peak only if the business accepts slow service in that minute, and I would say so aloud.
- Leading with one number solves a long, confusing answer. It costs the risk of choosing the wrong number. In drill 2 the request count (344 servers) hides the data (85,715). I would lead with the number that is largest compared with what one machine can do.
06Common misconceptions
"The average per second is enough." In drill 3 the average is 579 per second, but the first minute is 100,000. A system sized for the average fails in the first minute, which is the minute everyone remembers.
"Every big event is about requests per second." The IPL drill needs only 344 servers for its requests but 85,715 for its data. Check data, writes and requests separately, and find the one that is largest compared with one machine.
"1 crore is 1 million." 1 crore is 10,000,000, which is 10 million. If you use 1 million for 1 crore in drill 1, your payments per second are 10 times too small: 231 instead of 2,315. Change lakh and crore to plain numbers first.
07How to say it in the interview
Say it like this
On the 1st, 20 crore payments a day is 6,944 per second at peak, and 3 records each makes about 20,800 writes per second. That is 20 times what I assume one database server takes, so writes are the number I design around.
08Check your understanding
- Name the five steps of a drill and the three shapes of load. How many seconds are in a day, and how many minutes?
- A results website opens at 10:00:00. 20 lakh students each send 4 requests in the first 30 seconds. A server has 4 cores and uses 10 ms of CPU per request. We plan for 70% busy and one spare. (a) How many requests per second? (b) How many servers?
- A friend says: "The IPL final has 40,000 joins per second, so 344 servers is enough." What did your friend miss? Which number do you show?
09Answers
Show the answers
- The steps: name the load; write the assumptions with numbers; choose the shape; do the sums; check and name the limit. The shapes: a day with a rush, a crowd that stays, a burst. A day has 86,400 seconds and 1,440 minutes.
- (a) 20 lakh = 2,000,000. Requests = 2,000,000 x 4 = 8,000,000. Per second = 8,000,000 / 30 = 266,667. (b) One server does 4 x 1,000 / 10 = 400, and 400 x 0.7 = 280 at 70%. Servers = 266,667 / 280 = 952.4, so 953, plus 1 spare = 954.
- The friend counted the requests but not the data. Each of the 3 crore viewers needs 2 Mbps: 30,000,000 x 2 = 60,000,000 Mbps = 60,000 Gbps = 60 Tbps. With a 1 Gbps link used up to 70%, that is 60,000 / 0.7 = 85,715 servers for the links. The data leaving, not the requests, is the limit.
10Sources
- Every user, request, size, bitrate, seat, speed and price number in this lesson is an assumption made for teaching. None is a real traffic figure or price for UPI, the IPL or IRCTC. Real figures change often, so look up a current official number before you quote one.
- The Rs 10 per server-hour price comes from lesson 13. The 4-core server, the 70% target and the 3 copies come from lesson 15. The 1,000 writes per second of one database server is new here.
- Seconds, minutes, bits and bytes, and all arithmetic, are calculations from the formulas in the lesson.
Try it now, no sign-up
- Play Level 1: one server and 100 users. Free, no sign-up.
- Read today’s Drill: one real situation, answered in about 7 minutes.
More practice, in the app (free account)
Related lessons and practice
Ask the AI tutor about this lesson
The tutor has read this lesson. Ask in your own words, any time. Free account, 20 questions a day.
Reading never needs an account. The account is for the tutor, the quiz, your notes and your progress.