Cluster sizing with real numbers

Sizing is arithmetic with a few honest assumptions. This lesson walks through the whole calculation for a payments company, from terabytes per day to the number of servers, NameNode heap and containers, and measures our own lab with TestDFSIO so you can see where real throughput numbers come from and why a laptop's numbers must not be copied into a production plan.

Module 12 · Multiple clusters and operations⏱ 32 minIntermediateFull worked sizing, every number shownReal TestDFSIO benchmarkRuns in your browser (Python)8 practice problems
1 The story

“How many servers should we buy?”

Kabir's internship has moved to a payments startup. Its UPI switch writes about 2 TB of transaction logs a day, the regulator wants three years kept, and the fraud reports must be ready by 6 AM. The CFO wants one number by Friday: how many servers. Kabir's first guess comes from the lab: “Our three containers wrote 210 MB/s, so…” Riya stops him.

2 TB / dayraw UPI logs 0.5 TBParquet + zstd 547.5 TB× 1,095 days 1,642.5 TB× 3 copies 3,812.9 TB of disk+temp, 70% full, +30% ÷ 96 TB per worker= 40 workers Every arrow is an assumption you can name. That is what makes a sizing defensible. myphatshala.in
Riya

Kabir, those 210 MB/s came from three containers sharing one laptop disk. A real server has twelve disks and its own network card. You can't multiply a laptop.

Kabir

Then where do I even start?

Arjun Sir

From the data, not from the hardware. How much arrives each day, how small it gets on disk, how long you keep it, how many copies. That gives the storage, and storage usually decides the server count. Then you check three things against it: can the nightly work finish in its window, can the NameNode hold all the file and block objects, and does the network keep up. Today we do the whole calculation and also benchmark our own lab properly, so you know what a benchmark number really means.

2 Definition

Cluster sizing

Formal definition (write this in exams)

Cluster sizing (capacity planning) is the process of estimating the hardware a cluster needs to meet its storage, processing, availability and growth requirements. For Hadoop it combines: storage = data ingested per period × compression ratio × retention × replication factor (or erasure-coding overhead), plus space for temporary and intermediate data and headroom to keep disks below a target fill level; compute = the number of concurrent containers needed so that the workload, expressed in container-seconds, completes within its time window; memory and CPU per node derived from container sizes after reserving resources for the operating system and daemons; NameNode heap estimated from the expected number of files, directories and blocks; network bandwidth for ingest, replication and shuffle; and the master and edge nodes required for high availability and access. Estimates rest on stated assumptions and on benchmarks (such as TestDFSIO) of representative hardware.

In simple words

Work out how much data you will keep and how much work you must finish in how much time, add safety margins, and turn that into servers. Write down every assumption, and measure real hardware before trusting a number.

Words you'll meet in this lesson

RetentionHow long data must be kept (here 3 years = 1,095 days).
Compression ratioStored size ÷ raw size; 0.25 for our Parquet + zstd assumption.
HeadroomFree space kept on purpose; target fill 70%.
Temp spaceRoom for map output, staging and new files; +25% here.
Container-secondsTotal work: number of containers × seconds each.
Batch windowThe time a nightly job is allowed to take.
TestDFSIOHadoop's HDFS read/write benchmark (MapReduce tests jar).
OversubscriptionServers' total bandwidth ÷ the rack's uplink bandwidth.

From our lab (TestDFSIO, 64 MB files, replication 3, 3 workers on one laptop)

Write1 task: 113.48 MB/s · 3 tasks: 61.82 MB/s each (about 185 in total) · 6 tasks: 34.99 MB/s each (about 210 in total)
Read1 task: 320 MB/s · 3 tasks: 175.34 MB/s each · 6 tasks: 130.3 MB/s each (files just written, so mostly from memory)
Why it flattensAll three workers are containers on one laptop with one disk: more writers share the same disk
Example cluster2 TB/day, 3 years, replication 3 → 3,812.9 TB of disk → 40 workers; with cold data on RS-6-3 → 22 workers

Architecture at a glance: the cluster we are sizing

The UPI example, sized. Typical hardware values (disks, RAM, NICs) are assumptions for illustration.

spine / core switches 2 × 40 Gb uplink per rack rack 1 · ToR switch rack 2 · ToR switch rack 3 · ToR switch master 1: NameNode · JN · ZK master 2: NameNode · RM · JN · ZK master 3: RM · JN · ZK · JobHistory 14 workers each: 12 × 8 TB disks 256 GB RAM · 32 cores DataNode + NodeManager 224 GB YARN · 30 containers 10 GbE to the ToR 13 workers same hardware 40 workers in total 3,840 TB raw disk 13 workers same hardware 1,200 containers night job needs 291 edge node 1 (users, Airflow) edge node 2 (ingest gateway) masters spread over 3 racks JN = JournalNode · ZK = ZooKeeper · RM = ResourceManager · ToR = top-of-rack switch myphatshala.in

Sizing at three levels

Pick your level. New to this? Start at Beginner and climb.

Beginner Building a godown

  • A grain trader asks: how big a godown? You ask how many sacks arrive a day, how long they stay, and whether every sack must be stored three times (copies) in different corners.
  • You never fill a godown to the roof: you need aisles and space for a sudden delivery (headroom and temp space).
  • Then you check the loading crew: can they move tonight's sacks before morning? That is compute against the batch window.

Intermediate The calculation, in order

  • Storage: 2 TB × 0.25 = 0.5 TB/day → × 1,095 = 547.5 TB → × 3 = 1,642.5 TB → × 1.25 ÷ 0.70 × 1.3 = 3,812.9 TB → ÷ 96 = 40 workers.
  • NameNode: 2,048 files of 256 MB a day → 2,242,560 files and 4,485,120 blocks in 3 years → about 0.9 GB of objects at 150 B each. Plan a heap several times larger.
  • Compute: 60 TB scanned nightly at 20 MB/s per container = 3,145,728 container-seconds ÷ 10,800 s = 291 containers, against 40 × 30 = 1,200.
  • Per node: 256 GB − 32 GB reserved = 224 GB for YARN; 30 vcores → about 7.5 GB per vcore (Lesson 11.4).

Advanced What experienced planners add

  • Tiering: keep 90 hot days with 3 copies and older data in erasure coding: 888.8 TB of data and 22 workers instead of 40 (Lesson 7.3).
  • Network: 20 workers × 10 Gb = 200 Gb against 80 Gb of uplink is 2.5:1 oversubscription; replication and shuffle cross racks, so keep it modest.
  • Failure budget: losing one 96 TB node means re-replicating up to 96 TB; headroom and network decide how long that takes.
  • Benchmark, then re-plan: run TestDFSIO and a real job on one candidate server, replace the assumed throughput, and review against actual growth every quarter.

Exam tip: For “How will you size a Hadoop cluster for X TB per day?”, write the storage formula (daily × ratio × retention × replication × temp ÷ fill × growth ÷ disk per node), then one line each for compute (container-seconds ÷ window), NameNode heap (objects × ~150 B) and masters (2 NN, 3 JN, 3 ZK, 2 RM).

3 Types and ways to use it

The levers that change a sizing

LeverExample changeEffect in our exampleCost
File formatRaw CSV → Parquet + zstd159 → 40 workersConversion jobs (Lesson 10.2)
Retention3 years → 1 year40 → 14 workersA policy decision, often regulatory
Erasure codingCold data (90+ days) on RS-6-340 → 22 workersSlower recovery, more CPU (Lesson 7.3)
File size1 MB → 256 MB filesNameNode objects ÷ about 170Compaction or batching (Lesson 7.5)
Disk fill target70% → 85%Fewer disks, less safetyRisk during failures and rebalancing

Roles to size

Workers

DataNode + NodeManager. Sized by storage first, then checked for compute.

many

Masters

2 NameNodes, 3 JournalNodes, 3 ZooKeeper, 2 ResourceManagers, JobHistory: usually 3 servers with lots of RAM, spread over racks.

3–5

Edge nodes

Where users and tools (Airflow, Hive clients, ingest) connect; no data stored.

2+

Network

10/25 GbE per server, top-of-rack switches, uplinks; watch oversubscription.

racks

Animated example: sizing the payments cluster

From 2 TB a day to 40 servers 6 steps
Animated example UPI switch logs · 2 TB/day · keep 3 years 0.5 TB/dayParquet + zstd 1,642.5 TB3 years × 3 copies 40 workers3,812.9 TB ÷ 96 NameNode ≈ 0.9 GB objects2.2 M files + 4.5 M blocks 291 of 1,200 containers60 TB scan in 3 h fits cold data on RS-6-3 → 22 workers instead of 40 Step 1 · compress: 2 TB of logs becomes about 0.5 TB of Parquet. Step 2 · keep 1,095 days, three copies of each. Step 3 · +25% temp, 70% fill, +30% growth, ÷ 96 TB. Step 4 · count files and blocks for the NameNode heap. Step 5 · check the fraud job fits its 3-hour window. Step 6 · tiering: the biggest saving of all. Hardware values are assumptions; real projects benchmark them. myphatshala.in

Size from the data, check with benchmarks. A sizing that starts from “we have budget for 20 servers” and works backwards is a budget, not a plan.

4 Step by step

Benchmark first, then size

Run on the Module 8 lab with dfsio_lab.sh (in “Run it on your PC”), then do the arithmetic for the payments example.

  1. Benchmark writes with one task

    yarn org.apache.hadoop.fs.TestDFSIO -libjars $T -write -nrFiles 1 -fileSize 64MB
    Total MBytes processed: 64 Throughput mb/sec: 113.48 Test exec time sec: 17.6
    One map task writes one 64 MB file with three replicas. 113 MB/s is what one writer gets from our laptop's disk, through the DataNode pipeline.
  2. Add writers

    write, 3 files: Throughput mb/sec: 61.82
    write, 6 files: Throughput mb/sec: 34.99
    Per task the number drops; the total grows from about 113 to 185 to 210 MB/s and then flattens. Three “workers” sharing one disk can't add disk speed. On real servers, each node adds its own disks and the total keeps growing.
  3. Benchmark reads

    read, 1 file:  Throughput mb/sec: 320
    read, 3 files: Throughput mb/sec: 175.34
    read, 6 files: Throughput mb/sec: 130.3
    Reads look faster because the files were written seconds earlier and are still in memory (page cache). For an honest read benchmark, use files much larger than RAM or drop the caches first.
  4. Storage for the payments company

    2 TB × 0.25 = 0.5 TB/day × 1,095 days = 547.5 TB
    × 3 copies = 1,642.5 TB × 1.25 temp ÷ 0.70 fill × 1.3 growth = 3,812.9 TB
    ÷ 96 TB per worker (12 × 8 TB) = 39.7 → 40 workers
    Storage decides the cluster size. The compression ratio and disk per node are assumptions; measure the ratio on a sample of your real data (Lesson 10.2 measured about 0.14 for Parquet + zstd on our CSV, so 0.25 is a cautious choice).
  5. Check NameNode heap and compute

    files: 2,048 a day × 1,095 = 2,242,560; blocks: 4,485,120
    objects × 150 B ≈ 0.9 GB  (rule of thumb; plan a much larger heap)
    nightly work: 60 TB ÷ 20 MB/s = 3,145,728 container-seconds
    ÷ 10,800 s (3 h) = 291 containers at once; available 40 × 30 = 1,200
    Both fit with room to spare. If either did not, it would add nodes (compute), larger files (heap) or a second namespace (Lesson 7.2).
  6. Masters, edge and network

    masters: 3 servers (2 NN, 2 RM, 3 JN, 3 ZK, JobHistory), one per rack
    edge: 2 servers
    racks: 45 servers ÷ 20 per rack = 3 racks
    oversubscription: 20 × 10 Gb ÷ 80 Gb uplink = 2.5 : 1
    Spreading masters across racks means a single rack failure can't take the NameNode pair or the JournalNode quorum down (Lesson 7.1).

Never copy a benchmark from a laptop, a VM or another company's blog into a purchase order. Run TestDFSIO and one real job on a candidate server first, and treat every typical value in this lesson as a placeholder for your own measurement.

5 See it happen

Why more writers didn't mean more speed

Six steps of our TestDFSIO runs: what the tool printed and what was happening on the one shared disk.

Per task vs in total 6 steps
What you see hadoop@namenode : /tmp $ TestDFSIO -write -nrFiles 1 -fileSize 64MBThroughput mb/sec: 113.48Test exec time sec: 17.6 $ TestDFSIO -write -nrFiles 3 ...Throughput mb/sec: 61.82Average IO rate mb/sec: 68.42 $ TestDFSIO -write -nrFiles 6 ...Throughput mb/sec: 34.99Test exec time sec: 31.82 total = per task × tasks1 × 113.48 = 1133 × 61.82 = 1856 × 34.99 = 210 $ TestDFSIO -read -nrFiles 1 ...Throughput mb/sec: 320-read -nrFiles 6:Throughput mb/sec: 130.3 production worker (assumed):12 disks × ~150 MB/s≈ 1,800 MB/s of disk per node10 GbE NIC ≈ 1,250 MB/s myphatshala.in
Behind the screen worker1 worker2 worker3 ONE laptop disk one writer has the disk to itself: 113 MB/s three writers share it: 62 MB/s each six writers: 35 MB/s each 113 · 185 · 210the total flattens: the disk is the limit page cachereads come partly from memory: faster than the disk 12 disks12 disks12 disksreal workers bring their own disks: totals add up myphatshala.in
6 Real-world use

Sizing at work

UPI logs3 years kept

1. Payments: regulation drives retention

Payment companies keep transaction records for years by regulation. Retention × copies decides most of the cluster, so tiering old data to erasure coding or archive storage is the biggest cost lever.

Retention rule→Storage formula→Workers + tiering plan

2. E-commerce: the sale day sets the compute

Clickstream volume can be many times normal during a festival sale. Teams size compute for the peak night's window, and often burst extra capacity in the cloud for those days.

Peak volume→Container-seconds ÷ window→Containers needed
CDRsORC 20%

3. Telecom: format is the cheapest saving

Call records compress very well in columnar formats. Converting raw CDR text to ORC or Parquet often reduces the hardware more than any server discount.

Raw CDR text→ORC conversion→Fewer disks
NameNodeheap!

4. Healthcare: file counts, not bytes

Hospitals store millions of small reports and image metadata files. Their sizing worry is NameNode heap, solved by packing files into containers or object storage, not by more disks.

Millions of files→Objects × 150 B→Pack or federate
owncloud

5. Government: phased buying and growth

Public schemes grow as enrolment grows and data is rarely deleted. Planners model growth year by year and buy hardware in phases, reviewing against real usage before each purchase.

Growth model→Yearly sizing→Phased purchase

Simplified; organisations differ in tools and policies. Hardware figures in this lesson are assumptions for illustration.

7 Run the code

A cluster sizing calculator

The assumptions are at the top. Change one and see which part of the cluster moves. Storage usually decides the number of workers; compute checks that the nightly work fits the window.

import math
# --- assumptions (change these) ---
RAW_TB_DAY, RATIO, DAYS = 2.0, 0.25, 3 * 365     # raw data per day, Parquet+zstd size ratio, retention
REPL, TEMP, FILL, GROWTH = 3, 1.25, 0.70, 1.3     # replication, +25% temp/shuffle, keep disks 70% full, +30%
DISK_TB_PER_NODE = 12 * 8                         # 12 disks of 8 TB
NIGHTLY_SCAN_TB, MB_S_PER_CONTAINER, WINDOW_H = 60, 20, 3

stored = RAW_TB_DAY * RATIO * DAYS                # TB kept, one copy
data = stored * REPL
disk = data * TEMP / FILL * GROWTH
workers = math.ceil(disk / DISK_TB_PER_NODE)
print(f"one copy {stored:.1f} TB -> x{REPL} = {data:.1f} TB -> disk to buy {disk:.1f} TB -> {workers} workers")

files = RAW_TB_DAY * RATIO * 1024 * 1024 / 256 * DAYS   # 256 MB files
blocks = files * 2                                      # 128 MB blocks
print(f"{files:,.0f} files, {blocks:,.0f} blocks -> about {(files + blocks) * 150 / 2**30:.1f} GB of NameNode heap")

containers = NIGHTLY_SCAN_TB * 1024 * 1024 / MB_S_PER_CONTAINER / (WINDOW_H * 3600)
print(f"nightly work needs {containers:.0f} containers at once; {workers} workers x 30 = {workers * 30}")
one copy 547.5 TB -> x3 = 1642.5 TB -> disk to buy 3812.9 TB -> 40 workers 2,242,560 files, 4,485,120 blocks -> about 0.9 GB of NameNode heap nightly work needs 291 containers at once; 40 workers x 30 = 1200
  • disk = data * TEMP / FILL * GROWTHTemp space for shuffle and staging, headroom so disks never pass 70%, and a year of growth.
  • blocks = files * 2 # 128 MB blocksHeap depends on the number of files and blocks, not on bytes (Lesson 7.5).
  • containers = NIGHTLY_SCAN_TB * 1024 * 1024 / MB_S_PER_CONTAINER / (WINDOW_H * 3600)Total work in container-seconds divided by the seconds you have.

Run it on your PC: benchmark your own cluster

TestDFSIO ships with Hadoop in the MapReduce tests jar. Each map task writes (or reads) one file; the result is the throughput per task. Run it inside the Module 8 lab's namenode container. It takes about 3 minutes and removes its files with -clean at the end.

TestDFSIO: 1, 3 and 6 parallel writers and readers

# dfsio_lab.sh: measure what our cluster can write and read (TestDFSIO), the input to any sizing exercise.
# Run inside lab8-namenode-1.
T=$(ls /opt/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-*-tests.jar)
export HADOOP_CLASSPATH=$T
for files in 1 3 6; do
  for op in write read; do
    yarn org.apache.hadoop.fs.TestDFSIO -libjars $T -$op -nrFiles $files -fileSize 64MB -resFile /tmp/dfsio.txt > /tmp/dfsio.log 2>&1
    echo "== $op, $files file(s) x 64 MB in parallel"
    grep -E "Total MBytes processed|Throughput mb/sec|Average IO rate|Test exec time" /tmp/dfsio.log | sed -E 's/^.*TestDFSIO:[0-9]+ - +/   /'
  done
done
yarn org.apache.hadoop.fs.TestDFSIO -libjars $T -clean > /dev/null 2>&1

# On your PC, in the mr-lab folder:
#   docker cp dfsio_lab.sh lab8-namenode-1:/tmp/
#   docker exec lab8-namenode-1 bash /tmp/dfsio_lab.sh
== write, 1 file(s) x 64 MB in parallel Total MBytes processed: 64 Throughput mb/sec: 113.48 Average IO rate mb/sec: 113.48 Test exec time sec: 17.6 == read, 1 file(s) x 64 MB in parallel Total MBytes processed: 64 Throughput mb/sec: 320 Average IO rate mb/sec: 320 Test exec time sec: 18.71 == write, 3 file(s) x 64 MB in parallel Total MBytes processed: 192 Throughput mb/sec: 61.82 Average IO rate mb/sec: 68.42 Test exec time sec: 24.06 == read, 3 file(s) x 64 MB in parallel Total MBytes processed: 192 Throughput mb/sec: 175.34 Average IO rate mb/sec: 226.7 Test exec time sec: 20.66 == write, 6 file(s) x 64 MB in parallel Total MBytes processed: 384 Throughput mb/sec: 34.99 Average IO rate mb/sec: 35.97 Test exec time sec: 31.82 == read, 6 file(s) x 64 MB in parallel Total MBytes processed: 384 Throughput mb/sec: 130.3 Average IO rate mb/sec: 197.36 Test exec time sec: 29.2

Real output. “Throughput mb/sec” is per task (total MB ÷ the sum of task times). Multiply by the number of tasks for an approximate cluster total: about 113, 185 and 210 MB/s for writes. All three workers share one laptop disk, so the total stops growing. Reads look fast because the files were just written and sit in memory (page cache).

8 Line by line

From terabytes a day to workers

Follow the storage calculation one multiplication at a time.

Worked examples: real problems, solved and traced in memory

Four sizing problems from different industries. Every assumption is written down, because a sizing is only as good as its assumptions.

Example 1BeginnerTelecom · storage

How much disk for call records?

Problem statement

A telecom operator produces 800 GB of call detail records (CDRs) a day. They are kept for 2 years as ORC (about 20% of raw size), with replication 3, 25% temp space, disks at most 70% full. How many workers with 12 × 10 TB disks?

Input
800 GB/day · 2 years · ORC 20% · 3 copies
Expected output
116.8 TB stored, 350.4 TB with copies, 625.7 TB disk -> 6 workers

Approach

  1. Stored per day = raw × ratio.
  2. Data = stored × days × 3.
  3. Disk = data × 1.25 ÷ 0.70; workers = disk ÷ 120 TB, rounded up.

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.

Example 2IntermediateHealthcare · NameNode

A hospital that stores millions of small files

Problem statement

A hospital chain stores imaging metadata and report PDFs: 4 lakh files a day, average 300 KB each, kept 5 years. Estimate the NameNode heap at about 150 bytes per file and per block, and compare with packing each day into 1 GB SequenceFiles (Lesson 10.1).

Input
4,00,000 files/day × 300 KB · 5 years
Expected output
small files: 204 GB heap; packed: 0.26 GB heap

Approach

  1. Small files: 1 block each → 2 objects per file.
  2. Packed: day size ÷ 1 GB files, 8 blocks each.
  3. Heap = objects × 150 B.

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.

Example 3IntermediateE-commerce · compute

Will the sale-day report finish in time?

Problem statement

On a sale day an e-commerce company must process 45 TB of clickstream between midnight and 3 AM. Each 4 GB container processes about 25 MB/s. The cluster has 30 workers with 30 containers each. Does it fit, and how much of the cluster does it use?

Input
45 TB · 3 hours · 25 MB/s per container · 900 containers
Expected output
needs 175 containers at once, has 900 -> 19% of the cluster

Approach

  1. Container-seconds = MB ÷ MB/s.
  2. Concurrent containers = container-seconds ÷ window seconds.
  3. Compare with 30 × 30.

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.

Example 4AdvancedGovernment · growth

Five years of a welfare scheme's data

Problem statement

A state welfare scheme stores 300 GB a day (after Parquet compression) and grows 40% a year. Data is kept forever. With replication 3, 25% temp space and 70% fill, how many 96 TB workers are needed at the end of each of the next 5 years?

Input
300 GB/day in year 1 · +40%/year · keep forever
Expected output
year 1:   109.5 TB kept ->   7 workers
year 2:   262.8 TB kept ->  15 workers
year 3:   477.4 TB kept ->  27 workers
year 4:   777.9 TB kept ->  44 workers
year 5:  1198.5 TB kept ->  67 workers

Approach

  1. Each year adds 365 × that year's daily volume.
  2. Accumulate, then apply copies, temp and fill.
  3. Round up per year.

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.

9 Quiz and revision

Check yourself

Quick revision

Lesson 12.3 in one screen

  • Storage: raw/day × compression ratio × retention days × copies (3, or about 1.5 with EC) × 1.25 temp ÷ 0.70 fill × growth.
  • Workers = disk needed ÷ disk per node, rounded up. Example: 2 TB/day, 3 years → 3,812.9 TB → 40 workers (22 with cold data on RS-6-3).
  • NameNode heap ≈ (files + blocks) × 150 B; keep files large. 2.2 M files + 4.5 M blocks ≈ 0.9 GB of objects; give the NameNode generous headroom.
  • Compute: containers at once = work (container-seconds) ÷ window seconds; example 291 vs 1,200 available.
  • Per node: RAM − reserve (OS, DataNode, NodeManager) = YARN pool; balance memory per vcore (Lesson 11.4).
  • Masters: 2 NameNodes, 3 JournalNodes, 3 ZooKeeper, 2 ResourceManagers, JobHistory, plus edge nodes.
  • Benchmark real hardware: our laptop lab wrote 113 MB/s with one task and saturated near 210 MB/s total.

Interview and viva questions

How do you calculate the size of a Hadoop cluster?

Start from storage: daily data volume × compression ratio × retention period × replication factor (3, or about 1.5 with erasure coding), add 20–30% for temporary and shuffle data, divide by the target disk fill (around 70%) and add growth. Divide by usable disk per worker to get the number of workers. Then check compute against the batch window, size the NameNode heap from the expected number of files and blocks, and add masters and edge nodes.

How much memory does a NameNode need?

Roughly 150 bytes per file, directory and block object as a rule of thumb, often summarised as about 1 GB of heap per million blocks. The real driver is the number of objects, so a cluster full of small files needs far more heap than one with the same bytes in large files. Leave plenty of headroom for growth and garbage collection.

What is TestDFSIO?

A benchmark in the Hadoop MapReduce tests jar. Each map task writes or reads one file in HDFS, and the job reports throughput per task and average I/O rate. It measures the storage path end to end (client, DataNodes, disks, network) and is used before and after hardware or configuration changes.

Why keep HDFS disks below 70–80% full?

Jobs need temporary space for map output, staging and new data; the balancer needs room to move blocks; when a node or disk fails, its replicas are re-created on the others; and nearly full disks make DataNodes and NodeManagers unhealthy. Headroom is what keeps a failure from turning into an outage.

Is it cheaper to run Hadoop in the cloud?

It depends on utilisation. Steady, always-busy clusters are often cheaper on owned or reserved hardware; spiky or experimental workloads benefit from cloud clusters that are created for a job and deleted, with data kept in object storage. Compare the full cost: servers, power, space and staff on one side; compute hours, storage, data transfer and support on the other.

Practice problems

Sizing exercises. Write your assumptions first, then calculate.

P1Easy

Copies on disk

10 TB of data with replication 3 vs RS-6-3 erasure coding: how much disk does each use?

Input
10 TB
Expected output
replication 3: 30 TB   RS-6-3: 15.0 TB
Show solution and explanation
print("replication 3:", 10 * 3, "TB   RS-6-3:", 10 * 1.5, "TB")
replication 3: 30 TB RS-6-3: 15.0 TB

How it works: 30 TB vs 15 TB. Our lab measured the same 2:1 shape: 422 MB vs 235 MB (Lesson 7.3, RS-3-2 there).

P2Easy

Aggregate throughput

Our TestDFSIO run reported 61.82 MB/s per task with 3 writers and 34.99 with 6. What was the total in each case?

Input
per-task throughput × tasks
Expected output
185.5 209.9 MB/s
Show solution and explanation
print(round(3 * 61.82, 1), round(6 * 34.99, 1), "MB/s")
185.5 209.9 MB/s

How it works: About 185 and 210 MB/s: doubling the writers added only 13% because one disk was shared.

P3Easy

Compression saves workers

The UPI example stores 0.5 TB/day as Parquet+zstd. If it stored raw CSV (2 TB/day), how many workers would 3 years need?

Input
2 TB/day, no compression
Expected output
15252 TB -> 159 workers
Show solution and explanation
import math
disk = 2.0 * 1095 * 3 * 1.25 / 0.70 * 1.3
print(f"{disk:.0f} TB -> {math.ceil(disk / 96)} workers")
15252 TB -> 159 workers

How it works: 159 workers instead of 40: the file format is a sizing decision (Lesson 10.2).

P4Medium

Memory per vcore

A worker has 256 GB RAM and 32 cores. Reserve 32 GB and 2 cores for the OS and daemons. With 1 vcore per container, what container size uses memory and CPU evenly?

Input
224 GB, 30 vcores
Expected output
7.5 GB per vcore
Show solution and explanation
print(f"{224 / 30:.1f} GB per vcore")
7.5 GB per vcore

How it works: About 7.5 GB: smaller containers leave memory idle, bigger ones leave cores idle (Lesson 11.4).

P5Medium

Ingest bandwidth

0.5 TB of new data arrives every day and must be loaded in a 2-hour window with 3 replicas. What write bandwidth must the cluster sustain?

Input
0.5 TB × 3 in 2 hours
Expected output
218 MB/s across the cluster
Show solution and explanation
mb = 0.5 * 1024 * 1024 * 3
print(f"{mb / 7200:.0f} MB/s across the cluster")
218 MB/s across the cluster

How it works: About 218 MB/s, close to what our whole laptop lab could write. Forty production workers do this easily.

P6Medium

How many racks?

40 workers, 3 masters and 2 edge nodes, with at most 20 servers per rack. How many racks, and why spread masters across racks?

Input
45 servers, 20 per rack
Expected output
3 racks
Show solution and explanation
import math
print(math.ceil(45 / 20), "racks")
3 racks

How it works: 3 racks. Put the two NameNodes and the three JournalNodes in different racks so one rack failure can't take the quorum down.

P7Business problem

Own or rent?

Owning 40 workers costs ₹6 crore over 3 years including power and staff (illustrative). A cloud cluster of the same size costs ₹1,500 per node-hour (illustrative). Above what average number of busy hours a day is owning cheaper?

Input
₹6 crore / 3 years vs ₹1,500 × 40 nodes per hour
Expected output
break-even at 0.9 cluster-hours a day
Show solution and explanation
own_per_day = 6e7 / (3 * 365)
cloud_per_hour = 1500 * 40
print(f"break-even at {own_per_day / cloud_per_hour:.1f} cluster-hours a day")
break-even at 0.9 cluster-hours a day

How it works: About 0.9 hours a day with these made-up prices. Plug in real quotes before any decision; the shape of the calculation is what matters.

P8Advanced

A sizing function

Write size(raw_tb_day, ratio, days, copies) returning the number of 96 TB workers (25% temp, 70% fill, 30% growth). Check it against the UPI example.

Input
2.0, 0.25, 1095, 3
Expected output
40 20
Show solution and explanation
import math
def size(raw_tb_day, ratio, days, copies, node_tb=96):
    disk = raw_tb_day * ratio * days * copies * 1.25 / 0.70 * 1.3
    return math.ceil(disk / node_tb)
print(size(2.0, 0.25, 1095, 3), size(2.0, 0.25, 1095, 1.5))
40 20

How it works: 40 and 20. The 22 in the lesson keeps the last 90 days with 3 copies; putting everything on erasure coding would give 20.

Real-world scenario questions (asked in company interviews)

Sizing questions are common for experienced roles. Interviewers look for a method and stated assumptions, not a memorised number.

Sizing · methodExperienced

“We ingest 5 TB a day and keep it 2 years. How many nodes?”

The classic open question.

The interviewer is checking: a method with assumptions out loud.

Show a strong answer
  • Ask: format and compression, replication or EC, growth, node hardware.
  • Storage: 5 × ratio × 730 × 3 × 1.25 ÷ 0.7 × growth; divide by usable disk per node.
  • Then check compute against the processing window and NameNode heap against file counts.
NameNode · capacityExperienced

The NameNode needs a restart every few weeks: heap is full

Storage is only 40% used.

The interviewer is checking: objects vs bytes.

Show a strong answer
  • Heap tracks files and blocks, so check FilesTotal and BlocksTotal and the average file size per folder.
  • Fix the writers producing small files; compact old data (Lesson 7.5).
  • Short term: raise heap with GC tuning; long term: federation if one namespace is too big (Lesson 7.2).
Benchmarks · honestyFresher

“Our test cluster writes 200 MB/s. Is that good?”

A trainee ran TestDFSIO on three virtual machines.

The interviewer is checking: understanding what was measured.

Show a strong answer
  • Ask what is shared: if all VMs use one physical disk, adding writers won't add throughput.
  • Look at per-task vs total, and whether reads came from page cache.
  • Benchmark the real hardware with realistic file sizes and concurrency.
Planning · growthExperienced

Finance asks for a 3-year hardware budget

Data grows 40% a year and nobody deletes anything.

The interviewer is checking: retention and tiering as levers.

Show a strong answer
  • Model year by year with compounding growth; buy in phases, not all at once.
  • Propose levers: retention policies, better formats, erasure coding or archive storage for cold data.
  • Present a range with assumptions, and review it every quarter against real usage.