PostgreSQL 19's new WAIT FOR LSN command lets a replica block until it has replayed your write. The read-after-write problem it solves, the workarounds it replaces, and what the timeout, status, and mode options are actually for.
PostgreSQL 19's new WAIT FOR LSN command lets a replica block until it has replayed your write. The read-after-write problem it solves, the workarounds it replaces, and what the timeout, status, and mode options are actually for.
PostgreSQL 19's new WAIT FOR LSN command lets a replica block until it has replayed your write. The read-after-write problem it solves, the workarounds it replaces, and what the timeout, status, and mode options are actually for.
Most social networks use a single database with an app, storing usernames, posts, algorithms, moderation rules, and HTML within the same company. Building on top means relying on the vendor’s rate-limited API, which can change or disappear unexpectedly.
The AT Protocol (ATproto) divides the monolith into parts that different people can run, use different languages for, and swap out without…
A replica set is MongoDB's name for a group of database nodes that maintain the same data and provide automatic failover. One node is the primary (accepts writes); the rest are secondaries that asynchronously apply the primary's operation log. If the primary becomes unreachable, the secondaries elect a new primary among themselves.
How it works
Writes go to the primary, which records them in…
Sharding is the practice of horizontally partitioning a dataset across multiple database instances so each shard holds a subset of the data and serves a subset of the load. Sharding is the standard answer when a single database server cannot keep up with storage, read throughput, or write throughput.
How it works
A shard key (one or more fields) determines which shard each row or document…
The CAP theorem states that a distributed data store cannot simultaneously provide all three of: Consistency (every read returns the latest write), Availability (every request receives a response), and Partition tolerance (the system continues to operate despite network splits). Under a network partition, a system must give up either consistency or availability.
What the three properties mean…
Eventual consistency is the property that, given enough time without new updates, all replicas of a piece of data will converge to the same value. Reads may see stale or out-of-order data in the short term, but the system guarantees convergence rather than instantaneous global agreement.
Why it exists
Strong consistency (every read sees the latest write) requires coordination on every write,…
Consensus is the problem of getting a set of distributed processes to agree on a single value despite failures, message delays, and out-of-order delivery. Consensus protocols are the foundation under any replicated state machine, leader election, distributed lock, or strongly consistent database.
The classical guarantees
A Saga is a pattern for executing a business transaction that spans multiple services or databases by chaining local transactions together, with compensating actions to roll back partial progress on failure. Sagas replace distributed transactions (two-phase commit) in microservice systems where global ACID across services is impractical.
How it works
A saga breaks a business transaction into a…
Event-Driven Architecture (EDA) is a style in which services communicate by publishing and subscribing to events on a message bus, rather than calling each other synchronously. Producers emit events when something happens; consumers react to those events independently. The pattern reduces coupling and enables fan-out, replay, and asynchronous processing.
How it works
A producer publishes an…
A modular monolith is a single-deployable application built with strict internal module boundaries: clear ownership per module, explicit interfaces between them, no shared mutable state across boundaries. The result combines monolithic operational simplicity with most of the structural benefits of microservices.
How it works
Each module owns its own data, its own domain logic, and exposes a…
A monolith is an application packaged and deployed as a single unit: one codebase, one build, one process, one database. Everything ships together. Most applications start as monoliths and many remain so for their entire useful life; the term has acquired a pejorative tone in recent years that obscures how often it is the right choice.
Strengths
A cache stampede (or thundering herd) is the failure mode where many concurrent requests for the same hot key all miss the cache at the same time, hit the origin simultaneously, and overwhelm it. Stampedes typically happen the instant a popular key expires, when a cache is cold-started, or when a downstream system briefly fails and recovers.
How it happens
Consider a homepage feed cached with…
Idempotency is the property that repeating an operation produces the same outcome as performing it once. An idempotent operation can be safely retried after a network failure, timeout, or partial failure, without risking duplicate side effects.
Idempotency by HTTP method
Key takeaways from Amazon's 2007 Dynamo paper.
Key takeaways from Amazon's 2007 Dynamo paper.
Distributed systems fail at the boundaries between services. A single user request crosses many network hops, each with different latency, failure behavior, and ownership. Without shared traffic controls, every team invents its own retry logic, timeout values, routing rules, and access policy. That creates inconsistent behavior, hidden coupling,…
Why logging at every layer of a service produces noise, and how to log only at the handler level while propagating context from below.
Why logging at every layer of a service produces noise, and how to log only at the handler level while propagating context from below.
How to test unary gRPC services in Go - handler logic, interceptors, deadlines, metadata propagation, and rich error details - all in-memory with bufconn.
How to test unary gRPC services in Go - handler logic, interceptors, deadlines, metadata propagation, and rich error details - all in-memory with bufconn.
Why the middleware-to-handler boundary is a special case for context values.
Why the middleware-to-handler boundary is a special case for context values.
A simple litmus test for when to use context values in Go.
A simple litmus test for when to use context values in Go.
How to wrap a generated gRPC client behind a clean Go API so users never have to touch protobuf types or connection management directly.
How to wrap a generated gRPC client behind a clean Go API so users never have to touch protobuf types or connection management directly.
Why the etcd codebase is my go-to reference for building gRPC services in Go.
Why the etcd codebase is my go-to reference for building gRPC services in Go.
Master shadow testing for large-scale system migrations. Learn to safely rewrite services by comparing outputs between old and new implementations.