Apache Hudi Architecture (Copy-on-Write vs Merge-on-Read, Indexing)
Choose Hudi CoW vs MoR storage and indexing strategies for upsert-heavy lakes.
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
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.
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.
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.
How it works, step by step
Step 1 of 41. 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.
- 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
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.
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.
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
UPSERTrewrites only file groups found byrecord_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?
Knowledge check
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.