Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems
Rate it:
Open Preview
23%
Flag icon
Pretending that replication is synchronous when in fact it is asynchronous is a recipe for problems down the line.
23%
Flag icon
A natural extension of the leader-based replication model is to allow more than one node to accept writes.
23%
Flag icon
It rarely makes sense to use a multi-leader setup within a single datacenter, because the benefits rarely outweigh the added complexity.
24%
Flag icon
With a normal leader-based replication setup, the leader has to be in one of the datacenters, and all writes must go through that datacenter.
24%
Flag icon
In a multi-leader configuration, you can have a leader in each datacenter.
24%
Flag icon
24%
Flag icon
In a single-leader configuration, every write must go over the internet to the datacenter with the leader.
24%
Flag icon
In a multi-leader configuration, every write can be processed in the local datacenter and is replicated asynchronously to the other datacenters.
24%
Flag icon
If you make any changes while you are offline, they need to be synced with a server and your other devices when the device is next online.
24%
Flag icon
The biggest problem with multi-leader replication is that write conflicts can occur, which means that conflict resolution is required.
24%
Flag icon
24%
Flag icon
If you want synchronous conflict detection, you might as well just use single-leader replication.
24%
Flag icon
In a multi-leader configuration, there is no defined ordering of writes, so it’s not clear what the final value should be.
24%
Flag icon
As the most appropriate way of resolving a conflict may depend on the application, most multi-leader replication tools let you write conflict resolution logic using application code.
24%
Flag icon
Even if the application checks availability before allowing a user to make a booking, there can be a conflict if the two bookings are made on two different leaders.
24%
Flag icon
A replication topology describes the communication paths along which writes are propagated from one node to another.
24%
Flag icon
With more than two leaders, various different topologies are possible.
25%
Flag icon
In circular and star topologies, a write may need to pass through several nodes before it reaches all replicas.
25%
Flag icon
When a node receives a data change that is tagged with its own identifier, that data change is ignored, because the node knows that it has already been processed.
25%
Flag icon
A leader determines the order in which writes should be processed, and followers apply the leader’s writes in the same order.
25%
Flag icon
In some leaderless implementations, the client directly sends its writes to several replicas, while in others, a coordinator node does this on behalf of the client.
25%
Flag icon
The client simply ignores the fact that one of the replicas missed the write.
25%
Flag icon
The replication system should ensure that eventually all the data is copied to every replica.
25%
Flag icon
After an unavailable node comes back online, how does it catch up on the writes that it missed?
25%
Flag icon
Note that without an anti-entropy process, values that are rarely read may be missing from some replicas and thus have reduced durability, because read repair is only performed when a value is read by the application.
25%
Flag icon
As long as w + r > n, we expect to get an up-to-date value when reading, because at least one of the r nodes we’re reading from must be up to date.
25%
Flag icon
If w + r > n, at least one of the r replicas you read from must have seen the most recent successful write.
25%
Flag icon
With a smaller w and r you are more likely to read stale values, because it’s more likely that your read didn’t include the node with the latest value.
25%
Flag icon
However, even with w + r > n, there are likely to be edge cases where stale values are returned.
25%
Flag icon
Stronger guarantees generally require transactions or consensus.
26%
Flag icon
The only safe way of using a database with LWW is to ensure that a key is only written once and thereafter treated as immutable, thus avoiding any concurrent updates to the same key.
26%
Flag icon
An operation A happens before another operation B if B knows about A, or depends on A, or builds upon A in some way.
26%
Flag icon
If one operation happened before another, the later operation should overwrite the earlier operation, but if the operations are concurrent, we have a conflict that needs to be resolved.
26%
Flag icon
For defining concurrency, exact time doesn’t matter: we simply call two operations concurrent if they are both unaware of each other, regardless of the physical time at which they occurred.
26%
Flag icon
When a write includes the version number from a prior read, that tells us which previous state the write is based on.
26%
Flag icon
With the example of a shopping cart, a reasonable approach to merging siblings is to just take the union.
26%
Flag icon
Each replica increments its own version number when processing a write, and also keeps track of the version numbers it has seen from each of the other replicas.
27%
Flag icon
The version vector allows the database to distinguish between overwrites and concurrent writes.
27%
Flag icon
A version vector is sometimes also called a vector clock, even though they are not quite the same.
27%
Flag icon
If a leader fails and you promote an asynchronously updated follower to be the new leader, recently committed data may be lost.
28%
Flag icon
In effect, each partition is a small database of its own, although the database may support operations that touch multiple partitions at the same time.
28%
Flag icon
The main reason for wanting to partition data is scalability.
28%
Flag icon
Partitioning is usually combined with replication so that copies of each partition are stored on multiple nodes.
28%
Flag icon
A node may store more than one partition.
28%
Flag icon
Each partition’s leader is assigned to one node, and its followers are assigned to other nodes.
28%
Flag icon
Our goal with partitioning is to spread the data and the query load evenly across nodes.
28%
Flag icon
A partition with disproportionately high load is called a hot spot.
28%
Flag icon
A good hash function takes skewed data and makes it uniformly distributed.
28%
Flag icon
Keys that were once adjacent are now scattered across all the partitions, so their sort order is lost.
29%
Flag icon
The problem with secondary indexes is that they don’t map neatly to partitions.