Distributed systems
25 facts about distributed systems from 3 Rialo sources. Each one is the explanation Reactor shows after a question, followed by the exact line it rests on.
Test yourself on this topic in AtlasRialo Learn
The demo covers Strong, Bounded, Session, Prefix, Monotonic, Read My Writes and Eventual consistency.
“Explore Strong, Bounded, Session, Prefix, Monotonic, Read My Writes, and Eventual consistency.”A Visual Guide to Concurrency Control
The conclusion says a future post will cover how Rialo uses optimistic execution for a high performance execution environment.
“In the future, we will explore how Rialo uses optimistic execution to provide a high-performance execution environment for applications and guarantee the best possible experience for users.”Both read $100; if B's $150 commit lands last it overwrites A's debit and creates money, while $70 landing last destroys money.
“The first (final balance: $150) prints additional money, while the second (final balance: $70) destroys money.”Pessimistic systems delay a transaction that could conflict, while optimistic systems pay later with re-execution.
“Pessimistic execution systems pay this cost upfront (before execution) in the form of delays–a transaction might be delayed if its execution could conflict with another transaction.”Rerunning (orange) is the optimistic mode retry state; Waiting (gray) is the pessimistic mode delay state.
“Rerunning (orange): Transaction is being re-executed (optimistic mode)”The post links the visualizer at concurrency-control.learn.rialo.io, where you can watch optimistic and pessimistic modes run.
“We've built a dashboard to visualize concurrency control that you can access at https://concurrency-control.learn.rialo.io/”A scheduler that cannot tell reads from writes gives exclusive access per account, so even a pure read may be forced to wait.
“Transaction C will have to execute in sequential mode, even though it's only reading a shared account.”Whether A or B runs first, the sequential result is $120, which is the benchmark parallel execution must match.
“No matter the order of execution, the final result is always $120.”The boost is mostly limited to pessimistic mode; optimistic mode has no notion of exclusive access and already runs at maximum parallelism.
“The performance boost is mostly limited to pessimistic mode because optimistic mode doesn't have a notion of exclusive access and always permits maximum parallel execution and concurrent state access.”Waiting is gray and marks pessimistic mode delays; blue is the Executing state.
“Waiting (gray): Transaction is waiting to execute (pessimistic mode) Executing (blue): Transaction is executed”Transactions within a batch run concurrently while the batches themselves execute one after another.
“Conflicting transactions are grouped into conflict-free batches. Transactions within a batch execute concurrently, but the batches themselves are executed in a sequence.”Optimistic execution lets both run, then validation catches A's stale read and reruns it against $150, giving the correct $120.
“Transaction A and B both read $100, but the balance reads $150 by the time Transaction A finishes (because Transaction B committed earlier). Transaction A notices the state change has changed, discards the old result, and re-executes with the new balance instead of overwriting it. The final result is $120 because Transaction A calculates $150 - $30 instead of $100 - $30.”This line is from the post A Visual Guide to Concurrency Control.
“Permitting shared reads unlocks opportunities for higher concurrency, particularly for optimistic systems that maximize parallelism.”A Practical Guide to Consistency in Distributed Systems
The guide covers strong consistency, bounded staleness, consistent prefix, monotonic reads, read-my-writes and eventual consistency.
“This article explains the six major consistency guarantees used in distributed systems with replicated storage, including strong consistency , bounded staleness , consistent prefix , monotonic reads , read-my-writes , and eventual consistency”Alice's branch, ATM and mobile app connect to replicas in New York, San Francisco and Texas, which is why her balance can differ.
“In this example, the bank operates replicas in New York, San Francisco, and Texas.”Bounded staleness caps how stale a read can be, in time or versions, so rankings can lag but never beyond the 10 minute bound.
“Leaderboards are a concrete application of bounded staleness.”Consistent prefix means every read is a valid ordered prefix of history, so a node cannot show block N without all the blocks before it.
“Public blockchains : A node may lag the head of the chain, but it cannot present block N without presenting blocks 1 through N-1.”Reads can be stale and skip values, but they never move backward: the client sees K, then M, then Z and never J after K.
“A client connects to a lagging replica, and its first read returns "K." On a later read, the replica returns "M," and later still it returns "Z."”DNS resolvers cache records for their TTL, so an updated record shows up in some regions before others and converges later.
“The Domain Name System (DNS) is a real-world example of a replicated distributed system with eventual consistency guarantees.”Block finalization needs strong consistency, but historical queries can relax to bounded staleness or eventual consistency for lower latency.
“while read-heavy workflows like querying historical chain data may use bounded staleness or eventual consistency to reduce coordination and improve latency”Stronger consistency constrains failure modes like stale reads; the guide gives double spending prevention as the blockchain case.
“(for example, blockchains rely on strong consistency to prevent double-spending)”Read-my-writes only covers a client's own writes within its session; other clients' writes get no visibility guarantee.
“The name reflects that the guarantee applies specifically to a client's own writes: read-my-writes does not guarantee visibility into another client's writes.”Eventual consistency allows stale reads but never invented ones; every value must come from a real committed write.
“In this example, no endpoint can return a balance such as $130 because it was never written.”Monotonic reads let the first read be stale but forbid the session from travelling backward in the write history.
“Under monotonic reads, a client's view of committed writes only moves forward.”This line is from the post A Practical Guide to Consistency in Distributed Systems.
“In the event stream, a replica cannot expose OrderShipped without first exposing OrderCreated and PaymentReceived.”