SD System Design In Depth
0%
lesson system-designstorage-engines

End-to-end checksums

Module 2.3: Storage Engine Internals & Blob Systems Updated Sep 17, 2026
📄 Cheat Sheet
AWS re:Invent 2023 - Get started with checksums in Amazon S3 for data integrity checking (STG350)
AWS Events AWS re:Invent 2023 - Get started with checksums in Amazon S3 for data integrity checking (STG350) Watch on YouTube ↗

AWS explains how S3 computes and verifies checksums end to end, from client upload through storage and back, with supported algorithms: the exact practice this unit teaches.

0:00 / --:--

Under the Hood: Silent Data Corruption & Bit Rot

Modern storage systems do not fail merely by crashing or throwing I/O errors. Physical hardware experiences Silent Data Corruption (Bit Rot): firmware bugs, misdirected or lost writes, media errors, cable noise and memory bit flips (for example from cosmic rays hitting DRAM) corrupt data without returning an operating system error code. High-durability systems implement End-to-End Checksums: CRCs to catch accidental corruption, and cryptographic hashes where tampering matters.

The End-to-End Verification Pipeline

flowchart TD Client["Client SDK"] -->|"1. Compute CRC32C / MD5: '0x8A4B291F'"| Gateway["API Gateway"] Gateway -->|"2. Verify Checksum during ingest"| ChunkServer["Storage Node"] ChunkServer -->|"3. Write Block + Checksum Footer to Disk"| Disk[("NVMe / HDD Media")] subgraph Scrubber ["Background Scrubbing Daemon"] Cron["Weekly Scrubbing Worker"] -->|"4. Read Block & Recalculate CRC32C"| Verifier{"Checksum Matches Footer?"} Verifier -->|"Yes"| OK["Data Valid"] Verifier -->|"No (Bit Rot Detected!)"| Heal["Trigger Auto-Repair: Rebuild Chunk via Erasure Coding"] end

Under the Hood: Checksum Algorithms & Hardware Acceleration

  • CRC32C (Castagnoli): The gold standard for storage engines. Modern Intel and AMD x86 CPUs feature dedicated hardware instructions (SSE 4.2 CRC32) capable of calculating CRC32C at several GB/s per core for a single stream, and 20+ GB/s per core with interleaved multi-stream implementations.
  • Block-Level Checksum Footers: Instead of computing one checksum per 100GB file, storage engines compute a 32-bit checksum for every 4KB block. This enables immediate corruption detection during random reads without scanning the entire file.
  • Continuous Background Scrubbing: A low-priority background daemon continuously reads cold disks sequentially, re-verifies block checksums, and invokes erasure coding repair before a second disk failure causes catastrophic data loss.

Worked example: an upload verified end to end

  1. The client computes CRC32C of the 64 MB file while reading it from local disk and sends it in x-amz-checksum-crc32c.
  2. The service computes the checksum of the bytes it received and rejects the PUT if it does not match; the client retries.
  3. Each stored shard carries its own block-level checksums, verified when written and on every read.
  4. On download the service returns the stored checksum, and the client verifies the bytes it received.
  5. Background scrubbers re-read data at rest, and a bad block is rebuilt from replicas or parity before it is needed.

Overhead of block checksums

1 PB stored in 4 KB blocks is about 244 billion blocks. At 4 bytes of CRC32C each, that is about 1 TB of checksums, roughly 0.1% overhead. With hardware CRC instructions, a single core can checksum many gigabytes per second, so the CPU cost is small compared to the I/O.

Choosing an algorithm

AlgorithmSizeSpeedDetectsTypical use
CRC32C32 bitsVery fast with SSE4.2 or ARMv8 CRCAll burst errors up to 32 bits, most random errorsRocksDB blocks, iSCSI, ext4 metadata, S3 option
xxHash64 or XXH364 bitsVery fast in softwareAccidental corruption, lower collision rateRocksDB option, many caches
MD5128 bitsModerateAccidental corruption; broken against attackersLegacy ETags and Content-MD5
SHA-256256 bitsSlower without hardware supportAccidental and malicious changesContent addressing, ZFS dedup, S3 option

Where silent corruption comes from

  • Memory bit flips: the reason servers use ECC RAM; checksums computed after a flip will faithfully protect the wrong data, so compute early.
  • Firmware bugs: misdirected writes (right data, wrong place) and phantom writes (acknowledged but never written).
  • Defective CPUs: Google and Meta have both published on "silent data corruption" from faulty cores that compute wrong results.
  • Media decay: latent sector errors on disks that are only discovered when read, which is why scrubbing matters.
Check yourself Question 1 of 3
Per-block checksums recall
From: Under the Hood: Checksum Algorithms & Hardware Acceleration

Why do storage engines keep a checksum for every 4 KB block rather than one checksum per large file?

Key Takeaways

Silent bit rot corrupts bytes on physical media without triggering OS or hardware controller errors.
CRC32C is hardware-accelerated by modern CPU instruction sets, delivering several GB/s per core for a single stream and over 20GB/s per core with interleaved multi-stream implementations.
Continuous background scrubbers detect bit flips early and trigger automatic erasure-code repairs.
Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue