36 Minutes, 1 Trillion Dollars, Zero Answers: How the 2010 Flash Crash Invented the Database That Never Forgets
When the Dow fell 1,000 points in minutes and investigators tried to reconstruct exactly what happened, they discovered a horrifying truth: the databases running Wall Street had already thrown away the evidence. The fix would change how every serious system stores truth.
2:42 PM, May 6, 2010
On the trading floor at Waddell & Reed in Overland Park, Kansas, a single algorithm began executing a $4.1 billion sell order in E-Mini S&P 500 futures. It was supposed to be routine โ a hedging trade, spread out over the day. Instead, it collided with low liquidity, high-frequency trading bots, and a feedback loop nobody had modeled.
In the next 36 minutes, the Dow Jones Industrial Average plunged nearly 1,000 points โ almost 9% of its value โ and then, just as inexplicably, recovered most of it. Accenture stock traded for one cent. Apple shares briefly traded for $100,000. Nearly $1 trillion in market value evaporated and reappeared before most humans had even looked up from their screens.
Then came the hard part: figuring out what actually happened.
The Investigators Who Couldn't Find the Truth
The SEC and CFTC spent five months producing a joint report on the Flash Crash. Five months, for 36 minutes of trading. Why so long? Because the systems involved โ exchange matching engines, broker order management systems, clearinghouses โ were built the way almost every database in the world is built: to store current state, not history.
A typical order management system doesn't ask "what was the state of this order at 2:42:15.003 PM?" It asks "what is the state of this order right now?" Every UPDATE statement overwrites the previous value. The order went from PENDING to FILLED, and the PENDING row is just... gone. Mutated into something else. The past was never a first-class citizen โ it was scaffolding, torn down once the building was finished.
To reconstruct the Flash Crash, investigators had to stitch together disparate logs from dozens of venues โ NYSE, NASDAQ, BATS, CME โ each with its own timestamp precision, its own format, its own gaps. It was less like reading a ledger and more like doing archaeology on a crime scene where someone had vacuumed the carpet.
The report's blunt conclusion: a huge, automated sell program interacting with high-frequency traders created a hot-potato effect, draining liquidity until the market broke. But the deeper, quieter lesson โ the one that rippled through systems architecture for the next decade โ was this: if your database only stores the present, you have no past to investigate.
The Insight: Stop Storing State. Start Storing Change.
There's a pattern, formalized and popularized around this same era by a programmer named Greg Young, that flips the entire premise of a database on its head. It's called Event Sourcing, and its core idea is almost insultingly simple:
Don't overwrite data. Append it.
Instead of a accounts table where balance gets updated in place โ UPDATE accounts SET balance = balance - 100 WHERE id = 42 โ you store a stream of immutable facts:
AccountOpened { id: 42, initial_balance: 0 }
FundsDeposited { id: 42, amount: 500 }
FundsWithdrawn { id: 42, amount: 100 }
FundsDeposited { id: 42, amount: 200 }
The current balance โ 600 โ isn't stored anywhere. It's derived. It's a left-fold over the event log: reduce(events, (balance, event) => apply(balance, event), 0). Current state becomes a view, not a source of truth. The events themselves are the truth.
This is the exact capability the Flash Crash investigators were missing. If every order, cancellation, and modification across every exchange had been captured as an immutable, timestamped event from day one, reconstructing 2:32 PM to 3:08 PM wouldn't take five months โ you'd just replay the log.
What You Get for Free
Once state is just a fold over events, a bunch of previously-hard problems become almost trivial:
Time travel. Want to know the exact state of an order book at 2:45:02.100 PM? Replay events up to that timestamp. Done.
Audit trail by default. You don't bolt on logging โ the log is the system. Every regulated industry's dream: banking, healthcare, insurance, logistics.
Debugging in production, safely. Pull the real event stream from prod, replay it against a new build in staging, and watch exactly where behavior diverges. No more "can't reproduce."
Free schema migrations for reads. If your reporting needs change, you don't run a risky ALTER TABLE against live data โ you build a brand-new read model and replay the entire history of events into it from scratch.
Undo, as a feature, not a hack. Since nothing is ever destroyed, "undo" is just appending a compensating event.
Enter CQRS: Splitting the Write Path From the Read Path
Event sourcing answers how to store truth. But it creates an obvious problem: folding over 2 million events every time you want to render a dashboard is insane. This is where Greg Young's other 2010 idea pairs almost too perfectly: CQRS โ Command Query Responsibility Segregation.
The idea: stop forcing one data model to serve both writes and reads. Split them.
- Command side: A client sends a command (
WithdrawFunds). An aggregate root โ an in-memory object that's rebuilt by folding over its own event stream โ validates the command and, if valid, emits a new event (FundsWithdrawn) to an append-only event store. - Query side: Separate projections subscribe to that event stream and update denormalized read models โ purpose-built for exactly how they'll be queried. Need full-text search? Project into Elasticsearch. Need sub-millisecond lookups? Project into Redis. Need complex joins for a reporting dashboard? Project into a normalized Postgres schema.
The write path and read path now scale completely independently. One durable, append-only log feeding ten different denormalized views, each optimized for a single access pattern instead of one table trying to please everyone.
Building It for Real
In production, the event store itself is usually one of: EventStoreDB (purpose-built for this pattern), Apache Kafka (treating topics as the log), AWS Kinesis, or โ perfectly legitimately โ a plain Postgres table with only INSERTs allowed, indexed on (aggregate_id, version) to guarantee ordering and optimistic concurrency.
The performance trick that makes this viable at scale is snapshotting. Nobody wants to replay 4 million events every time a bank account loads. So periodically โ every 100 or 1,000 events โ you persist a snapshot: the folded state at that version. Loading an aggregate means "load latest snapshot, replay only the events since." This is exactly how LMAX, the London-based financial exchange, built its famous Disruptor pattern โ a single-threaded event-sourced architecture processing 6 million orders per second by keeping everything in memory and treating the event log as the only durable truth.
The Honest Tradeoffs
This pattern is not free, and pretending otherwise is how teams get burned.
Eventual consistency is real and it's scary. When a write happens, the projections update asynchronously. There can be a 50-100ms window where your read model is stale. Executives watching a dashboard that "lags" the actual write will panic the first time they see it โ until they understand the write itself was never in doubt, only the view of it.
Events are immutable forever โ including your mistakes. You can't "fix" a typo in an event from 2018. You write an upcaster, a function that transforms old event shapes into new ones as they're read, or you handle the correction in projection logic. The history itself never lies, even when it's imperfect.
Storage grows forever. Every event, kept indefinitely, adds up. Teams mitigate this with tiered storage โ hot recent events in fast storage, cold historical events archived cheaply.
Walmart's inventory systems, core banking platforms processing ledger transactions, and Microsoft Dynamics 365's entire business logic layer all run on event-sourced architectures for exactly one reason: in these domains, time is not optional metadata โ it's the product.
The Legacy
Event sourcing is wildly over-engineered for a to-do list app. If your domain doesn't care about how it arrived at its current state โ only what that state is โ a plain CRUD table with UPDATE statements is faster to build and easier to reason about. Don't event-source a blog.
But for domains where regulators ask "prove it," where a trillion dollars can vanish in 36 minutes and someone needs to know exactly why, the old model โ store the present, discard the past โ isn't just inconvenient. It's dishonest. It pretends history doesn't matter until the one day it's the only thing that matters.
The Flash Crash didn't invent event sourcing. But it's the clearest proof of why it exists: when your system can only say what is, and never what happened, you haven't built a database. You've built a system with amnesia โ and sooner or later, something is going to demand that it remember.
Keep Reading
The $400 Database That Charged You to Sleep: How Neon and PlanetScale Finally Split Postgres From Its Own Hard Drive
For 50 years, a database was a machine โ you provisioned it, paid for it 24/7, and prayed it didn't fall over on Black Friday. Then a handful of engineers asked a heretical question: what if storage and compute didn't have to live in the same box?
The Pipe That Couldn't Get Bigger: How Netflix Built 100,000 Servers Inside Your ISP to Beat the Laws of Physics
In 2010, Netflix did the math and realized its video streams were about to eat more American internet bandwidth than every other service combined โ and the internet simply wasn't built to survive it. So they built their own.
The Green Dashboard That Lied: How OpenTelemetry Killed the Logging Era and Taught Us to Ask Questions We Never Thought to Ask
Your dashboard says p99 latency is 800ms. Your customer says checkout took 45 seconds. Both are true. This is the story of how a messy 2019 merger of two rival projects quietly ended the vendor lock-in wars and rewired how the internet debugs itself.