Estimating daily users to requests per second
35 min · Intermediate
Need help? Ask a tutor on WhatsApp (opens in a new tab)ShopLite's owner says "a million people use the app every day." The servers see requests, not people. How many requests a second is that, and how busy is the busiest minute?
DAU × actions per user ÷ 86,400 = average RPS
RPS (requests per second), also called QPS (queries per second), is how many requests reach the servers each second. DAU, daily active users, is how many different people use the app on a normal day.
Average RPS = DAU × requests per user per day ÷ 86,400. Count API requests, not clicks: one product page may make 3–4 calls. The code compares three very different apps.
Example 1 · Average requests per second from daily users
public class AverageRpsDemo { static double averageRps(long dailyUsers, int requestsPerUser) { return (double) dailyUsers * requestsPerUser / 86_400; }
public static void main(String[] args) { System.out.printf("College fest site: 20,000 users x 10 requests -> %.1f RPS%n", averageRps(20_000, 10)); System.out.printf("ShopLite today: 1,000,000 users x 30 requests -> %.0f RPS%n", averageRps(1_000_000, 30)); System.out.printf("Payments app: 100,000,000 users x 8 requests -> %,.0f RPS%n", averageRps(100_000_000, 8)); }}College fest site: 20,000 users x 10 requests -> 2.3 RPS ShopLite today: 1,000,000 users x 30 requests -> 347 RPS Payments app: 100,000,000 users x 8 requests -> 9,259 RPS
What this code does
- DAU × requests per user ÷ 86,400 gives the average requests per second over a whole day.
- The cast to
doublematters: withlongdivision the fest site would show 2 instead of 2.3, and small numbers would turn into 0. - Three very different apps land in three different powers of ten (2, 300, 9,000 RPS). That gap, not the decimals, decides the design.
For a quick mental version divide by 10⁵ instead of 86,400: the answer is about 14% low, which never changes the order of magnitude. The next two sections add what a daily average hides: the busiest moment and the split between reads and writes.
Peak factor (2–10×) and read/write ratio
The peak factor is how many times busier the busiest moment is than the daily average: about 2–3× on a normal evening, 10× or more on a sale day or when exam results come out.
Design for the peak, not the average. The read/write split then shows what to scale. The code tries three peak factors with about 1 write for every 150 reads.
Example 2 · Peak factor and the read/write split
public class PeakAndRatioDemo { public static void main(String[] args) { double averageRps = 350; int[] peakFactors = {2, 5, 10}; double writeShare = 1.0 / 150; // about 1 write for every 150 reads
for (int factor : peakFactors) { double peak = averageRps * factor; double writes = peak * writeShare; double reads = peak - writes; System.out.printf("peak factor %2dx -> %,6.0f RPS (reads %,6.0f, writes %3.0f)%n", factor, peak, reads, writes); } }}peak factor 2x -> 700 RPS (reads 695, writes 5) peak factor 5x -> 1,750 RPS (reads 1,738, writes 12) peak factor 10x -> 3,500 RPS (reads 3,477, writes 23)
What this code does
- Traffic is not flat: evenings are busier than 4 a.m., and a sale or a festival offer can multiply it. The peak factor (often 2× to 10×) turns the average into the busiest-moment number you must design for.
- Most requests only read (browse, search); few write (place an order). Splitting them matters because reads can be served by caches and replicas, while every write must reach the main database.
The read/write ratio is how many requests only read data for each one that changes it. Shops, news and social apps are read-heavy, often 100:1 or more. The split matters because reads are scaled with caches and replicas, and writes with the primary database.
Worked example: ShopLite with 1 million DAU
Assume 1 million DAU, 30 API requests per user per day, 5% of users ordering with 4 writes each, and a peak factor of 5. Follow the numbers in the code line by line.
Example 3 · Worked example: ShopLite with 1 million DAU
public class ShopLiteRpsWorksheet { public static void main(String[] args) { long dau = 1_000_000; int requestsPerUser = 30; double buyerShare = 0.05; // 5% of daily users place an order int writesPerBuyer = 4; // add to cart x2, place order, payment update int peakFactor = 5; // evening plus sale-day spikes
long requestsPerDay = dau * requestsPerUser; long writesPerDay = (long) (dau * buyerShare) * writesPerBuyer; double avgRps = requestsPerDay / 86_400.0; double avgWriteRps = writesPerDay / 86_400.0;
System.out.println("Assumptions: 1M DAU, 30 requests/user, 5% buy, 4 writes/buyer, peak 5x"); System.out.printf("Requests per day: %,d%n", requestsPerDay); System.out.printf("Writes per day: %,d (reads:writes about %d:1)%n", writesPerDay, (requestsPerDay - writesPerDay) / writesPerDay); System.out.printf("Average RPS: %.0f (quick: 3 x 10^7 / 10^5 = 300)%n", avgRps); System.out.printf("Peak RPS: %,.0f%n", avgRps * peakFactor); System.out.printf("Peak write RPS: %.0f%n", avgWriteRps * peakFactor); }}Assumptions: 1M DAU, 30 requests/user, 5% buy, 4 writes/buyer, peak 5x Requests per day: 30,000,000 Writes per day: 200,000 (reads:writes about 149:1) Average RPS: 347 (quick: 3 x 10^7 / 10^5 = 300) Peak RPS: 1,736 Peak write RPS: 12
What this code does
- Every input is a written assumption with a reason. If the interviewer disagrees with one ("users make 50 requests, not 30"), you change one number, not the method.
- ShopLite needs about 350 requests a second on average and about 1,700 at peak, but only about 12 writes a second at peak: a read-heavy system.
- The quick mental version, 3 × 10⁷ ÷ 10⁵ = 300, is printed next to the exact one to show that it lands in the same range.
By hand, step by step:
- 1,000,000 × 30 = 30,000,000 requests a day.
- 30,000,000 ÷ 86,400 ≈ 347 requests a second on average.
- 347 × 5 ≈ 1,736 requests a second at peak.
- Writes: 50,000 buyers × 4 = 200,000 a day, about 12 a second at peak.
So ShopLite is strongly read-heavy, about 150 reads for every write, which points to caching and read replicas long before sharding.
Order of execution
Order the estimate
Put the steps in the order you would do them.
A single-file Java estimator
An estimator is a small program that turns written assumptions into numbers, so a new what-if is one more input, not a new calculation.
A Scenario record holds the assumptions and an RpsEstimate record holds average, peak, reads and writes. The code runs today, sale day and three years from now side by side.
Example 4 · A reusable estimator for several scenarios
import java.util.List;
record Scenario(String name, long dau, int requestsPerUser, int peakFactor, double writeShare) { }
record RpsEstimate(double average, double peak, double peakReads, double peakWrites) { static RpsEstimate of(Scenario s) { double avg = (double) s.dau() * s.requestsPerUser() / 86_400; double peak = avg * s.peakFactor(); double writes = peak * s.writeShare(); return new RpsEstimate(avg, peak, peak - writes, writes); }}
public class RpsEstimatorDemo { public static void main(String[] args) { List<Scenario> scenarios = List.of( new Scenario("ShopLite today", 1_000_000, 30, 5, 0.007), new Scenario("ShopLite sale day", 1_000_000, 45, 10, 0.02), new Scenario("ShopLite in 3 years", 10_000_000, 30, 5, 0.007));
System.out.printf("%-20s %8s %8s %8s %7s%n", "scenario", "avg", "peak", "reads", "writes"); for (Scenario s : scenarios) { RpsEstimate e = RpsEstimate.of(s); System.out.printf("%-20s %,8.0f %,8.0f %,8.0f %,7.0f%n", s.name(), e.average(), e.peak(), e.peakReads(), e.peakWrites()); } }}scenario avg peak reads writes ShopLite today 347 1,736 1,724 12 ShopLite sale day 521 5,208 5,104 104 ShopLite in 3 years 3,472 17,361 17,240 122
What this code does
- A
Scenariorecord holds the assumptions andRpsEstimate.ofdoes the maths, so a new "what if" is one more line, not a new calculation. - Sale day changes two things at once (more requests per user, a bigger peak factor), and peak writes jump about 9-fold (12 to 104 a second) because far more people buy.
- Growing to 10 million DAU multiplies everything by 10. Seeing 17,000 peak RPS early is the signal that one server and one database will not do.
Running scenarios side by side shows which assumption moves the answer most. Here ten times more users in three years (17,361 peak RPS) matters far more than a sale day (5,208).
Sanity checks: what one server can handle
Headroom is the spare capacity you keep free, for example running servers at most 70% busy, so a spike or a failed server does not cause an outage.
Divide the peak by one server's comfortable load, round up and add a spare. The code does this for today, a sale day and three years from now.
Example 5 · Sanity check: how many app servers is that?
public class ServerCountDemo { static int serversNeeded(double peakRps, double perServerRps, double targetUse) { int busy = (int) Math.ceil(peakRps / (perServerRps * targetUse)); return busy + 1; // one spare for failures and deploys }
public static void main(String[] args) { double perServer = 500; // one ShopLite instance, simple JSON endpoints (measured, not guessed) double targetUse = 0.7; // keep 30% headroom double[] peaks = {1_736, 5_208, 17_361}; String[] names = {"ShopLite today", "sale day", "in 3 years"}; for (int i = 0; i < peaks.length; i++) { System.out.printf("%-15s peak %,6.0f RPS -> %d app servers%n", names[i], peaks[i], serversNeeded(peaks[i], perServer, targetUse)); } }}ShopLite today peak 1,736 RPS -> 6 app servers sale day peak 5,208 RPS -> 16 app servers in 3 years peak 17,361 RPS -> 51 app servers
What this code does
- Compare the estimate with what one server can do. If one ShopLite instance handles about 500 simple requests a second (find this with a load test), run each at most 70% busy and keep one spare.
- Today's peak needs 5 app servers + 1 spare: already more than one box, which is why the earlier modules added a load balancer and stateless servers.
- The same check against the database is even more important: its writes and connections usually run out before the app servers do.
A typical Java app server may handle a few hundred to a few thousand simple requests a second, and one MySQL server a few thousand simple queries a second. These ranges are wide, so measure your own with a load test. If the answer is 1 server, keep it simple; if it is 50, the design needs load balancing, caching and maybe a different data layout.
Your turn: a results-day estimate
A college results site has 200,000 DAU making 10 requests each, and results open at 10 a.m. with a peak factor of 20. Write your own average and peak first, then check.
Predict the output
Estimate, then check
Do the sum yourself, then pick the closest answer.
Round 1 of 2
What is the average RPS?
Next step
Check your understanding
12 quick questions