Interview's MateData Engineer
Interview's Mate

Data Engineer

SQL · Spark · Lakehouse · Streaming

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Data Engineer topics
Lesson 90/ 160
05. Data Lakehouses & Open Table Formats

Apache Hudi Architecture (Copy-on-Write vs Merge-on-Read, Indexing)

Choose Hudi CoW vs MoR storage and indexing strategies for upsert-heavy lakes.

AdvancedCoW · MoR · Indexing3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

Locate file group for a durable record key. Next, precombine newer/late duplicate events. Finally, compact, clean old instants, and monitor timeline.

Think of it like…

CoW replaces a whole edited page in the ledger; MoR keeps a stack of sticky-note corrections and periodically binds a new clean page.

Where you’ve seen it

A CoW UPSERT rewrites only file groups found by record_key=customer_id,order_id; an MoR write appends Avro/Delta logs and periodic compaction merges them into a new Parquet base.

Words you’ll hear

CoW
A Hudi table type that rewrites affected file groups so readers always access complete Parquet base files.
MoR
A table type that appends log blocks and later compacts them, trading read amplification for faster updates.
Indexing
Record/file-group lookup metadata-bloom, simple/global, bucket, or external-that controls upsert locate cost.
Operational boundary
An undersized record index causes slow bloom/key lookup, MoR leaves large log files and read amplification if compaction lags, and CoW rewrites huge Parquet files for a small hot-key update. Choose CoW for read-heavy bounded updates and MoR for write-heavy ingestion with scheduled compaction; size bucket/global indexes from key skew, monitor file groups/logs, and tune precombine ordering for late duplicates.

Visual diagram

Loading interactive diagram

Theory & deep dive

CoW: the working mechanism

Hudi tracks a table timeline and indexes record keys: copy-on-write rewrites affected base files on upserts, while merge-on-read writes log slices that readers merge with base files on demand.

Locate file group for a durable record key. Precombine newer/late duplicate events, then copy-on-write base or merge-on-read log; this exposes the state governed by Indexing.

Apache Hudi Architecture in one concrete design

A CoW UPSERT rewrites only file groups found by record_key=customer_id,order_id; an MoR write appends Avro/Delta logs and periodic compaction merges them into a new Parquet base.

Key takeaway: Hudi tracks a table timeline and indexes record keys: copy-on-write rewrites affected base files on upserts, while merge-on-read writes log slices that readers merge with base files on demand

Apache Hudi Architecture: failure mode and production response

An undersized record index causes slow bloom/key lookup, MoR leaves large log files and read amplification if compaction lags, and CoW rewrites huge Parquet files for a small hot-key update.

Choose CoW for read-heavy bounded updates and MoR for write-heavy ingestion with scheduled compaction; size bucket/global indexes from key skew, monitor file groups/logs, and tune precombine ordering for late duplicates. Track File-group updates as "portion of a large base rewritten for one batch", and make Log block count visible to the dataset owner.

Key takeaway: Choose CoW for read-heavy bounded updates and MoR for write-heavy ingestion with scheduled compaction; size bucket/global indexes from key skew, monitor file groups/logs, and tune precombine ordering for late duplicates.

How it works, step by step

Step 1 of 4
CoW

1. Index records

Locate file group for a durable record key. Hudi tracks a table timeline and indexes record keys: copy-on-write rewrites affected base files on upserts, while merge-on-read writes log slices that readers merge with base files on demand.

locate file group for a durable record key
Key numbers at this step
File-group updates
portion of a large base rewritten for one batch
MoR
A table type that appends log blocks and later compacts them, trading read amplification for faster updates.

When to use it & trade-offs

What it is

Hudi tracks a table timeline and indexes record keys: copy-on-write rewrites affected base files on upserts, while merge-on-read writes log slices that readers merge with base files on demand. A CoW UPSERT rewrites only file groups found by record_key=customer_id,order_id; an MoR write appends Avro/Delta logs and periodic compaction merges them into a new Parquet base.

Why it matters: An undersized record index causes slow bloom/key lookup, MoR leaves large log files and read amplification if compaction lags, and CoW rewrites huge Parquet files for a small hot-key update. Choose CoW for read-heavy bounded updates and MoR for write-heavy ingestion with scheduled compaction; size bucket/global indexes from key skew, monitor file groups/logs, and tune precombine ordering for late duplicates.

When to reach for it

  • Choose Hudi CoW vs MoR storage and indexing strategies for upsert-heavy lakes.
  • Choose CoW because it provides this capability: A Hudi table type that rewrites affected file groups so readers always access complete Parquet base files.
  • Keep evidence for File-group updates at "portion of a large base rewritten for one batch" so the last production stage-Maintain - compact, clean old instants, and monitor timeline-remains testable.

When to avoid or be careful

  • An undersized record index causes slow bloom/key lookup, MoR leaves large log files and read amplification if compaction lags, and CoW rewrites huge Parquet files for a small hot-key update.
  • Do not conflate MoR with CoW. The second concept contributes different behavior: A table type that appends log blocks and later compacts them, trading read amplification for faster updates.
  • Release only after this guardrail is in place: Choose CoW for read-heavy bounded updates and MoR for write-heavy ingestion with scheduled compaction; size bucket/global indexes from key skew, monitor file groups/logs, and tune precombine ordering for late duplicates.

CoW / MoR / Indexing - roles, limits, and operating cost

CoW
Best for: A Hudi table type that rewrites affected file groups so readers always access complete Parquet base files.

Strengths: A Hudi table type that rewrites affected file groups so readers always access complete Parquet base files. Hudi tracks a table timeline and indexes record keys: copy-on-write rewrites affected base files on upserts, while merge-on-read writes log slices that readers merge with base files on demand.

Watch out: An undersized record index causes slow bloom/key lookup, MoR leaves large log files and read amplification if compaction lags, and CoW rewrites huge Parquet files for a small hot-key update.

MoR
Best for: A table type that appends log blocks and later compacts them, trading read amplification for faster updates.

Strengths: A table type that appends log blocks and later compacts them, trading read amplification for faster updates. In this workflow it supports: Write - copy-on-write base or merge-on-read log.

Watch out: The operating cost is real: rising MoR logs require compaction.

Indexing
Best for: Record/file-group lookup metadata-bloom, simple/global, bucket, or external-that controls upsert locate cost.

Strengths: Record/file-group lookup metadata-bloom, simple/global, bucket, or external-that controls upsert locate cost. Its output can be checked with Precombine.

Watch out: Operating guardrail: Choose CoW for read-heavy bounded updates and MoR for write-heavy ingestion with scheduled compaction; size bucket/global indexes from key skew, monitor file groups/logs, and tune precombine ordering for late duplicates.

Interview signals & numbers to know

When this topic comes up

  • “Where is the failure boundary for CoW, and how would File-group updates reveal it?”
  • “Why is MoR distinct from this behavior: record/file-group lookup metadata-bloom, simple/global, bucket, or external-that controls upsert locate cost?”
  • Production clue: An undersized record index causes slow bloom/key lookup, MoR leaves large log files and read amplification if compaction lags, and CoW rewrites huge Parquet files for a small hot-key update.
  • Design probe: Choose CoW for read-heavy bounded updates and MoR for write-heavy ingestion with scheduled compaction; size bucket/global indexes from key skew, monitor file groups/logs, and tune precombine ordering for late duplicates.

Benchmarks & rules of thumb

File-group updates -
portion of a large base rewritten for one batch
Log block count -
rising MoR logs require compaction
Precombine -
one deterministic winner per record key and source ordering field

Common mistakes & follow-ups

Common interview mistakes

  • An undersized record index causes slow bloom/key lookup, MoR leaves large log files and read amplification if compaction lags, and CoW rewrites huge Parquet files for a small hot-key update.
  • Reporting success from a job exit code without checking File-group updates and Log block count.
  • Treating this example as complete without replay, rollback, or access boundaries: A CoW UPSERT rewrites only file groups found by record_key=customer_id,order_id; an MoR write appends Avro/Delta logs and periodic compaction merges them into a new Parquet base.

Likely interviewer follow-ups

  • How would you prove this contract instead of only checking that the command ran: A Hudi table type that rewrites affected file groups so readers always access complete Parquet base files.
  • What does the recovery plan do when this occurs? An undersized record index causes slow bloom/key lookup, MoR leaves large log files and read amplification if compaction lags, and CoW rewrites huge Parquet files for a small hot-key update.
  • When is CoW insufficient for Log block count, and what does adding MoR cost in File-group updates?
Interview tip: Lead with the data path and failure boundary: Hudi tracks a table timeline and indexes record keys: copy-on-write rewrites affected base files on upserts, while merge-on-read writes log slices that readers merge with base files on demand. Then make the answer operational: Choose CoW for read-heavy bounded updates and MoR for write-heavy ingestion with scheduled compaction; size bucket/global indexes from key skew, monitor file groups/logs, and tune precombine ordering for late duplicates.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Apache Hudi Architecture (Copy-on-Write vs Merge-on-Read, Indexing) with data engineer interview Q&A and hands-on practice.

Open Data Engineer Q&A →Machine Learning Q&A
Previous topic
Iceberg Features (Hidden Partitioning, Partition Evolution, Time Travel, Branching/Tagging)
Next topic
Schema Evolution & Schema Enforcement in Lakehouses