In this article
  1. Before you start
  2. Why interviewers ask this
  3. Processing 100,000 files on Hadoop from first principles
  4. The Staff-level answer
  5. The rubric
  6. Three variants of this question
  7. Common mistakes
  8. Follow-up questions
  9. Sources

Before you start

This question belongs to the machine learning operations (MLOps) interview questions path, and the storage and pipelines around it are covered in designing the data platform under machine learning. If the machine-learning side is new, start with machine learning algorithms.

Why interviewers ask this

A candidate who answers "spread the files over more servers" misses the cost that decides this question. The question tests whether you see that many small files cost more in tasks and in metadata than the same bytes held in a few large files. Candidates report it in data-engineering and system-design rounds; no public source ties it to one company.

A weak answer lists tools. A strong answer asks the file size first, counts the tasks that one file per task would create, and names the NameNode as the place where file count turns into memory. A Staff-level answer adds the follow-up an interviewer asks next, what happens at 100 million files, and fixes the problem where the files are written rather than where they are read.

Processing 100,000 files on Hadoop from first principles

NameNode
The NameNode is the Hadoop Distributed File System (HDFS) master server that keeps the metadata of every file and block in memory and tells clients which DataNodes hold each block. Its memory use grows with the number of files and blocks, not with the number of bytes stored.
Input split
An input split is the slice of input data that one map task reads, and by default the framework creates one map task per input split. With the default FileInputFormat, a file smaller than a block is a split of its own, so many small files mean many splits and many tasks.
Small-files problem
The small-files problem is the loss of speed and memory that comes from storing and processing very many files far smaller than the HDFS block size. Each file adds a metadata object on the NameNode and a map task to the job, while holding very little real work.

In plain words

Imagine a mail room that must deliver many postcards, an illustrative 100,000 of them. Every courier pays a fixed cost to take a job: sign in, load a bag, walk out. If each courier carries one postcard, the sign-in takes longer than the walk. If each carries a full bag, the sign-in is a small part of the trip.

A map task is the courier and a small file is the postcard. The analogy breaks in one place: couriers do not also write every postcard into a central ledger, but the NameNode does register every file.

In one precise sentence: processing many files on Hadoop is cheap only when the files are grouped into units near the block size.

The reason is that task startup and NameNode memory are paid per file, not per byte.

Packing small files cuts 100,000 tasks to 782 near the dataFlow of the answer: 100,000 small files make 100,000 map tasks and 200,000 NameNode objects, combining them gives 782 splits, and the tasks run on the servers that hold the blocks.100,000 smallfilesabout 1 MBeach100,000 maptasksone per file200,000 NameNode objectsfiles plus blocks782 combinedsplits128 MB; objectsunchangedTasks nearthe dataon the blockserversDiagram: Interview Clozo, CC BY 4.0 ·interview.clozo.ai/blog/how-will-you-process-100-000-files-across-multiple-servers.html

Packing small files cuts the work from 100,000 tasks to 782, and the tasks still run where the data sits.CC BY 4.0 — source: How will you process 100,000 files across multiple servers on Hadoop?
Step-by-step description
  1. 100,000 files make 100,000 map tasks.
  2. The NameNode holds 200,000 objects.
  3. Combined splits leave 782 map tasks.
  4. Tasks run where the blocks are.
  • One map task per file means 100,000 map tasks for 100,000 small files.
  • The NameNode holds about 200,000 objects in memory for the 100,000 files.
  • Combining files into 128 MB splits leaves about 782 map tasks.
  • Tasks run on the servers that hold the data blocks.

Step 1: One map task per file means 100,000 tasks

One map task per file means 100,000 map tasks for 100,000 small files (illustrative count).1 The MapReduce tutorial says the framework creates one map task per input split. FileInputFormat, the default, never puts two files in one split, so each small file becomes its own split (Tom White, Cloudera).

Take 100,000 files of 1 MB each, which is 100 GB in all (illustrative sizes).1 Assume 10 servers with 8 containers (task slots) each, 2 seconds to start a task and a read speed of 50 MB per second (all illustrative). Reading one 1 MB file then takes 20 milliseconds, so the 2 seconds of startup is 100 times the real work and about 99% of each task's time.1 The 80 slots run the 100,000 tasks in 1,250 waves, an estimated 2,525 seconds, about 42 minutes.1

Input: 100,000 files (illustrative). Output: 100,000 tasks. You now know the first cost is tasks; the second is memory.

Step 2: The NameNode counts files, not bytes

The NameNode holds about 200,000 objects in memory for the 100,000 files, about 30 megabytes1. The HDFS design guide and Tom White's small files post describe the cause: the NameNode keeps file and block metadata in memory, and a common rule of thumb is about 150 bytes per file, directory or block object.

Each 1 MB file is one file object and one block object, so 100,000 files make 200,000 objects, or 30,000,000 bytes (illustrative).1 That is small: this many files do not break a NameNode. The same arithmetic at 100 million files gives 30 GB, and that is where the real problem starts.1

A small file does not waste a whole block on disk, because a block uses only the bytes it holds. The waste is metadata and tasks. Adding servers adds DataNodes, not NameNode memory, so it does not fix this.

Input: the file count. Output: bytes of metadata.

Step 3: Combine small files into splits near the block size

Combining files into 128 MB splits leaves about 782 map tasks (illustrative inputs)1. CombineFileInputFormat packs many files into each split (Javadoc), so the 100 GB make 782 splits instead of 100,000.1 One map task per file gives 100,000 map tasks; the combined job gives 782, a cut of about 99%.1

The class is abstract, so in practice you use CombineTextInputFormat and set the maximum split size, mapreduce.input.fileinputformat.split.maxsize, to 128 MB. Without a maximum, blocks from the same rack are combined into one huge split (Javadoc). Locality is only partial.

This changes how the job reads, not how the files are stored, so the 200,000 NameNode objects remain. To fix both problems, pack the files themselves. A SequenceFile (file name as key, contents as value) cuts both the NameNode objects and the map tasks, because tasks split the one large file. A Hadoop Archive (HAR), read as a har:// file system (Hadoop Archives guide), cuts NameNode memory only; a job reading a HAR still gets one input per archived file (Tom White, Cloudera). Upstream compaction into block-sized files fixes both.

In an illustrative model, packing 100 GB into block-sized units cuts tasks from 100,000 to 782 and an estimated 2,525 seconds to 45.6 seconds.1
QuantityOne file per taskPacked into 128 MB units
Data size100 GB100 GB
HDFS files plus blocks200,0001,564
NameNode memory at 150 bytes per object30,000,000 bytes234,600 bytes
Map tasks100,000782
Waves on 80 slots1,25010
Estimated wall time2,525 seconds45.6 seconds
Combining files cuts 100,000 map tasks to 782Bar chart of map tasks for 100 GB held in 100,000 files of 1 MB: one task per file gives 100,000 tasks, while combined 128 MB splits give 782 tasks.Map tasks (tasks)050,000100,000Task per fileCombinedHow the job reads the files100,000782Diagram: Interview Clozo, CC BY 4.0 ·interview.clozo.ai/blog/how-will-you-process-100-000-files-across-multiple-servers.html
Combining files into block-sized splits removes about 99% of the map tasks.CC BY 4.0 — source: How will you process 100,000 files across multiple servers on Hadoop?
Text description of the diagram
  • One map task per file gives 100,000 map tasks.
  • Combining files into 128 MB splits leaves about 782 map tasks.

Step 4: Tasks run on the servers that hold the data

Tasks run on the servers that hold the data blocks, because the scheduler moves computation to the data. The HDFS design guide states the principle: moving computation is cheaper than moving data.

That is why you do not copy all the files to one server and fan out from there. The files already sit on DataNodes across the cluster, and each task reads mostly blocks stored on its own node or rack, since combined splits give partial locality. With an illustrative 782 tasks on 80 slots the job runs in 10 waves, about 45.6 seconds in the same illustrative model, against 2,525 seconds before.1

The number of reducers is a separate setting, chosen from the size of the output, not from the file count. Compare this batch design with the other modes in batch vs streaming vs real-time inference; general cluster scheduling is covered in Kubernetes for machine learning infrastructure.

Input: 782 splits (illustrative). Output: the job's results.

Knowing it is half the job. Saying it is the other half.

Interview Clozo is an AI interview copilot for real interview rounds: it hears the question and puts a strong answer on your screen, and you say it in your own words. See the features or how it works.

Start Free Trial →

The Staff-level answer

Interviewer asks

How will you process 100,000 files across multiple servers on Hadoop?

A strong answer

First I ask how big the files are, because size matters more than count. If they are small, say about 1 MB each, one task per file would mean 100,000 tasks, and task startup would dwarf the real work. So I compact them into files near the block size upstream, or read them with CombineTextInputFormat and the maximum split size set to 128 MB, which gives a few hundred splits. The scheduler runs those tasks on the servers holding the blocks. At this count the NameNode is fine, about 30 MB of metadata by the usual rule of thumb, but at 100 million files it would not be, so I fix it at the source.

What makes it Staff-level: it asks the file size first, separates the task cost from the NameNode cost, and moves the fix to where the files are written.

The rubric

A strong answer asks the file size, counts tasks and metadata, and fixes the source of the small files; the rows show what separates each level.
DimensionWeak answerStrong answerStaff answer
CorrectnessSays "use more servers"Compacts or combines files, then schedules near the dataSeparates the task cost from the NameNode cost
DepthNames tools onlyCounts one task per fileComputes tasks, metadata and waves from the file size
Trade-offsNoneCompares the combine input format with compactionFixes the writer and says when small files can stay
CommunicationLists tools in no orderStates the answer first, then the numbersOpens with the file-size question, ends with the follow-up
Follow-up readinessStuck at 100 million filesQuotes the memory rule of thumbKnows what the rule leaves out and checks the real cluster

Three variants of this question

What if the 100,000 files are 10 GB each?

Then the file count stops being the issue. Each file spans many blocks, splits follow blocks, and every task has real work, so no compaction is needed. Total bytes and block count decide the cost instead.

How would you process 100 million small files?

The NameNode becomes the limit: about 30 GB of metadata by the rule of thumb in Step 2. Compact at ingestion, use SequenceFile or HAR packing, and consider HDFS Federation, which splits the namespace across several NameNodes. Reading with a combine input format alone will not remove the metadata.

How would you process the files with Spark instead of MapReduce?

The principle is the same: many tiny partitions waste time on scheduling, so read the data in fewer, larger partitions. The setting names differ by engine, so state the principle first and name the engine's setting second: in Spark, spark.sql.files.maxPartitionBytes controls how much file data one partition reads, and coalesce merges partitions after the fact (Spark Structured Query Language (SQL) performance-tuning guide).

Common mistakes

  • "I'll add more servers." (wrong) More DataNodes add disk and compute but not NameNode memory, and they do not cut per-file overhead. (right) "I'll cut the number of files and tasks first."
  • "Each small file wastes a full 128 MB block." (wrong) A block uses only the bytes it holds. (right) "The waste is NameNode metadata and task startup."
  • "One map task per file is fine." (wrong) With 1 MB files the startup is about 99% of each task's time in the example above. (right) "I group files into splits near the block size."
  • "This many files will overload the NameNode." (wrong) That is about 30 MB by the rule of thumb. (right) "By the rule of thumb, the NameNode only becomes the limit in the tens of millions of files, and that rule dates from 2009 hardware, so I check the real heap."

Follow-up questions

What is the small files problem in Hadoop?

It is the slowdown and memory cost of very many files much smaller than a block: each file adds a NameNode object and a map task while holding little data. The usual fixes are combining, packing and upstream compaction.

Why is one map task per small file slow?

Each task pays a fixed startup cost before it reads anything. When the file is tiny, the startup cost is most of the task's time, and the cluster spends its slots starting tasks instead of processing data.

How does CombineFileInputFormat reduce map tasks?

It packs many files into each input split, so the framework creates one task per packed split rather than one per file; in practice you use CombineTextInputFormat and set the maximum split size. It does not change how the files are stored, so the NameNode still holds one object per file and block.

How much NameNode memory do 100 million files need?

By the rule of thumb of about 150 bytes per object, with a file object and a block object per small file, it is about 30 GB. Treat that as an estimate and check it against a real NameNode.

What is the difference between a SequenceFile and a Hadoop archive?

A SequenceFile stores each small file as a record, name as key and contents as value, inside one large file that tasks can split, so it cuts both NameNode objects and map tasks. A Hadoop Archive cuts NameNode metadata but not the task count: a job reading it still gets one input per archived file (Tom White, Cloudera; Hadoop Archives guide). Small files also arise when features are written in many tiny pieces, as discussed in feature store design.

Key takeaways
  • One map task per small file means a task for every file, and task startup dominates.
  • The NameNode pays memory per file and per block, not per byte; 100,000 files is about 30 MB, 100 million is about 30 GB.
  • Pack files into units near the block size: combine at read time, or compact at the source.
  • Tasks run where the blocks are, so do not copy the files to one server first.
  • More servers do not fix per-file overhead.

Sources

  1. HDFS Architecture — Apache Hadoop documentation, 26 Oct 2026
  2. MapReduce Tutorial — Apache Hadoop documentation, 26 Oct 2026
  3. CombineFileInputFormat (Javadoc) — Apache Hadoop documentation, 26 Oct 2026
  4. Hadoop Archives Guide — Apache Hadoop documentation, 26 Oct 2026
  5. The Small Files Problem — Cloudera blog (Tom White), 26 Oct 2026
  6. Spark SQL performance tuning — Apache Spark documentation, 26 Oct 2026