Riya's laptop meets five years of data
Riya's Python script read the canteen's 15 lakh orders in two seconds. Impressed, the university asks for the same report for all 400 college canteens in the state, for the last five years, including app click logs. The data comes to about 2 TB. Riya's laptop has a 512 GB SSD, 8 GB of RAM and 4 CPU cores.
Sir, my laptop gave up. First the disk was full, then I tried an external disk and Python said MemoryError.
Every computer has four hard limits, Riya: how much it can store, how much it can hold in memory, how fast it can compute, and how fast it can move data in and out. Your 2 TB hit all of them.
So I just need a bigger computer?
That's called scaling up. It works for a while. But the biggest servers cost crores, still have a ceiling, and if that one machine fails, everything stops.
Then what do companies do?
They scale out: many ordinary machines working together. Today we'll calculate, with real numbers, exactly where one computer runs out of road.
At TiffinGo they told me the monthly report used to run on one server and now runs on a “cluster”. Was the old server just too slow?
Maybe slow, maybe out of memory, maybe the disk couldn't read fast enough. Kabir, the skill is finding which wall you hit, because every fix just moves the bottleneck somewhere else. You'll watch that happen on a real report today.
Why isn't one computer enough?
A single computer is limited by its storage capacity, main memory (RAM), processing power (CPU) and I/O bandwidth (disk and network throughput), and it is a single point of failure. Vertical scaling (scaling up) adds resources to one machine, but cost rises steeply and there is a hard upper limit. Big data systems therefore use horizontal scaling (scaling out): data and work are spread across a cluster of many commodity machines that operate in parallel.
One computer has a limited disk, limited memory, limited speed, and it can break. You can buy a bigger one, but it gets very expensive and you'll outgrow it again. So big data uses many normal computers together, each doing a small part of the job at the same time.
Words you'll meet in this lesson
Typical numbers to remember (2026, approximate)
| Hard disk (HDD) read speed | about 150–250 MB per second |
|---|---|
| SATA SSD read speed | about 500 MB per second |
| NVMe SSD read speed | about 3,000–7,000 MB per second |
| Laptop RAM | 8–32 GB |
| Large single server | a few TB of RAM, around 100–200 cores, tens of disks |
| Office / data-centre network | 1 Gbps ≈ 125 MB/s; 10 Gbps ≈ 1.25 GB/s; 100 Gbps in big data centres |
These are ballpark figures to reason with. Real speeds depend on the exact hardware and the workload.
One computer's limits at three levels
Beginner The same walls on your own phone
You have already hit every wall on your phone:
- Storage wall: “Storage full. Delete some photos.”
- Memory wall: too many apps open, and the phone becomes slow or closes apps by itself.
- Compute wall: exporting a long 4K video takes many minutes.
- I/O wall: copying a movie to a pen drive crawls, however fast the phone is.
- Reliability wall: the phone falls in water and every photo without a backup is gone.
Big data is the same story, a million times larger.
Intermediate Find the bottleneck with simple arithmetic
- Time = data ÷ speed. 500 GB at 250 MB/s is 2,048 seconds, about 34 minutes, just to read once.
- I/O bound vs CPU bound: if the CPU is mostly idle while the disk is at 100%, buying a faster CPU does nothing.
- Memory blow-up: a CSV loaded into Python or pandas often takes 2–10 times its file size in RAM. A 6 GB file can need 30 GB of RAM.
- Distances in time (approximate): reading from RAM ≈ 100 nanoseconds; from an SSD ≈ 100 microseconds (1,000× slower); a hard-disk seek ≈ 10 milliseconds; a network round trip inside a data centre ≈ 0.5 ms; Mumbai to the US and back ≈ 200 ms.
- One core: a plain Python loop uses one core. On an 8-core machine the CPU meter shows only about 12%.
Advanced Why scaling out is powerful, and why it is hard
- Cost curve: scaling up gets more expensive per unit of power as you go higher, and stops at the biggest machine for sale. Scaling out costs roughly in line with size.
- Elasticity: in the cloud you can rent 80 nodes for Diwali week and return them after. You pay for the peak only while it lasts.
- New problems appear: the network becomes slow and unreliable compared with local memory; some nodes finish late (stragglers); a node can fail half-way (partial failure); and keeping copies in agreement becomes hard (consistency).
- Limits to speed-up: the part of a job that can't be split stays slow however many machines you add (Amdahl's law, Lesson 1.3).
- Move code to data: sending a 50 KB program to where 100 GB sits is far cheaper than moving the 100 GB.
- Module 3 covers these in depth: scaling and estimation, partitioning, replication and the CAP theorem.
Exam tip: Name the four resource limits (storage, memory, CPU, I/O) plus reliability, then contrast vertical and horizontal scaling in a table. Most university questions on “need for big data technologies” expect exactly this.
The five walls of one computer
1. Storage wall
The data doesn't fit on the machine's disks. Even large servers top out at some hundreds of TB; big companies have petabytes.
Disk space2. Memory wall
Fast processing needs data in RAM. When data is bigger than RAM, programs crash (MemoryError) or slow to a crawl as the OS swaps to disk.
3. Compute wall
A CPU has a fixed number of cores. A heavy calculation over billions of records can take days, and a plain Python loop uses only one core.
CPU4. I/O wall
Reading data is often the slowest part. One disk reads a few hundred MB per second, so 100 TB takes days just to read once.
Disk + network speed5. Reliability wall
One machine is one point of failure. A dead disk or power supply stops everything, and a 12-hour job must start again.
FailuresScale up vs scale out
| Vertical scaling (scale up) | Horizontal scaling (scale out) | |
|---|---|---|
| How | Replace with a bigger machine | Add more machines |
| Cost | Rises steeply: the top-end server costs many times more per unit of power | Grows roughly in line with size: buy as many ordinary nodes as you need |
| Upper limit | Yes: the largest machine you can buy | Practically very high: clusters run to thousands of nodes |
| Failure | The machine fails → everything stops | One node fails → others continue (if designed for it) |
| Software | Usually no change needed | Needs distributed software (HDFS, Spark, Kafka…) |
| Good for | Moderate growth, traditional databases | Big data, web-scale services |
Scaling up is not “wrong”. It is simpler, and for data up to some hundreds of GB it is often the best choice. Scale out when one machine truly can't keep up, because distributed systems add their own complexity.
Push 2 TB through one laptop and watch each wall appear
Storage: does it even fit?
The first wall is the simplest: 2 TB is four times the laptop's disk. An external drive helps, but then every read goes through a USB cable.data_gb, disk_gb = 2048, 512 print("Fits on disk?", data_gb <= disk_gb)Fits on disk? FalseMemory: load it all into a list
In Python, one small record object takes a few hundred bytes of RAM (you'll measure it below), far more than its size in the file. Billions of records need hundreds of GB of RAM. The laptop has 8.rows = open("orders_5yrs.csv").readlines() # tries to hold everything in RAMMemoryErrorStream it instead: one line at a time
Streaming fixes the memory wall: only one line is in RAM at a time. But now the I/O wall appears: the whole 2 TB still has to be read from the disk.total = 0 for line in open("orders_5yrs.csv"): # reads one line, forgets it total += int(line.split(",")[2])I/O: how long does reading take?
Nearly three hours just to read the data once, before any calculation. Python parsing each line is usually slower still, and the plain loop keeps only one of the four cores busy.mb = 2 * 1024 * 1024 # 2 TB in MB print(round(mb / 200 / 3600, 1), "hours at 200 MB/s (external hard disk)")2.9 hours at 200 MB/s (external hard disk)Scale up: buy a bigger server
A server with 64 cores, 512 GB RAM and fast NVMe disks finishes the job in minutes. For this year.
Next year the data doubles, and the year after it doubles again. Each bigger server costs disproportionately more, and there is always a largest machine. If it fails, the report doesn't run.Scale out: split the work
Twenty ordinary machines, each with its own disk, each reading its own part at the same time. Need it faster next year? Add machines. This is the idea behind Hadoop and Spark, and it is exactly what Lesson 1.3 builds on.machines = 20 print(round(2 * 1024 * 1024 / machines / 200 / 60), "minutes, each machine reading its own 100 GB")9 minutes, each machine reading its own 100 GB
One laptop vs 2 TB: what Riya sees, and what the hardware is doing
Step through the six frames. Left: Riya's screen. Right: the disk, memory and CPU inside.
- Riya tries to copy the 2 TB dataset to her laptop. Windows says there is not enough space.
- With the data on an external drive, her script tries to load all rows at once and crashes with MemoryError.
- She rewrites it to read one line at a time. No crash, but the progress bar says almost four hours.
- Strangely, Task Manager shows the CPU only 25% busy while the job crawls.
- A big server finishes in minutes, but it is expensive and the data will double next year.
- On a cluster of 20 ordinary machines, the same report takes about 9 minutes, and can grow by adding nodes.
- Storage wall: the dataset is four times larger than the entire disk.
- Memory wall: loading billions of rows as Python objects needs far more than 8 GB of RAM, so Python raises MemoryError.
- I/O wall: streaming keeps only one line in RAM, but every byte must still travel through a ~200 MB/s pipe. 2 TB takes about 3 hours.
- Compute wall: a plain Python loop runs on one core. The other three sit idle, so the CPU shows 25%.
- Scale up: bigger machines help, but cost climbs much faster than power, and there is a largest machine.
- Scale out: split the data across 20 nodes. Their disks read in parallel at a combined 4 GB/s, and a failed node's part can be redone by another.
Where the time goes: a rough budget for 2 TB
| Setup | Read speed | Time to read 2 TB once |
|---|---|---|
| Laptop + external hard disk | ~200 MB/s | ~2.9 hours |
| Laptop NVMe SSD (if it fitted) | ~3,000 MB/s | ~12 minutes |
| 20 nodes, 1 hard disk each | ~4,000 MB/s combined | ~9 minutes |
| 200 nodes, 1 hard disk each | ~40,000 MB/s combined | under 1 minute |
Reading is only the start: parsing, calculating and writing results add more time. The ratios are what matter.
Real-time scenarios: watching one machine run out of road
Three live scenarios: the race that convinced web companies to build Hadoop, a monthly report where every fix moves the bottleneck somewhere else, and an advanced one on the cost of scaling up versus scaling out.
Real-time scenario 1Reading 100 TB with 1 disk vs 1,000 disks
This is the calculation that convinced web companies to build systems like Hadoop. Watch the race, and see what happens when one of the thousand disks fails.
- The task: read 100 TB once. One disk at 200 MB/s versus 1,000 nodes each reading its own 100 GB.
- Race starts: the single disk has barely begun. The thousand disks are already a third of the way.
- Finish: the cluster is done in about 9 minutes. The single disk needs about 6 days.
- The catch: with a thousand disks, failures are a normal event, not a rare accident. Here one dies during the job.
- The fix: the data was stored with copies on other nodes, so that part is simply read again elsewhere. Designing for failure is a core big data idea.
Kabir's monthly report: every fix moves the bottleneck
TiffinGo's monthly orders file is 50 GB. Kabir tries to build the report on his 16 GB, 8-core laptop. Watch the four resource meters as he fixes one problem after another.
- Reading: the disk is at 100% while the CPU is at 12%. The job is I/O bound: reading 50 GB at 250 MB/s takes about 3.4 minutes on its own.
- Loading everything: in memory the data needs several times the file size. RAM hits 100%, the laptop swaps to disk and Python stops with
MemoryError. - Chunks: reading 1 GB at a time keeps RAM low. Now the CPU shows 12%: one core is busy and seven are idle.
- All cores: eight worker processes fill the CPU, and the disk is the limit again. Each fix moved the bottleneck.
- Next year: at 2 TB the disk, RAM and CPU are all full at once. This is the point where a cluster is the only real answer. (Numbers are approximate.)
The cost of growing: scale up vs scale out
As data grows, compare the cost of buying ever-bigger single servers with adding ordinary machines to a cluster. Then see what each does when hardware fails, and how the cloud changes the maths.
- Small data: one bigger server (red) costs less than a cluster (green) and needs no distributed software. Scaling up is the right choice here.
- Growing: top-end servers cost more and more per unit of power, so the curves cross. Beyond this point a cluster is cheaper.
- Ceiling: the red curve stops at the biggest server you can buy. The green line keeps going: you simply add more ordinary nodes.
- Failures: when the one big server dies, everything stops. When one of 40 nodes dies, the other 39 carry on, if the software is built for it.
- Cloud elasticity: a cluster can grow from 20 to 80 nodes for Diwali week and shrink back afterwards, so you pay for peak capacity only while you need it. (Curves are illustrative, not real prices.)
Where one machine stopped being enough
1. Search engines indexing the web
In the early 2000s, Google described how it stored and processed web-scale data across thousands of cheap machines (the Google File System and MapReduce papers). Those papers inspired the open-source Hadoop project. No single computer could hold or scan the whole web.
2. Banks: the end-of-day batch window
Banks run interest, statements and risk reports overnight. As customers grow, a job that took two hours on one big server starts running past morning opening time. Moving it to a cluster brings it back inside the window.
3. Video platforms: one upload, many versions
Every uploaded video is converted into many resolutions (240p to 4K). One machine would take hours per video; platforms split each video into chunks and convert the chunks on many machines at once.
4. Retail: daily demand forecasts per store
A retailer forecasting demand for 50,000 products in 2,000 stores has 10 crore small forecasts to compute every night. Each is independent, so they are spread across a cluster instead of running one after another.
5. Training AI models
Large AI models are trained on enormous datasets using hundreds or thousands of GPUs working together. Even the most powerful single machine would take far too long, so the data and the model are split across a cluster.
Examples are simplified to show the scaling problem. Real setups vary by company.
Calculate when one machine is too slow
The core big data calculation: how long does it take just to read the data, with 1 machine or many? Each machine has one hard disk reading about 200 MB per second, and reads only its own share. Then try the challenges: will the data fit, how often do disks fail, and how to split work.
def read_minutes(data_tb, machines, mb_per_sec=200):
data_mb = data_tb * 1024 * 1024
per_machine = data_mb / machines # each machine reads only its share
return per_machine / mb_per_sec / 60
data_tb = 2
for machines in [1, 5, 20, 100]:
m = read_minutes(data_tb, machines)
print(f"{machines:>3} machine(s): {m:6.1f} minutes")def read_minutes(data_tb, machines, mb_per_sec=200):mb_per_sec=200is a default value: a typical hard disk. Pass another value to model an SSD.per_machine = data_mb / machinesThe heart of scaling out: with the data spread evenly, each machine reads a smaller part, and all read at the same time.f"{machines:>3} machine(s): {m:6.1f} minutes"Format codes:>3right-aligns in 3 characters,6.1fshows one decimal place in 6 characters, so the columns line up.
Run it on your PC: measure your machine's memory wall
How much RAM do records really take inside Python? This program builds 10 lakh small payment records in a list and measures the memory used with Python's built-in tracemalloc. Save it as ram_test.py and run it on your computer.
How much RAM does one record need?
import os, shutil, tracemalloc
print("CPU cores :", os.cpu_count())
total, used, free = shutil.disk_usage(".")
print("Disk :", round(total / 1024**3), "GB total,", round(free / 1024**3), "GB free")
# How much memory do 10 lakh small payment records take inside Python?
tracemalloc.start()
records = [{"id": i, "item": "chai", "amount": 20} for i in range(1_000_000)]
used_mb = tracemalloc.get_traced_memory()[0] / 1024**2
tracemalloc.stop()
print("10 lakh records in a list use", round(used_mb), "MB of RAM")
per_record = used_mb * 1024**2 / len(records)
print("That is about", round(per_record), "bytes per record")
for n, label in [(100_000_000, "10 crore"), (10_000_000_000, "1,000 crore")]:
gb = n * per_record / 1024**3
print(f"{label:>11} records would need about {gb:,.0f} GB of RAM")
# In a terminal: python ram_test.pyRecorded on a small cloud machine with Python 3.10. Your cores and disk will be different; the bytes per record will be close (it varies a little by Python version). A record of about 40 characters in a CSV becomes about 270 bytes as a Python object. That gap is why loading big data “into memory” fails long before the disk is full.
Scaling out, one line at a time
Watch how the same function is called three times, once for each cluster size. Each call gets its own frame with its own machines and per_machine; the frame disappears when the function returns.
Worked examples: real problems, solved and traced in memory
Four decisions, from beginner to advanced. Three a data engineer actually makes: does the data fit, which kind of scaling is cheaper, and how many failures to plan for. Each program runs live and is traced in memory. The last one finds the bottleneck of a whole job.
Which walls will the laptop hit?
Problem statement
A laptop has a 512 GB disk and 8 GB RAM. A job needs to store 2,048 GB and, if loaded into Python, would need about 1,760 GB of RAM. Print which resources are a problem.
laptop: disk 512, ram 8 · job: disk 2048, ram 1760 (GB)
disk wall: 4 times too small ram wall: 220 times too small
Approach
- Put the laptop's capacity and the job's needs in two dictionaries with the same keys.
- Loop over the keys and compare need with capacity.
- Print a “wall” message when the need is bigger.
Solution: run it live
What happens in memory, step by step
Recorded from a real Python run: press Next to execute one line at a time. Watch variables change in each frame, and lists and dictionaries (numbered #1, #2 …) fill up as objects.
Scale up or scale out?
Problem statement
A team needs 256 CPU cores. One option is a single 256-core server. The other is a cluster of 16-core nodes at ₹2,50,000 each. Compare the cost (prices are illustrative).
needed 256 cores · servers {64: 12 lakh, 128: 35 lakh, 256: 1.1 crore} · node 16 cores at 2.5 lakhScale up : one server, Rs 110.0 lakh Scale out: 16 nodes, Rs 40.0 lakh
Approach
- Look up the price of the 256-core server.
- Work out how many 16-core nodes give 256 cores.
- Multiply by the node price and compare.
Solution: run it live
What happens in memory, step by step
Recorded from a real Python run: press Next to execute one line at a time. Watch variables change in each frame, and lists and dictionaries (numbered #1, #2 …) fill up as objects.
How many disk failures should we plan for?
Problem statement
A cluster has 1,000 hard disks. Around 1.5% of disks fail each year. How many failures should the team expect per year, and how often is that?
1000 disks, 1.5% fail per year
Expected failures per year: 15.0 About one failure every 24 days
Approach
- Multiply disks by the yearly failure rate.
- Divide 365 days by that number to get the gap between failures.
Solution: run it live
What happens in memory, step by step
Recorded from a real Python run: press Next to execute one line at a time. Watch variables change in each frame, and lists and dictionaries (numbered #1, #2 …) fill up as objects.
Which resource limits the job?
Problem statement
A nightly job must read 600 GB, do 48 core-hours of calculation and send 120 GB of results over the network. The server has disks that read 1,000 MB/s in total, 16 cores and a 1 Gbps network (125 MB/s). Estimate how long each part takes if it runs alone, and name the bottleneck.
600 GB read · 48 core-hours · 120 GB send · 1000 MB/s · 16 cores · 125 MB/s
disk : 10.2 minutes cpu : 180.0 minutes network : 16.4 minutes Bottleneck: cpu
Approach
- Disk time = data ÷ disk speed. Convert GB to MB by multiplying by 1024.
- CPU time = core-hours ÷ cores.
- Network time = data sent ÷ network speed.
- When parts overlap, the slowest one sets the total time: that is the bottleneck.
Solution: run it live
What happens in memory, step by step
Recorded from a real Python run: press Next to execute one line at a time. Watch variables change in each frame, and lists and dictionaries (numbered #1, #2 …) fill up as objects.
Check yourself
Quick revision
Lesson 1.2 in one screen
- Time = data ÷ speed. The slowest resource is the bottleneck; fixing it moves the bottleneck elsewhere.
- RAM ≈ 100 ns, SSD ≈ 100 µs, HDD seek ≈ 10 ms, data-centre round trip ≈ 0.5 ms.
- Cloud elasticity: rent nodes for the peak, return them after.
- One computer has five walls: storage, memory, CPU, I/O (disk + network) and reliability.
- Hard disk ≈ 200 MB/s. 100 TB on one disk ≈ 6 days; on 1,000 disks in parallel ≈ 9 minutes.
- Vertical scaling (scale up): bigger machine. Simple, but steep cost, hard ceiling, single point of failure.
- Horizontal scaling (scale out): more machines. Grows far, survives failures, but needs distributed software.
- Python objects are much bigger than file bytes, so “load everything into memory” fails early. Stream instead.
- A plain loop uses one core. Big jobs are often I/O bound.
- With many machines, failures are normal: keep copies of data and re-run failed parts.
Interview and viva questions
What are the limitations of a single machine for processing big data?
Limited storage capacity, limited RAM (data larger than memory causes crashes or swapping), limited CPU cores (a single process uses one), limited I/O bandwidth (one disk reads a few hundred MB/s, so terabytes take hours), and it is a single point of failure. Scaling it up is expensive and has an upper limit.
Differentiate vertical and horizontal scaling.
Vertical scaling adds CPU, RAM or disk to one machine: simple, no code change, but costly at the top end, limited by the largest machine, and still a single point of failure. Horizontal scaling adds more machines and splits data and work across them: cost grows roughly linearly, it can grow very large and tolerate node failures, but it needs distributed software and adds network and coordination complexity.
What does “I/O bound” mean? Give an example.
A job is I/O bound when its speed is limited by reading or writing data rather than by calculation. Summing one column of a 2 TB file is I/O bound: the addition is trivial, but reading 2 TB from a disk at 200 MB/s takes about three hours.
Why is commodity hardware used in big data clusters?
Ordinary servers are cheap and easy to replace. Instead of paying a large premium for one very reliable machine, clusters use many affordable machines and handle failures in software through replication and re-running tasks.
Is scaling out always better than scaling up?
No. For data that fits comfortably on one machine, scaling up is simpler, cheaper to run and has no distributed-system complexity. Scale out when the data, the speed requirement or the reliability requirement goes beyond what one machine can deliver.
Practice problems
Capacity and time calculations that come up in real data platform planning. The last three are business tasks.
Read time for 500 GB
How many minutes does it take to read 500 GB from a disk at 250 MB/s?
500 GB, 250 MB/s
34.1 minutes
Show solution and explanation
mb = 500 * 1024
print(round(mb / 250 / 60, 1), "minutes")How it works: 500 GB = 5,12,000 MB; ÷ 250 MB/s = 2,048 s ≈ 34 minutes.
How many disks?
Each disk holds 4 TB. How many disks are needed for 90 TB? (A part-full disk still counts.)
90 TB, 4 TB per disk
23 disks
Show solution and explanation
import math
print(math.ceil(90 / 4), "disks")How it works: math.ceil rounds up: 22.5 becomes 23.
Fits in RAM?
A 6 GB CSV is loaded into Python, where it takes about 5 times its file size. The machine has 16 GB RAM. Print whether it fits.
6 GB file, ×5 overhead, 16 GB RAM
Needs 30 GB; fits? False
Show solution and explanation
needed = 6 * 5
print("Needs", needed, "GB; fits?", needed <= 16)How it works: 30 GB > 16 GB, so it won't fit even though the file itself is smaller than the RAM.
Round-robin assignment
Assign 7 tasks to 3 workers in turn and print each worker's tasks.
tasks T1..T7, 3 workers
{1: ['T1', 'T4', 'T7'], 2: ['T2', 'T5'], 3: ['T3', 'T6']}Show solution and explanation
tasks = [f"T{i}" for i in range(1, 8)]
workers = {1: [], 2: [], 3: []}
for i, t in enumerate(tasks):
workers[i % 3 + 1].append(t)
print(workers)How it works: i % 3 cycles 0, 1, 2, 0, 1, 2 …, so tasks go to workers 1, 2, 3, 1, 2, 3 ….
Speed-up and efficiency
A job takes 120 minutes on 1 machine and 10 minutes on 16 machines. Print the speed-up (old ÷ new time) and the efficiency (speed-up ÷ machines) as a percentage.
120 min on 1, 10 min on 16
Speed-up: 12.0 Efficiency: 75.0 %
Show solution and explanation
speedup = 120 / 10
efficiency = speedup / 16 * 100
print("Speed-up:", speedup)
print("Efficiency:", efficiency, "%")How it works: Perfect scaling would give a speed-up of 16. Coordination and uneven splits usually cost something, here 25%.
Will it fit in RAM?
A CSV takes about 6 times its file size once loaded into pandas. For each file, print whether it fits in 16 GB of RAM (keeping 4 GB free for the operating system), and if not, how many chunks of equal size are needed so that each chunk fits.
files: 1.5, 3, 9 GB · RAM 16 GB · reserve 4 GB
1.5 GB file needs 9.0 GB: fits 3 GB file needs 18 GB: use 2 chunks 9 GB file needs 54 GB: use 5 chunks
Show solution and explanation
import math
ram, reserve, blowup = 16, 4, 6
usable = ram - reserve
for size in [1.5, 3, 9]:
need = size * blowup
if need <= usable:
print(f"{size} GB file needs {need} GB: fits")
else:
chunks = math.ceil(need / usable)
print(f"{size} GB file needs {need} GB: use {chunks} chunks")How it works: Memory needed = file size × blow-up factor. When it exceeds usable RAM, split the file into ceil(need ÷ usable) chunks and process them one at a time, exactly what Kabir did in scenario 2.
Nodes needed per hour (autoscaling)
Each node handles 5,000 orders per second. Given the expected orders per second for each hour, print how many nodes to run in that hour (always at least 2, for safety) and the total node-hours for the day so far.
[8000, 21000, 64000, 12000]
hour 0: 8000 orders/s -> 2 nodes hour 1: 21000 orders/s -> 5 nodes hour 2: 64000 orders/s -> 13 nodes hour 3: 12000 orders/s -> 3 nodes Total node-hours: 23
Show solution and explanation
import math
per_node = 5000
load = [8000, 21000, 64000, 12000]
node_hours = 0
for hour, rate in enumerate(load):
nodes = max(2, math.ceil(rate / per_node))
node_hours = node_hours + nodes
print(f"hour {hour}: {rate:>6} orders/s -> {nodes} nodes")
print("Total node-hours:", node_hours)How it works: This is what cloud autoscaling does: capacity follows the load hour by hour, instead of running 13 nodes all day for the one peak hour.
Fit the nightly window
A bank's nightly job must read 30 TB within 2 hours. Each node reads 200 MB/s. What is the minimum number of nodes?
30 TB, 2 hours, 200 MB/s per node
Minimum nodes: 22
Show solution and explanation
import math
total_mb = 30 * 1024 * 1024
one_node_secs = total_mb / 200
nodes = math.ceil(one_node_secs / (2 * 3600))
print("Minimum nodes:", nodes)How it works: One node would need about 43.7 hours; to finish in 2 hours you need at least 22 nodes (in practice, more for safety and failures).
Same cost, faster answer
Cloud nodes cost Rs 40 per hour each. A report needs 25 node-hours of work. Compare 1 node for 25 hours with 50 nodes for half an hour.
Rs 40/node-hour, 25 node-hours
1 node(s) for 25 h -> Rs 1000 50 node(s) for 0.5 h -> Rs 1000
Show solution and explanation
rate = 40
for nodes, hours in [(1, 25), (50, 0.5)]:
print(nodes, "node(s) for", hours, "h -> Rs", round(nodes * hours * rate))How it works: Both cost Rs 1,000, but one finishes 50 times sooner. On pay-per-use clouds, scaling out often costs the same and saves time.
When do we outgrow one server?
Data is 2 TB today and grows 60% a year. One server can handle up to 20 TB. In which year does the data pass that limit?
2 TB, +60% per year, limit 20 TB
Year 5 : about 21.0 TB
Show solution and explanation
data, year = 2.0, 0
while data <= 20:
data = data * 1.6
year = year + 1
print("Year", year, ": about", round(data, 1), "TB")How it works: Growth compounds: 2 → 3.2 → 5.1 → 8.2 → 13.1 → 21.0. Planning for scale-out starts years before the limit.
Real-world scenario questions (asked in company interviews)
Questions about scaling that interviewers use to see whether you can reason with numbers. Decide your answer first, then open the model answer.
The nightly job now finishes after the bank opens
The end-of-day reconciliation job ran in 3 hours two years ago. Transactions have tripled and it now takes 8 hours, finishing after 9 am. It runs on one large database server. What would you investigate and propose?
The interviewer is checking: can you find the bottleneck first, and do you know when to scale up versus scale out?
Show a strong answer
- Measure first: is the job limited by disk reads, CPU, memory (swapping) or locks in the database? Look at monitoring during the run.
- Quick wins: process only the new day's data instead of rescanning history; add the right indexes; use columnar formats for reporting tables.
- If it's still growing: a bigger server buys a year or two. For sustained growth, move the heavy batch work to a distributed engine like Spark on a cluster, reading data in parallel, so capacity grows by adding nodes.
Avoid saying: “Just buy a bigger server” or “Move everything to Hadoop” without measuring where the time goes.
“Why not just buy one very powerful computer?”
An interviewer asks you to argue why big data platforms use clusters of ordinary machines rather than one supercomputer-class server.
The interviewer is checking: do you know the concrete limits, not just the slogan “big data needs clusters”?
Show a strong answer
- Ceiling: even the biggest server has a fixed maximum of disks, RAM and cores; data keeps growing.
- Cost curve: top-end hardware costs far more per unit of power than ordinary servers.
- I/O: a cluster reads from hundreds of disks in parallel; 100 TB in minutes instead of days.
- Reliability: one machine is a single point of failure; a cluster with replicated data keeps running when a node dies.
- Elasticity: in the cloud you can add nodes for a busy night and remove them after.
Avoid: claiming one big machine is always worse. For small and medium data it is simpler and often the right choice.
The script that takes hours at 25% CPU
A colleague's Python script summarises 300 GB of order logs. It takes five hours, and the 4-core machine shows 25% CPU the whole time. They ask you to “make it use the whole CPU”.
The interviewer is checking: do you understand serial loops, I/O bottlenecks and the options available before reaching for a cluster?
Show a strong answer
25% on 4 cores means one core is busy: the loop is serial. It may also be waiting on the disk.
- Check read speed: 300 GB at ~200 MB/s is about 25 minutes of pure reading, so most of the 5 hours is Python processing.
- Split the files and process them with
multiprocessing(one process per core), or use faster tools like Pandas/Polars on chunks or DuckDB. - Store logs in a compressed columnar format (Parquet) so only needed columns are read.
- If the data keeps growing, run it on Spark across several machines.
Avoid: assuming more CPU alone fixes it without checking whether the disk is the bottleneck.
“Disks rarely fail, we don't need copies”
In a design review for a 500-node storage cluster with 6 disks per node, a teammate proposes storing one copy of each file to save money, because “disks rarely fail”.
The interviewer is checking: can you turn a small per-disk failure rate into a cluster-wide expectation?
Show a strong answer
500 × 6 = 3,000 disks. At around 1.5% failing per year, that's about 45 failures a year, nearly one a week. With a single copy, each failure loses data permanently.
- Keep multiple copies (HDFS defaults to 3) on different nodes and racks, or use erasure coding to save space while still surviving failures.
- Automate detection and re-copying of data from failed disks.
- Quote the trade-off: extra storage cost versus the cost of losing data and re-running jobs.
Avoid: judging reliability per disk instead of across the whole cluster.