[KongchangAI]
· 3 min read· 1,786 words

Detailed Explanation of WAL Network Latency Optimization in Lakebase's Decoupled Storage-Compute Architecture

Detailed Explanation of WAL Network Latency Optimization in Lakebase's Decoupled Storage-Compute Architecture

How Lakebase/Neon optimizes WAL latency in decoupled storage-compute via quorum writes, pipelining, and proximity deployment.

This article explains how Databricks Lakebase (based on Neon architecture) addresses the WAL network latency challenge inherent in decoupled storage-compute databases. Through Safekeeper quorum consensus, group commit pipelining, streaming WAL transmission, and co-located deployment strategies, Lakebase compresses commit latency to local-disk levels while maintaining strict ACID guarantees by redefining durability as WAL consensus replication rather than physical page materialization.

Introduction: The WAL Latency Challenge in Decoupled Storage-Compute Architecture

As cloud-native database architectures evolve, Databricks Lakebase (based on the Neon architecture) has adopted a decoupled storage and compute design. While this architecture offers significant advantages in elastic scaling and cost optimization, it introduces an unavoidable core problem: When the compute layer and storage layer are separated by a network, synchronous WAL (Write-Ahead Log) flush operations must traverse the network to reach the distributed storage layer—how can we avoid paying the cost of a network round-trip for every transaction commit?

WAL (Write-Ahead Log) is the foundational technology that ensures crash recovery capability in modern database systems. Its core principle is: any data modification must first have a log record describing that modification written to persistent storage before the actual data page is modified. This design originated from IBM's System R project in the 1970s and was later systematized through the ARIES (Algorithm for Recovery and Isolation Exploiting Semantics) algorithm. WAL's value lies in converting random writes into sequential writes (log appending) while providing precise recovery points. In PostgreSQL, WAL serves not only crash recovery but is also the data source for streaming replication, Point-in-Time Recovery (PITR), and logical decoding. Understanding WAL's role as a "single source of truth" is the prerequisite for understanding why the Neon architecture can confirm durability based solely on WAL consensus.

This problem touches on the most fundamental trade-off in the database domain—how to minimize latency while guaranteeing ACID (Atomicity, Consistency, Isolation, Durability). This article provides an in-depth analysis centered on this technical question, dissecting Lakebase/Neon's multi-layered latency optimization strategies.

Differences in WAL Mechanisms Between Traditional and Decoupled Architectures

Traditional Database Local WAL Flushing

In traditional single-node PostgreSQL, a transaction commit requires synchronously flushing WAL logs to the local disk—only when fsync returns successfully is the transaction considered durably committed. Since this is a local disk operation, latency is typically in the microsecond to millisecond range.

Latency Amplification in Decoupled Storage-Compute Architectures

In decoupled storage-compute architectures like Lakebase/Neon, the local disk is replaced by a distributed storage service accessed over the network (called Pageserver and Safekeeper in Neon). If the traditional "wait for remote confirmation on every commit" model is used, each transaction's commit latency would include at least one full network round-trip time (RTT)—sub-millisecond within the same availability zone, potentially several milliseconds across zones—which is devastating for high-concurrency OLTP workloads.

Decoupled storage and compute is not an entirely new concept; its roots trace back to the SAN (Storage Area Network) architecture of the mainframe era. However, cloud-native storage-compute separation is fundamentally different: it leverages the virtually unlimited capacity and pay-as-you-go pricing of object storage (such as S3), while solving performance issues through a software-defined intermediate layer. AWS Aurora (2014) pioneered this paradigm, with its core insight being "the log is the database"—using WAL as the only payload transmitted across the network, with page materialization completed on the storage side. Neon inherited and developed this approach but took an open-source PostgreSQL-compatible route. Meanwhile, Snowflake, Google AlloyDB, Azure Hyperscale, and other products have each implemented different forms of storage-compute separation, forming the mainstream trend in cloud database architecture.

Neon's Core Solution: Decoupling the Durability Path with Safekeeper Consensus

WAL Written to Safekeeper Quorum Enables Commit

A key design in the Neon architecture is: the durability guarantee for transaction commits does not depend on data pages being written to final storage, but rather on WAL being successfully replicated to a quorum (majority) of Safekeeper cluster nodes.

Specifically:

  • Safekeepers are a group of lightweight nodes dedicated to receiving and persisting WAL, typically employing a consensus protocol similar to Paxos/Raft.
  • When a compute node initiates a commit, it only needs to wait for WAL to be written to a majority of Safekeeper nodes (e.g., 2 out of 3 nodes) before returning a successful commit.
  • The actual materialization of data pages is completed asynchronously by the Pageserver replaying from the WAL stream—this is not on the critical commit path.

The Safekeeper quorum mechanism is rooted in distributed consensus theory. In the classic Paxos protocol (Lamport, 1989) and Raft protocol (Ongaro & Ousterhout, 2014), as long as a majority of nodes (N/2+1) confirm a write, the system can tolerate minority node failures without data loss. For a typical 3-node deployment, 1 node failure is tolerated; for 5 nodes, 2 failures. This mechanism provides stronger fault tolerance compared to traditional primary-standby replication: in primary-standby mode, if the synchronous standby becomes unavailable, the system must either block writes or degrade to asynchronous replication with data loss risk. Quorum writes allow any single node to be temporarily unavailable without affecting write availability. As dedicated WAL receiving nodes, Safekeepers are designed for ultimate write throughput and low latency, so they do not handle compute-intensive tasks like page materialization, maintaining the efficiency of a "thin" service.

This way, commit latency is compressed to the network delay to the nearest majority of Safekeeper nodes, rather than a full round-trip to final storage. By deploying Safekeepers in the same or adjacent availability zone as compute nodes, RTT can be kept at sub-millisecond levels.

How ACID Guarantees Are Maintained in Decoupled Storage-Compute

Many people worry that asynchronous materialization would break Durability. In practice, it does not:

  • Durability: As long as WAL has landed on a majority of Safekeeper nodes, even if the compute node crashes, all committed transactions can be recovered from Safekeepers upon restart. This satisfies the D requirement.
  • Atomicity & Consistency: These are guaranteed by PostgreSQL's transaction engine itself; the separation of the storage layer does not change the semantics of the transaction log.
  • Isolation: The MVCC (Multi-Version Concurrency Control) mechanism continues to operate fully at the compute layer.

Multi-Version Concurrency Control (MVCC) is the core mechanism by which PostgreSQL implements transaction isolation. Each transaction obtains a snapshot at startup, which defines which data versions that transaction can "see." In traditional PostgreSQL, multi-version data (multiple versions of tuples) is stored in the same heap table, with visibility determined through transaction IDs (xid) and the visibility map. In Neon's decoupled storage-compute architecture, MVCC logic executes entirely at the compute layer, while the storage layer (Pageserver) is completely transparent to transaction semantics—it only provides page contents at a specified LSN. This clean layering means all of PostgreSQL's original isolation levels (Read Committed, Repeatable Read, Serializable) work correctly in Neon without modification, making the storage-compute separation completely transparent to the application layer.

In other words, Neon redefines "durability" from "writing to final data pages" to "writing to the WAL consensus group"—this is perfectly valid in database theory, as WAL itself is the authoritative source of durability.

Detailed Multi-Layered Latency Optimization Techniques

Pipelining and Group Commit Batching

Neon extensively uses WAL streaming rather than a request-response model. The compute node continuously pushes WAL records to Safekeepers, and logs from multiple transactions can be pipelined in the network pipe, avoiding the serial waiting of "send one, wait for one." Meanwhile, the group commit mechanism merges flush operations from multiple concurrent transactions into a single network acknowledgment, significantly amortizing per-transaction latency.

Group commit is a classic database performance optimization technique, first proposed by Jim Gray in the 1980s. Its core idea is: when multiple transactions reach their commit point nearly simultaneously, their fsync operations are merged into a single physical I/O. In single-node PostgreSQL, when one transaction is executing a WAL fsync, other transactions waiting to commit "piggyback" on the same disk flush. This reduces per-transaction I/O cost from O(1) to O(1/N), where N is the number of concurrent commits. In Neon's networked scenario, the value of group commit is further amplified: a single network round-trip can carry WAL records from dozens or even hundreds of transactions, with the RTT cost amortized across all participating transactions. Combined with pipelining, throughput under high concurrency can approach the network bandwidth limit rather than being constrained by RTT.

Proximity Deployment Strategy to Minimize Physical RTT

By deploying Safekeepers in the same region or even the same availability zone as compute nodes, physical network latency is minimized. Modern cloud internal network RTT can be as low as 0.1–0.5 milliseconds, on par with the fsync latency of local SSDs.

Local Cache Optimization for the Read Path

For read operations, compute nodes maintain local shared buffers and a Local File Cache. Hot data doesn't need to be fetched from the Pageserver every time, effectively eliminating network latency from most read paths. Only page misses trigger on-demand fetches from the Pageserver.

The Pageserver is the core component in the Neon architecture responsible for transforming the WAL stream into readable data pages. It continuously consumes WAL records from Safekeepers and builds page states at arbitrary points in time through replay logic. This design enables two key capabilities: first, time-travel queries, which can reconstruct a page at any historical LSN (Log Sequence Number); second, branching—creating instant database copies by sharing WAL history. When a compute node experiences a page miss, it sends a GetPage@LSN request to the Pageserver, which returns the exact state of that page at the specified LSN. To optimize this path, the Pageserver internally maintains tiered storage: recent WAL deltas are kept in memory and local SSDs, while historical data sinks to object storage (such as S3), forming a hot-warm-cold tiered read architecture.

Performance Comparison Summary with Traditional Models

Returning to the original technical question—"How to avoid the standard network round-trip cost for every transaction commit?" The answer can be summarized in three points:

  1. Shorten the critical path: Commits only need to wait for WAL to be written to a Safekeeper majority, not for final storage materialization.
  2. Batching and pipelining: Group commit and streaming transmission amortize the network overhead per transaction.
  3. Physical proximity deployment: Safekeepers are deployed near compute nodes, bringing network round-trips close to local disk latency.

Fundamentally, Lakebase hasn't "eliminated" network latency—instead, it hides network latency within a highly optimized durability path that operates at the same magnitude as local disk, while maintaining strict ACID semantics by redefining the durability boundary.

Conclusion: The Durability Paradigm Shift in Cloud-Native Databases

The Databricks Lakebase/Neon design demonstrates an important paradigm shift in cloud-native databases: durability no longer equates to physical disk writes, but to consensus replication of logs. This approach is entirely aligned with the distributed systems principle of "the log is the source of truth."

For developers, understanding this mechanism helps in properly evaluating Lakebase's performance in high-concurrency OLTP scenarios, and in clearly recognizing that the concern of "storage-compute separation introduces latency" has been effectively resolved through careful architectural engineering. Of course, latency trade-offs in cross-availability-zone or cross-region deployments remain a real constraint that users must carefully evaluate against their business SLAs.

Key Takeaways

#Lakebase WAL optimization#Neon architecture#storage-compute separation latency#Safekeeper quorum#group commit pipelining#cloud-native database durability#WAL consensus replication
Share:

Related articles