Skip to content
Computing Medium #wal#redo#durability

Write-Ahead Log (WAL)

Log changes before mutating pages. Crash recovery just replays the log.

A free, animated write-ahead log (wal) you can read here or embed on any website, from Scrollchart.

Write-Ahead Log (WAL)

Write-Ahead Log (WAL)Log changes before touching pages. Crash recovery replays WAL from last checkpoint.WALon diskPagesbuffer poolDiskdata pagestxn startsLSN 1001BEGINLSN 1002UPDATE ordersLSN 1003COMMITfsyncLSN = Log Sequence Numberpage dirtied in RAMdirty pagenot yet on diskcheckpointdata pageflushed to diskcrash pointCRASHpages lost from RAMARIES RecoveryFind checkpointlast stable LSNRedo committedreplay WAL fwdUndo abortedroll back in-flightGroup CommitBatch WAL fsyncs across transactions: 10-100x throughput gain on HDD/SSDsynchronous_commit = off: async, sub-ms latency, up to 200 ms data loss on hard crashWAL record: sequential writes only, never random I/OFields: LSN, xid, relation OID, page no., before-image (undo), after-image (redo)Durability guarantee: COMMIT is safe once WAL record is fsynced. Data pages never need to be on disk before commit.

A transaction writes its intended changes to the WAL and fsyncs before touching pages. Crash and recovery: replay the WAL from the last checkpoint forward. Group commit and async commit tradeoffs annotated.

Good for

  • Database durability and crash-safety explainers
  • Postgres WAL configuration and tuning guides
  • Teaching ARIES recovery in database systems courses

Source & accuracy

This write-ahead log (wal) is an editorial illustration built to represent the concept accurately. Where it shows figures, they are typical or representative values chosen to make the relationship clear, not a single underlying dataset. The diagram and its explainer are reviewed and maintained centrally, and updated over time as understanding improves.

Writing changes to the log first

Write-ahead logging (WAL) is a crash recovery technique: before changing a page in the database, the change is written to a sequential log file on disk. The log is slower but safer than random writes to the main database file. If the system crashes, the log survives, and on restart the database replays every logged change to restore the state at the moment of the crash.

Why log-before-page is essential

If you wrote the page first and then the log, a crash between the two leaves the database in a corrupt state: a page is changed but the change is not logged, so it is lost on restart. WAL reverses this: the log is the source of truth. The in-memory cache can be lost safely because the log has a durable copy. Most databases (PostgreSQL, MySQL InnoDB, SQLite) use WAL for durability.

Performance optimization through batching

Logging every tiny change immediately would be slow. Modern systems buffer changes in memory and write the log in batches, trading some crash-safety window for speed. The commit() call forces a batch write to disk, guaranteeing that the transaction is durable. Tuning the batch size and fsync frequency balances durability guarantees against throughput.

Embed this diagram

Add this animated write-ahead log (wal) to your own site. Copy one line of HTML, or use the embed builder for theme and sizing options.

Reference

What this is
A free, embeddable, animated write-ahead log (wal) for any website.
Who uses it
Developer blogs, DevOps / SRE sites.
How to embed
Copy one line of HTML. No signup. No watermark. Works in WordPress, Webflow, Ghost, Substack, plain HTML.
File size
iframe embed, ~80 KB gzipped (loads on demand, does not block your page paint).
License
Free forever. Editorial explainer text included; updated centrally over time.

Embed format options

Copy the universal HTML snippet, the WordPress shortcode, or an iframe fallback - see the WordPress plugin page for details. Any format keeps the same Core Web Vitals profile and the same explainer text.

Embed snippet
<div data-scrollchart="wal-redo-log" data-scrollchart-v="1"></div>
<script src="https://scrollchart.com/embed.js" async></script>

Frequently asked questions

Where can I get a free animated "Write-Ahead Log (WAL)" for my website?
Scrollchart provides "Write-Ahead Log (WAL)" as a free, embeddable animated diagram you can add to any website with one line of HTML. No signup is required and there is no watermark. The diagram and its explainer text are served from scrollchart.com, so the embed stays current without any maintenance on your end.
How do I embed a write-ahead log (wal) in a developer or tech blog?
Copy the one-line snippet from the Scrollchart diagram page and paste it into your post HTML. It works in any static site generator, CMS, or hand-coded HTML page. The embed is a thin loader, not an iframe, so the content is fully in your DOM.