The Log is the Architecture

Published on August 27, 2026 · 8 min read

Over the past few months I kept running into the same structure in systems that do very different jobs: moving events between services, recovering a database after a crash, keeping several machines in agreement. Each uses a log: an ordered sequence of records that grows by appending to the end.

Jay Kreps connected these uses in his 2013 essay The Log: What every software engineer should know about real-time data’s unifying abstraction. The more systems I study, the more useful that connection becomes.

A shared event log makes the architecture visible. Applications append events, or a change data capture (CDC) process publishes database changes. Replicas copy the history. Other readers use it to build the state they need.

Shared log architecture
Shared log architecture

Each reader tracks its own position. The search index can fall behind while analytics keeps processing. A new read model can replay retained records without asking the producer to send them again.

This diagram shows a shared event pipeline. A database write-ahead log or a Raft log uses the same ordered structure for a different purpose; neither requires this entire pipeline.

When Hisenberg changes his email address, an event log appends a new record. Earlier records keep their positions. A reader that has processed through position 42 can resume with the next record. Kafka calls this position an offset within a partition.

The order belongs to that sequence. Record 43 follows record 42 in the log, but their positions do not prove that the underlying events happened in that wall-clock order. Clocks can disagree, and messages can arrive late.

Ordering also has a scope. Kafka orders records within a topic-partition. A Raft group agrees on a command sequence for one replicated state machine. Neither implies a global order across every partition or group. Broader ordering requires more coordination; independent sequences allow more work to proceed in parallel.

Append-only describes how new records enter the log. Retention can delete an old prefix, and recovery rules may allow an uncommitted suffix to be discarded. Kafka’s compaction mechanism can also remove superseded records inside a keyed log while preserving the offsets of surviving records. A compacted log supports recovery of keyed state under its retention rules, rather than preserving every change forever.

On disk, a log is often split into segment files so retention can remove whole closed segments. An index helps readers find a position without scanning from the beginning. Appending also makes writes easier to batch and recovery easier to perform incrementally. The benefit depends on the storage and flush policy, not just on the claim that sequential writes are fast.

For order #100, applying OrderCreated, PaymentReceived, and OrderShipped produces a current status of Shipped. A query table can keep that result ready for lookup. Replaying the history can rebuild the table if the records are complete and their interpretation is stable.

text
initial state + ordered changes + stable interpretation = current state

This is why a log can support several views of the same data. A read model stores order status, a search index organises searchable fields, and analytics calculates aggregates. Separating a write path from a derived query model is one way to implement command-query responsibility segregation (CQRS). CQRS itself does not require an event log.

Replay is also a compatibility requirement. Old records must remain interpretable after the code changes. A record that depends on deleted reference data may no longer contain enough information to reproduce the original result. Schema changes need a plan for reading historical versions.

A snapshot reduces replay work by storing state at a known position. Recovery starts with that state and applies the later records. The snapshot must agree with the position it claims to represent, and the necessary suffix must still be available.

Readers can advance independently, but advancing a position needs a precise meaning. Fetching a record, processing it, and making its effects durable are different steps. Consider a reader that charges a customer:

text
read event -> call payment provider -> persist offset

If it crashes after the payment succeeds but before it persists the offset, it may charge again on replay. Persisting the offset first reverses the risk: a crash can skip the charge. An offset alone cannot make an external payment happen exactly once. The application needs a suitable boundary, such as a payment provider’s idempotency key or a transaction that includes both the effect and progress.

A record may be in the writer’s memory, flushed to one machine’s durable storage, or copied to replicas. A consensus protocol can additionally establish that it is committed. These states tolerate different failures.

Acknowledging before a local flush can lose recent writes after a power failure. Flushing on one machine does not protect against losing that machine’s storage. Replication adds copies, but its acknowledgement and failover rules determine whether an acknowledged record survives a leader change.

Under a consensus protocol such as Raft, committed entries remain part of the agreed history under the protocol’s failure assumptions. New writes require a communicating quorum. Losing that quorum stops progress without undoing earlier commitments.

The acknowledgement policy therefore belongs in the application’s requirements. A payment instruction that must survive a single-node failure needs a different policy from telemetry that can tolerate losing a few recent records. Waiting for more durable copies adds work to the acknowledgement path.

Kafka exposes partitioned logs as shared infrastructure. Producers append records, and consumers track positions in retained history. Partitions provide parallelism and define the scope of ordering and replication. Retention and compaction determine what remains available for replay.

PostgreSQL’s write-ahead log supports database recovery. Before a changed data page reaches durable storage, the WAL describing that change must be flushed. Recovery can redo changes that did not reach their data pages before a crash. The database can therefore avoid flushing every modified page at each commit.

Commit acknowledgement is a separate setting: asynchronous commit can return before WAL is durable, accepting a window of possible transaction loss. WAL records also describe database operations; they are not automatically a stable domain-event API for application readers.

redo WAL

Change page

Flush WAL

Acknowledge
sync commit

Write page
to disk later

Crash before
page write

redo WAL

Change page

Flush WAL

Acknowledge
sync commit

Write page
to disk later

Crash before
page write

Raft, described by Diego Ongaro and John Ousterhout, uses a replicated log to agree on commands. A leader copies entries to followers, and state machines apply committed entries in order. An entry existing on the leader does not establish commitment. Deterministic state machines that start from the same state and apply the same commands in the same order can reproduce the same state.

Client command

Leader appends

Followers copy

Quorum + Raft
commit rules

Apply committed
entries in order

Client command

Leader appends

Followers copy

Quorum + Raft
commit rules

Apply committed
entries in order

The ext4 journal protects filesystem consistency after a crash. Committed journal transactions can be replayed after an interrupted update. Its default data=ordered mode journals metadata, so it should not be treated as a durable history of every change to file contents.

crash after commitrecordcrash before commitrecord

Descriptor block

Metadata blocks

Commit record

Checkpoint to
final location

Replayed on mount

Discarded on mount

crash after commitrecordcrash before commitrecord

Descriptor block

Metadata blocks

Commit record

Checkpoint to
final location

Replayed on mount

Discarded on mount

These systems share a way to record ordered work. The record format and the rules for commitment decide what that history can safely be used for.

Independent readers need enough retained history to recover from an outage. They also need spare processing capacity. A reader that processes 50 MB/s while the producer writes 50 MB/s can keep up, but it cannot clear an existing backlog while that ingress continues.

text
catch-up rate = consumer throughput - producer throughput
catch-up time = backlog bytes / catch-up rate  (when the rate is positive)

Retention limits the age of the next unread record. With constant ingress and oldest-first processing, that age grows during an outage and falls when the consumer processes faster than ingress.

A five-day outage creates five days of backlog. At 1.6 times the producer’s rate, a consumer needs about 8.3 days to clear it while new records arrive. Seven-day retention can still be sufficient: the oldest unread record starts five days old and gets younger throughout recovery. The total catch-up duration does not have to fit inside the retention window.

Production settings need margin for changing rates and repeated outages. Once a required record has been deleted, replay needs another starting point, such as a suitable snapshot. Monitor consumer lag alongside the age of unread records and the available recovery throughput.

The log also needs structures around it. An index or materialised view makes current state efficient to query. Snapshots shorten recovery. Retention and compaction limit stored history, while deletion requirements may constrain what records can contain in the first place. Keeping an append-only history does not remove those responsibilities.

When evaluating a design, I want the requirements written down before choosing the implementation:

RequirementArchitectural consequence
Observe each order’s transitions in sequenceChoose an ordering scope and route related writes to it
Preserve acknowledged payments after one node failsDefine the durable replication and failover rules
Rebuild a read model from six months of changesRetain interpretable records for that period
Recover a reader after an outageProvide enough retention and processing headroom
Retry an external effect safelyCouple progress to the effect or make retries idempotent
Keep only the latest value per keyConsider compaction and its deletion rules

“Every transition for one order must be observed in order” gives me a requirement I can check against a partitioning scheme. “Use a log” leaves that decision open. I want the same precision about acknowledged writes and how far readers must be able to replay.