10 min read

Beyond the Speed of Light: Building 100% Consistent Global Ledgers at 1M TPS

100% Consistent Global Ledgers at 1M TPS

Beyond the Speed of Light: Building 100% Consistent Global Ledgers at 1M TPS

Imagine it’s 2:00 AM. A user in Singapore initiates a $50,000 cross-border transfer to a merchant in London. At the exact same millisecond, an automated subscription service in New York attempts to pull $50 from that same account. In a traditional centralized database, this is a solved problem: a row-level lock, a quick ACID transaction, and you’re done.

But what if your system is distributed across five continents to ensure sub-10ms latency for a global user base?

The speed of light is roughly 300,000 kilometers per second. In fiber optics, it’s slower. A round-trip from New York to Singapore takes about 160ms. In the world of high-frequency fintech, 160ms is an eternity—it’s the difference between a seamless user experience and a “double-spend” race condition that could bankrupt a startup or trigger a regulatory nightmare.

Standard industry practice usually forces a choice: Availability (the system stays up, but maybe users see stale balances) or Consistency (the system is always right, but it feels slow because every write must wait for a global “handshake”).

At the cutting edge of fintech engineering, we are refusing to accept that trade-off. The answer lies in Multi-Region Deterministic State Machines (DSMs). By moving away from “database-first” architectures and toward “compute-first” deterministic execution, we can achieve global consistency without the crushing weight of traditional distributed locks.

The Physics of the Problem: Why Your RDBMS is Failing You

Most engineers grow up with the “Database as the Source of Truth” mental model. You have a massive Postgres or MySQL instance, and your application code is just a “stateless” pipe that talks to it.

When you scale globally, you usually try Read Replicas. This works great for Instagram likes, but it’s disastrous for ledgers. If a user in London reads their balance from a local replica while a New York transaction is still replicating, they see money they don’t actually have. This is “Stale Read” territory.

To solve this, you might look at Global Databases like Spanner or CockroachDB. They use atomic clocks or Paxos/Raft consensus to ensure linearizability. They are engineering marvels, but they are bound by the laws of physics. Every write must be coordinated across a majority of nodes. If your nodes are global, your “write latency” is capped by the slowest round-trip time between your regions.

For a high-throughput ledger processing 100,000 transactions per second (TPS), waiting 150ms for a consensus commit is a bottleneck that no amount of vertical scaling can fix.

Enter the Deterministic State Machine (DSM)

To break the bottleneck, we have to flip the script. Instead of replicating the data (the state), we replicate the input (the commands).

A Deterministic State Machine is a simple but profound concept:

If two instances of a program start in the exact same state and receive the exact same sequence of inputs, they will produce the exact same output and end in the exact same state.

In a fintech context, the “State” is the ledger. The “Inputs” are the transactions (Withdraw, Deposit, Transfer). If we can guarantee that every node in our global network sees the same list of transactions in the same order, we don’t need them to “talk” to each other to confirm a balance. They can compute the result locally and be 100% certain that every other node reached the same conclusion.

Architecture: The Three Pillars of Global Determinism

Building this at scale requires three distinct layers that move the complexity out of the database and into the sequencing of the log.

1. The Global Sequencer (The “Total Order” Layer)

The hardest part of distributed systems is agreeing on when things happened. We use a high-performance consensus ring (usually based on a modified Raft or a sequencer-based approach like the LMAX Disruptor pattern) to assign a monotonically increasing sequence number to every incoming request.

The Sequencer doesn’t execute the trade; it just stamps it:

  • Transaction A: NYC, 10:00:00.001 -> Sequence #101
  • Transaction B: SIN, 10:00:00.002 -> Sequence #102

2. The Deterministic Execution Engine

This is where the magic happens. The engine is a single-threaded (or partitioned multi-threaded) process that consumes the ordered log. Because it’s deterministic, it doesn’t need locks. It doesn’t need SELECT FOR UPDATE. It just iterates through the log as fast as the CPU allows.

// A simplified look at a deterministic ledger transition
fn process_transaction(state: &mut LedgerState, tx: Transaction) -> Result<(), Error> {
    // 1. Validation is pure and deterministic
    let sender_balance = state.balances.get(&tx.sender_id).unwrap_or(0);

    if sender_balance < tx.amount {
        return Err(Error::InsufficientFunds);
    }

    // 2. State transition is a pure function
    state.balances.insert(tx.sender_id, sender_balance - tx.amount);
    let receiver_balance = state.balances.get(&tx.receiver_id).unwrap_or(0);
    state.balances.insert(tx.receiver_id, receiver_balance + tx.amount);

    Ok(())
}

3. The Replicated Journal

The sequence of inputs is persisted to a high-speed distributed log (like Apache Kafka, or more likely for fintech, a custom NVMe-optimized journal). If a node crashes, it simply reloads the last snapshot and “replays” the log to catch up.

Solving the “Non-Determinism” Trap

The biggest challenge in DSM is that “the real world” is non-deterministic. If your code calls DateTime.now() or Math.random(), or queries an external API, your state machines will diverge. In a global fintech system, divergence is a catastrophic failure.

We solve this through Input Decoration. When a request hits our gateway, we “decorate” it with all the non-deterministic data it might need before it enters the sequencer.

  • Time: The Sequencer attaches a “Logic Timestamp” to the transaction. The state machine uses this timestamp instead of the system clock.
  • Entropy: If a transaction needs a random ID, the gateway generates it or attaches a random seed to the request.
  • External Data: If we need the current USD/BTC exchange rate, a separate “Oracle” service injects the rate into the command log as a “System Event.”

By the time the transaction reaches the execution engine, it contains everything needed to be processed identically by 1,000 different nodes in 1,000 different locations.

The Engineering Curiosity: Why Rust and Zig are Winning

In this architecture, the bottleneck isn’t the network (thanks to asynchronous sequencing) or the disk (thanks to append-only journaling). The bottleneck is Tail Latency (P99.9).

If your execution engine is written in a garbage-collected language like Java or Go, a “Stop the World” GC pause of 50ms can stall the entire global ledger. This is why we’re seeing a massive shift toward Rust and Zig in the fintech infrastructure space (shoutout to projects like TigerBeetle).

Using Rust allows us to control memory layout and avoid the non-determinism of GC sweeps. When we’re processing millions of events per second, we need the execution time for a single transaction to be measured in nanoseconds, not milliseconds.

The “Aha!” Moment: Sharding by Object, Not by Geography

A common mistake in global systems is sharding data by user location (e.g., “European users in eu-west-1”). But users travel, and they send money across borders.

In a high-throughput DSM, we shard by Object ID (Account ID). Each shard is its own independent deterministic state machine with its own sequencer.

  • Shard 1 handles Accounts 0-999.
  • Shard 2 handles Accounts 1000-1999.

If a transaction involves two accounts on the same shard, it’s a “Single-Shard Transaction”—blazing fast. If it spans two shards (a transfer from Shard 1 to Shard 2), we use a Deterministic Two-Phase Commit. Because the participants are deterministic, we can often skip the expensive “prepare” phase of traditional 2PC, using a technique called Sagas or Reversible Deterministic Commands.

Performance at Scale: The Numbers

Let’s look at the actual compute scale. In a traditional RDBMS, you might struggle to hit 10,000 TPS on a single write-primary due to lock contention and IOPS limits.

With a Deterministic State Machine:

  1. I/O is Batch-Optimized: We aren’t doing random writes. We are appending to a log. Modern NVMe drives can handle gigabytes of sequential appends per second.
  2. Zero Contention: Since the engine is single-threaded per shard, there are no mutexes, no semaphores, and no context switches.
  3. CPU Cache Efficiency: Since the same code runs over and over on a tight loop, the instruction cache stays “hot,” and we can utilize SIMD (Single Instruction, Multiple Data) to process batches of transactions in parallel where dependencies allow.

In production environments, we’ve seen this architecture reach over 1,000,000 transactions per second on a single medium-sized instance, with global replication lag being the only factor in “time-to-finality.”

Dealing with the “Edge” Hype

There’s a lot of noise right now about “Edge Computing” (Cloudflare Workers, Fly.io, Vercel). The hype suggests we should move “everything” to the edge.

However, the reality for fintech is more nuanced. You can’t run a consistent global ledger entirely at the edge because you still need a “Point of Linearizability.” If two people in two different cities buy the last ticket for a concert, someone has to be first.

The DSM architecture leverages the edge for Validation and Pre-processing, but maintains a Core Consensus Ring for sequencing. This “Hybrid Edge” approach allows us to reject invalid transactions (like those with bad signatures or malformed JSON) at the edge, so they never even hit our sequencer, preserving throughput for legitimate traffic.

Infrastructure: Networking and Anycast

To make this feel “instant” to a global user, we don’t just rely on the public internet. We use Anycast IP routing (via providers like AWS Global Accelerator or Cloudflare).

When a user in Tokyo hits our API, they aren’t routing through the open web to a data center in Virginia. They hit a “Point of Presence” (PoP) in Tokyo. That PoP maintains a persistent, optimized TCP/TLS connection to our Sequencer over a private fiber backbone.

This trims 30-50ms off the handshake time alone—an eternity in fintech.

The Resilience Factor: “Chaos is a Ladder”

One of the most elegant parts of a DSM is how it handles disaster recovery. In a traditional system, “failing over” from US-East to US-West is a terrifying event involving DNS changes, database promotion, and potential data loss.

In a DSM system, every node is a “hot” standby. Because every node is consuming the same log and reaching the same state, “failing over” is as simple as moving the Anycast route. The new node doesn’t need to “sync” or “recover”—it’s already there. It has been executing the same transactions all along.

We often run “Chaos Monkeys” that randomly kill the primary sequencer. The Raft cluster elects a new one in under 200ms, and the execution engines don’t even blink; they just start consuming from the new leader.

The Road Ahead: Formal Verification and ZK-Proofs

Where does this go next? As fintech moves toward even higher stakes—think “Real-time Gross Settlement” (RTGS) for billions of dollars—the “expert” consensus is moving toward Formal Verification.

We are starting to use languages like TLA+ to mathematically prove that our state machine logic is sound before we write a single line of Rust. If your state machine is deterministic, you can model it as a mathematical proof.

Furthermore, we are looking at Zero-Knowledge (ZK) Proofs. Imagine a state machine that not only processes a transaction but also generates a cryptographic proof that the transition was valid according to the rules. A remote node wouldn’t even need to “replay” the transaction; it would just verify the proof. This could allow for “Stateless Clients” that know their balance is correct without ever seeing the full ledger history.

Final Thoughts for the Architect

Moving to a Multi-Region Deterministic State Machine is not a “free lunch.” It requires a complete departure from the CRUD-based thinking that dominates the industry. You have to handle your own sharding, build sophisticated “replay” tooling, and be disciplined about eliminating non-determinism.

But for those building the next generation of global financial rails, the rewards are undeniable: 100% consistency, massive throughput, and a system that treats the laws of physics as a design constraint rather than a deal-breaker.

The world is getting smaller, and the “Speed of Light” barrier is the final frontier. If you can’t beat the light, you have to outsmart it. Deterministic execution is how we win.


More to explore

Keep diving in