Batch Concurrent Durable Writes With a Group Commit Leader

Last updated: November 29, 2026

Quick Overview

Many threads append records to a write-ahead log, and each append must return only after its record is durable. Flushing is expensive, so implement group commit: one thread flushes all pending records in a single batch while others wait for it.

Google
Software Engineering Fundamentals
Software Engineer
Google
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Hard

0

0

0 solved


Many threads append records to a write-ahead log, and each append must return only after its record is durable. Flushing is expensive, so implement group commit: one thread flushes all pending records in a single batch while others wait for it.

Storage systems at Google such as Spanner and Bigtable amortize disk or Paxos round trips by batching writes. Onsite interviewers use group commit to test leader election under a lock, releasing the lock around slow I/O, and the subtle condition that a waiter's record may not be in the batch currently being flushed.

What the Interviewer Expects
  • Assigns each record a sequence number so durability is checked per record
  • Elects a leader that flushes all pending records outside the lock
  • Waiters re-check whether their own sequence number is durable, not just whether a flush finished
  • Explains the throughput gain versus one flush per write
  • Handles flush failure without leaving the flushing flag stuck
Key Topics to Cover
group commit
write-ahead log
leader election
condition variable
batching
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • What should waiters see if the flush fails?
  • How would you add a small linger delay to grow batches, and what does it cost in latency?
  • How does this map onto Paxos or Raft log replication?
  • How would you cap batch size?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements
  • append(record) returns the record's sequence number after it is durable.
  • Records are flushed exactly once, in batches.
  • Only one flush runs at a time; concurrent appenders join the next batch....
High-Level Design

Each append takes an LSN and adds its record to pending. Then it loops until durable_lsn >= its lsn. If no flush is running it becomes leader: it swaps out the whole pending list, notes the highes...


Submit Your Answer
Markdown supported