BharatSearch: a search engine on four laptops
For their hackathon, Riya and Kabir build “BharatSearch”, a search engine for college websites. A crawler downloads pages, a program builds an index of words, and a web page answers searches. It works beautifully for 500 colleges. Then the judges say: “Nice. Now do it for every website in India.” Riya opens a calculator, and goes quiet.
Sir, billions of pages won't fit on any disk we have. And even if they did, building the index would take months.
This is almost exactly the problem web search companies faced around 2003. The web was exploding. They needed to store it, process it every few days, and do it on thousands of cheap machines that kept breaking.
Couldn't they just split the pages over many machines with a script? Machine 1 gets URLs starting with A, machine 2 with B…
People did. And then a machine died in the middle of the night, and someone had to find which pages were lost, rerun the script, fix the split when they added machines… Every team was writing the same messy plumbing again and again.
So the real problem wasn't search. It was store huge data, process it in parallel, and survive failures, without every programmer becoming a distributed-systems expert.
Exactly, Riya. That problem is what Hadoop was built to solve. Today you'll pin it down precisely, see why the tools of that time couldn't do it, and then answer the question every student asks me: is Hadoop still worth learning in 2026?
The problem Hadoop solved
By the early 2000s, organisations needed to store and process data sets far larger than any single machine (hundreds of terabytes to petabytes of web pages, logs and clicks) economically, using clusters of commodity servers. This required: (1) scalable, reliable distributed storage that keeps working when disks and nodes fail; (2) parallel batch processing that runs close to the data; (3) automatic fault tolerance for long-running jobs; and (4) a simple programming model that hides distribution, so ordinary developers can write jobs. Apache Hadoop is an open-source framework that provides these: HDFS for storage, MapReduce for processing and, from version 2, YARN for resource management.
Data became too big for one computer. Companies needed a way to spread it over thousands of cheap machines, crunch all of it in parallel, keep going when machines break, and let normal programmers write the code without worrying about any of that. Hadoop is the free, open-source software that does exactly this.
Words you'll meet in this lesson
The four requirements, and Hadoop's answer
| Store data bigger than any machine | HDFS: files split into blocks spread over many nodes |
|---|---|
| Survive failures of cheap hardware | Replication (3 copies), heartbeats, automatic re-replication and task retries |
| Process all of it in parallel, fast | MapReduce: many tasks at once, each next to its data (data locality) |
| Let ordinary programmers write jobs | Write two functions, map and reduce; the framework handles everything else |
| And keep it affordable | Runs on commodity servers; free, open-source licence (Apache 2.0) |
The problem at three levels
Beginner The wedding caterer
- Cooking for 50 guests: one kitchen, one cook. Easy.
- Cooking for 50,000 guests: you need many kitchens, many cooks, a way to split the menu, a way to replace a cook who falls sick, and a head chef who coordinates it all.
- Building that system from scratch for every wedding would be madness. A catering company has it ready: you just give the recipe.
- Hadoop is that catering company for data. You give the recipe (map and reduce); it brings the kitchens (cluster) and the coordination.
Intermediate Why the usual tools of 2003 didn't fit
- Big databases needed data cleaned into tables first, scaled up rather than out, and cost a lot per TB in licences and hardware.
- Central storage (SAN/NAS) held a lot, but every server pulled data across the network from one place: the network became the bottleneck.
- Supercomputing (MPI) was fast, but programmers had to handle splitting data, moving it and recovering from failures themselves.
- Home-grown scripts (manual sharding) worked until a machine died or a new one was added, then needed manual repair.
Advanced The design bets Hadoop made
- Throughput over latency: read whole files fast in large sequential chunks; don't optimise for small random reads or instant answers.
- Write once, read many: files are written once and appended to, not edited in the middle. This keeps replication simple.
- Move computation to data instead of pulling data to a central place.
- Failure is normal: handle it in software, so hardware can be cheap.
- Simple, restricted programming model: by limiting what a job can express (map then reduce), the framework can split, schedule and retry automatically.
- These bets are also why Hadoop is not good at some things: low-latency queries, many small files, and fast iterative jobs. Spark and other tools later filled those gaps.
Exam tip: For “What problems does Hadoop solve?” list the four requirements (scalable storage, parallel processing, fault tolerance, simple programming model), add low cost (commodity hardware, open source), and map each to a component (HDFS, MapReduce, replication/retries, YARN in Hadoop 2).
The options in 2003, compared
| Big RDBMS / warehouse | SAN + servers | HPC with MPI | Home-grown scripts | Hadoop | |
|---|---|---|---|---|---|
| Scales by | Bigger machine | Bigger storage box | More nodes | More nodes | More commodity nodes |
| Cost at petabytes | Very high | Very high | High (special hardware) | Low hardware, high people cost | Low |
| Raw, messy data | Must be loaded into tables first | Yes | Yes | Yes | Yes: store first, decide structure later |
| Failures | Hardware redundancy | Hardware redundancy | Programmer's problem | Manual repair | Automatic, in software |
| Data locality | Inside one machine | No: data pulled over network | Programmer's problem | Sometimes | Built in |
| Programming | SQL: easy | Any | Hard | Messy | map + reduce (later SQL via Hive) |
Is Hadoop still relevant in 2026? An honest answer
Still running
Many banks, telecoms, government bodies and large enterprises still run on-premises Hadoop clusters (HDFS, YARN, Hive), often for years of historical data and compliance.
Jobs existPartly replaced
Classic MapReduce jobs have largely been replaced by Spark (and Hive on Tez). New cloud projects often store data in object storage (S3, GCS, ADLS) instead of HDFS.
Know the shiftIdeas everywhere
Blocks, replication, data locality, master–worker, shuffle and YARN-style scheduling are the foundations of Spark, Kafka, cloud data platforms and lakehouses.
Concepts transferInterviews and migrations
Data engineering interviews still ask about HDFS, MapReduce and YARN, and many current projects are migrations from Hadoop, which need people who understand it.
Career valueLearn Hadoop as the foundation, not the destination. Once you understand HDFS, MapReduce and YARN, Spark, Hive, cloud data warehouses and lakehouse tables become much easier, because they solve the same problems with the same ideas. This course ends with exactly that bridge (Module 13).
Scaling BharatSearch by hand, and where each step hurts
Too big for one disk: split by a rule
A hash spreads URLs evenly over 4 machines. Every program that reads or writes a page must know this rule. That is manual sharding.import zlib def machine_for(url, machines): return zlib.crc32(url.encode()) % machines # a stable hash of the URL print(machine_for("https://iitb.ac.in", 4), machine_for("https://coep.org.in", 4))2 1Add a fifth machine
Now
With modulo hashing, about 80% of the pages must be moved when going from 4 to 5 machines (you'll measure it in the code below). Someone has to write and run that migration.% 5instead of% 4. Most URLs suddenly belong to a different machine.A disk dies at 2 am
Machine 3's disk fails. A quarter of the pages are gone, and the indexing job that was reading them crashes.
No copies, no automatic detection, no retry. The team re-crawls those pages and re-runs the whole job by hand.Build the index in parallel
Kabir writes a script that starts the indexer on each machine, waits, collects results and merges them.
He is now writing a scheduler, a progress tracker and a merge step: the same distributed plumbing every team rebuilds. Hadoop's MapReduce provides all of it.The realisation
The interesting code (parse a page, count words) is 50 lines. The plumbing (splitting, copying, retrying, merging) is thousands.
Hadoop's promise: you write the 50 lines. Storage, splitting, placement, parallelism and recovery come from the framework, tested on clusters of thousands of nodes.
Growing from 1 machine to 40: what the team sees, and what is really happening
Follow BharatSearch as the data grows. Left: the team's chat and screens. Right: the machines and the data.
- Small data, one laptop: the index is built in 20 minutes. Life is good.
- The crawl reaches 50 TB. Kabir splits it over 4 machines by hashing each URL.
- At 2 am a disk fails. A quarter of the pages are gone and the indexer crashes at 71%.
- Adding a fifth machine forces most data to move. Riya's home-made retry script keeps growing.
- Arjun Sir's advice: store pages in HDFS and express the indexing as map and reduce.
- On 40 nodes the job finishes despite two node failures, with no data lost. The plumbing code is gone. (Numbers are illustrative.)
- All data on one laptop. No distribution, no problems.
- Four machines, each holding a quarter of the pages. Exactly one copy of each page.
- m3's disk fails: its quarter of the pages is simply gone, and the job depending on it fails.
- Adding m5 changes the hash rule, so most pages must move to new homes. All of this is done by hand.
- With Hadoop, the framework takes over storage, replication, scheduling, retries and merging. The team writes only map and reduce.
- Two of 40 nodes die during the job. Other replicas are read and the lost tasks re-run. The job completes.
Try it yourself: the four requirements in one cluster
Store a file, process it, and break a node while the job runs. Each step checks one of the four requirements Hadoop was built for.
The same problem, in many industries
1. Web search and crawling
The original problem: crawl and index the web. Hadoop grew out of an open-source web search project (Apache Nutch) and was scaled up at Yahoo! for its search data.
2. Clickstream and app logs
Shopping, food delivery and streaming apps record every tap. Storing all of it cheaply and analysing it in bulk (funnels, recommendations, A/B tests) is the same store-process-survive problem.
3. Telecom call detail records
A telecom operator with crores of users produces billions of call and data records. Regulation requires keeping them, and network planning needs them analysed: a classic Hadoop workload.
4. Banking risk and fraud analytics
Banks keep years of transactions for risk models and audits. Many built Hadoop data lakes so that raw data from many systems lands in one place before being modelled.
5. Science and government
Genome sequencing, satellite imagery and census-scale data share the same need: store huge data sets and run the same analysis on every part in parallel.
Examples are simplified and describe common patterns, not any one company's setup.
Manual sharding, and why it hurts
Before Hadoop, teams split data across machines with their own rules. This program spreads 10,000 URLs over 4 machines with a hash, then counts how many URLs would have to move if a fifth machine is added. Then try the challenges.
import zlib
def machine_for(url, machines):
return zlib.crc32(url.encode()) % machines
urls = [f"https://site{i}.in/page" for i in range(10000)]
before = {u: machine_for(u, 4) for u in urls}
after = {u: machine_for(u, 5) for u in urls}
moved = sum(1 for u in urls if before[u] != after[u])
print("URLs per machine (4):", [list(before.values()).count(m) for m in range(4)])
print(f"Adding a 5th machine moves {moved} of {len(urls)} URLs ({moved / len(urls):.0%})")zlib.crc32(url.encode()) % machinesA hash turns the URL into a number;% machinespicks a machine. The same URL always lands on the same machine.before = {u: machine_for(u, 4) for u in urls}A dictionary comprehension: for each URL, which of 4 machines owns it.moved = sum(1 for u in urls if before[u] != after[u])Count URLs whose owner changes when there are 5 machines instead of 4.
Hash sharding, one line at a time
Watch three URLs being assigned to machines with a hash, first with 4 machines and then with 5. See which ones change owner.
Worked examples: real problems, solved and traced in memory
Three calculations that explain why Hadoop had to exist: how big the data was, how likely a long job was to fail, and how much a bigger cluster would cost without one. Each runs live and is traced in memory.
How many machines just to store the crawl?
Problem statement
A search engine has 80 crore pages of about 60 KB each, and wants 3 copies for safety. Each machine in 2005 has 4 disks of 250 GB. How many machines are needed just for storage?
80 crore pages × 60 KB · ×3 · 4 × 250 GB per machine
Data: 45,776 GB, with copies: 137,329 GB Machines: 138
Approach
- Total size = pages × KB, converted to GB.
- Multiply by 3 copies.
- Divide by GB per machine and round 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.
How often does a 1,000-machine job fail without fault tolerance?
Problem statement
An indexing job runs on 1,000 machines for 8 hours. Each machine has about a 4% chance of failing in a year. Without automatic recovery, any failure kills the job. What is the chance the job completes?
1,000 machines · 8 hours · 4% per year
One machine fails during the job: 0.00365% Job completes with no failures : 96.4%
Approach
- Chance one machine fails during the job = 4% × (8 hours ÷ hours in a year).
- Chance all 1,000 survive = (1 − p)1000.
- Compare with a job that can retry: it almost always finishes.
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 storage vs a commodity cluster
Problem statement
A company must store 500 TB. Option A: an enterprise storage array at Rs 40,000 per usable TB. Option B: commodity servers with raw disk at Rs 2,500 per TB, using HDFS with 3 copies and 25% headroom, plus Rs 20 lakh for setup and staff training. Compare the costs. (Prices are illustrative.)
500 TB · A: Rs 40,000/TB · B: Rs 2,500/TB raw, ×3 ÷ 0.75 + Rs 20 lakh
A (storage array) : Rs 200 lakh B (Hadoop cluster): Rs 70 lakh for 2,000 TB raw A costs 2.9 times more
Approach
- A = 500 × 40,000.
- B raw TB = 500 × 3 ÷ 0.75; cost = raw × 2,500 + 20 lakh.
- Print both in lakh rupees and the ratio.
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 2.1 in one screen
- Early 2000s: web-scale data, far bigger than any machine, on cheap hardware that fails often.
- Four requirements: scalable storage, parallel processing, fault tolerance, simple programming. Plus low cost.
- Hadoop's answers: HDFS, MapReduce, replication + retries, map/reduce functions; YARN from Hadoop 2.
- RDBMS: scale up, costly, needs tables. SAN: network bottleneck. MPI: programmer handles failures. Scripts: manual repair.
- Manual hash sharding: changing N moves most data; no copies, no retries.
- Design bets: throughput over latency, write once read many, move code to data, failure is normal.
- Not for: low-latency lookups, many tiny files, fast iterative jobs.
- 2026: still running widely; MapReduce mostly replaced by Spark; concepts power modern platforms; migrations need Hadoop skills.
Interview and viva questions
What is Hadoop and what problem does it solve?
Apache Hadoop is an open-source framework for storing and processing very large data sets on clusters of commodity computers. It solves the problem of data that is too large for one machine: HDFS stores it reliably across many nodes, MapReduce (and other engines on YARN) process it in parallel near the data, and failures are handled automatically, so developers only write the processing logic.
Why couldn't traditional databases handle big data?
They mostly scale up on one large server, become very expensive per TB, need data to be modelled into tables before loading, and are optimised for transactions and indexed queries rather than scanning petabytes of raw, semi-structured data. Hadoop scales out on cheap hardware and stores raw data first (schema-on-read).
What does “write once, read many” mean in HDFS?
Files are written once (and may be appended to), but not modified in the middle. Most big data workloads write data once and then read it many times for analysis. This simplifies replication and consistency and allows very high read throughput.
Is Hadoop dead?
No, but its role has changed. Many enterprises still run HDFS, YARN and Hive, especially on-premises. Classic MapReduce has largely been replaced by Spark and Tez, and new cloud projects often use object storage and managed services instead of HDFS. The core ideas (blocks, replication, data locality, distributed processing) are used by almost every modern data platform, and migrations from Hadoop are common projects.
What are the limitations of Hadoop?
High latency (batch, not interactive), poor handling of many small files (NameNode memory), MapReduce writes intermediate results to disk which makes iterative algorithms slow, operational complexity, and security that must be configured separately (Kerberos, Ranger). Later tools such as Spark, Hive LLAP/Impala and cloud warehouses address several of these.
Practice problems
Small calculations and programs about scale, sharding and failure: the reasons Hadoop exists. The business problems are the arguments teams really had before adopting it.
How long to read the crawl?
A 400 TB crawl is read by one machine at 200 MB/s. How many days does one full read take?
400 TB · 200 MB/s
24.3 days
Show solution and explanation
print(round(400 * 1024 * 1024 / 200 / 86400, 1), "days")How it works: About 24 days for one pass. Rebuilding a search index weekly is impossible on one machine.
Same read on 1,000 machines
The same 400 TB is spread over 1,000 machines, each reading its share at 200 MB/s. How many minutes?
400 TB · 1000 × 200 MB/s
35.0 minutes
Show solution and explanation
print(round(400 * 1024 * 1024 / (1000 * 200) / 60, 1), "minutes")How it works: About 35 minutes. Parallel reading is the heart of Hadoop.
Which machine owns the key?
Using zlib.crc32(key.encode()) % 3, print which of 3 machines owns each of the keys "pune", "delhi", "goa".
["pune", "delhi", "goa"] · 3 machines
pune -> 2 delhi -> 2 goa -> 1
Show solution and explanation
import zlib
for k in ["pune", "delhi", "goa"]:
print(k, "->", zlib.crc32(k.encode()) % 3)How it works: Deterministic: the same key always goes to the same machine. That is the good part of hashing.
Share of keys that move
For 20,000 keys, compute the share that change machine when going from 10 to 11 machines with modulo hashing.
keys k0…k19999 · 10 → 11 machines
91% of keys move
Show solution and explanation
import zlib
keys = [f"k{i}" for i in range(20000)]
moved = sum(1 for k in keys if zlib.crc32(k.encode()) % 10 != zlib.crc32(k.encode()) % 11)
print(f"{moved / len(keys):.0%} of keys move")How it works: About 91%. Adding just one machine to ten moves almost everything. HDFS avoids this: the NameNode tracks each block's location individually, so adding nodes moves nothing until you choose to balance.
Chance of a failure during the job
A job uses 3,000 machines for 24 hours. Each machine fails with probability 3% per year. What is the chance that at least one fails during the job?
3000 machines · 24 h · 3%/year
21.9%
Show solution and explanation
p = 0.03 * 24 / (365 * 24)
print(f"{1 - (1 - p) ** 3000:.1%}")How it works: About 22%: roughly one run in five hits a failure. Without automatic recovery, each of those runs fails entirely and starts again.
Schema-on-read in miniature
Raw log lines are stored as they are. Only when reading, parse them into (city, amount) and sum per city, skipping broken lines.
["Pune,240", "Delhi,120", "bad line", "Pune,60"]
{'Pune': 300, 'Delhi': 120}Show solution and explanation
raw = ["Pune,240", "Delhi,120", "bad line", "Pune,60"]
totals = {}
for line in raw:
parts = line.split(",")
if len(parts) != 2 or not parts[1].isdigit():
continue
totals[parts[0]] = totals.get(parts[0], 0) + int(parts[1])
print(totals)How it works: Hadoop stores data first and applies structure when reading (schema-on-read). A database would reject the bad line at load time (schema-on-write).
When does the storage array become too expensive?
Data starts at 50 TB and doubles every year. A storage array costs Rs 40,000 per TB; the company's budget for it is Rs 5 crore. In which year does the array exceed the budget?
50 TB · ×2 per year · Rs 40,000/TB · budget Rs 5 crore
Year 5 : 1600 TB costs Rs 6.4 crore
Show solution and explanation
tb, year = 50, 0
while tb * 40_000 <= 5_00_00_000:
tb *= 2
year += 1
print("Year", year, ":", tb, "TB costs Rs", tb * 40_000 / 10**7, "crore")How it works: In year 5 (1,600 TB = Rs 6.4 crore). With exponential growth, scale-up storage stops being affordable within a few years. This calculation drove many companies to Hadoop.
Developer time saved by a framework
Each new data job needs about 2,000 lines of distribution code without a framework, and 0 with Hadoop. A developer writes about 100 tested lines a day and costs Rs 6,000 a day. The team builds 15 jobs a year. How much does the framework save per year?
2000 lines/job · 100 lines/day · Rs 6,000/day · 15 jobs
Saved: 300 developer-days = Rs 18 lakh a year
Show solution and explanation
days_per_job = 2000 / 100
saving = days_per_job * 6000 * 15
print(f"Saved: {days_per_job * 15:.0f} developer-days = Rs {saving / 1e5:.0f} lakh a year")How it works: 300 developer-days a year (illustrative numbers), before counting the bugs avoided. Frameworks pay for themselves in people's time.
Real-world scenario questions (asked in company interviews)
Questions interviewers ask to check that you understand why Hadoop exists, and where it fits today.
“Why do we need Hadoop when we have Oracle?”
The interviewer works at a bank that uses Oracle for its core systems. She asks why a bank would also run a Hadoop cluster.
The interviewer is checking: do you see Hadoop and databases as complementary, with different strengths?
Show a strong answer
- Oracle runs the core banking transactions: many small reads and writes, strict consistency, millisecond responses. Hadoop is not built for that.
- Hadoop holds years of raw data from many systems (transactions, logs, call-centre notes, app clicks) cheaply, and runs large batch analytics: risk models, fraud features, regulatory reports.
- Moving that history and analytics load off the database saves expensive database capacity and lets analysts work on raw data.
- Data typically flows from the databases into Hadoop (and results flow back) through ingestion pipelines.
Avoid saying: “Hadoop replaces Oracle.”
“Isn't Hadoop outdated? Why did you learn it?”
A startup interviewer who uses only cloud tools asks this, half-teasing.
The interviewer is checking: do you have a balanced, informed view of the ecosystem, rather than defending or dismissing it blindly?
Show a strong answer
- Agree partly: classic MapReduce is rarely used for new work, and many new platforms use cloud object storage and Spark or warehouse engines.
- But HDFS, YARN and Hive still run in many large companies, and migrations from them are active projects.
- More importantly, Hadoop taught you the fundamentals that every tool relies on: partitioning data into blocks, replication, data locality, shuffles, master–worker scheduling and failure handling. That makes Spark, cloud warehouses and lakehouse tables easier to understand and tune.
Avoid: claiming Hadoop is the best choice for everything, or saying you learned it only because the syllabus required it.
Should this workload go to Hadoop?
Three requests arrive: (a) the app needs to show a user's last 10 orders in under 100 ms; (b) analysts want to scan 3 years of clickstream to find drop-off patterns; (c) a dashboard needs results refreshed every 5 seconds. Which belong on a Hadoop cluster?
The interviewer is checking: can you match workloads to Hadoop's design (high throughput batch) and spot the ones that don't fit?
Show a strong answer
- (a) No: low-latency lookups of small records belong in a database or key–value store (or HBase, which runs on HDFS but is a different tool).
- (b) Yes: scanning years of raw data in parallel is exactly Hadoop's job (with Hive or Spark on YARN).
- (c) Mostly no: 5-second refreshes need stream processing (Kafka + Flink/Spark Streaming) or a real-time analytics database. Hadoop can hold the history behind it.
Avoid: “Put everything in Hadoop.”
“Let's write our own distributed storage. It's just splitting files.”
A confident teammate proposes a home-made system: split big files across servers with a hash of the filename, and a cron job to copy them for backup.
The interviewer is checking: do you know the hard problems that frameworks like HDFS already solve?
Show a strong answer
- Growth: hashing by N means adding servers moves most data; HDFS tracks each block's location and moves nothing unless asked.
- Failures: detecting dead nodes, knowing which data lost copies, re-copying in the right order, avoiding false alarms.
- Correctness: partial writes, corruption (checksums), consistent metadata, concurrent readers and writers.
- Locality and scheduling: processing next to the data needs integration with the compute layer.
- All of this is years of work; HDFS has been hardened on thousands of clusters. Build only what is truly unique to the business.
Avoid: a flat “never build anything”. The point is knowing the true cost.