Skip to content

Chapter 3: Splitting the Tree & the Audit Storm

August 2001, Redmond, Washington.

The burst of the dot-com bubble had just left a trail of corpses across Silicon Valley, but inside GenesisSoft Building 113, Silas Horn's Web Incubator stood tall against the trend, thanks to its "barbaric growth" over the past two years. A tens-of-millions strong user base meant that "Hello World" was no longer an experimental project; it had become the company's star asset.

But with this bloated scale, the most suffocating monster of the tech giant finally caught the scent of blood and came knocking at the door—Compliance & Legal.

"A six-hundred-page government security review order."

Silas slammed a thick stack of documents heavily onto the conference table in the War Room, his face ashen. Sitting across from him were several senior technical experts from the Architecture Committee, along with GenesisSoft's proud Chief DBA (Database Administrator)—Vince.

"Last week, someone used our V2.0 system to send Hello data containing racial hate coordinates," Silas said through gritted teeth. "Now, those politicians in Washington D.C. are demanding that we deploy V3.0 - Full Audit Logging System. Starting today, every single Hello submission, no matter how tiny, must leave an immutable Audit Log. Timestamp, user ID, IP coordinates, original Payload—not a single byte can be missed!"

"This poses zero technical difficulty." Chief DBA Vince pushed his gold-rimmed glasses up, his tone carrying the arrogance of a defender of traditional relational databases. He represented that group of low-level data clerics who treated ACID (Atomicity, Consistency, Isolation, Durability) as a religious faith.

"We simply need to create a new massive Audit_Logs table in the core SQL Server instance. When the business side writes the Hello data, they can use the same database connection to conveniently INSERT a log record into this table. The enterprise-grade database transaction mechanism will guarantee that these two pieces of data live and die together. Absolutely safe, absolutely compliant." Vince was brimming with confidence.

Sitting in the corner, Simon Li slightly furrowed his brow.

As a Senior Software Engineer, he understood the importance of Observability better than anyone. If business code was the flesh and blood of humanity, then Logs were the foundational olfactory genes proving this body was once alive and hadn't developed cancer.

But he also understood the cruel laws of the physical world far better.

"Vince, current concurrent writes are at five thousand per second," Simon spoke up coldly. "Adding audit logs means over ten thousand disk writes per second. Moreover, the primary key of the log is a randomly generated UUID. You are forcefully taking a power drill to a perfect crystal."

"Simon, I know you have a knack for stateless servers, but please don't lecture me in the database domain," Vince retorted dismissively. "The underlying enterprise SAN storage array is worth tens of millions of dollars. It can handle it."

Silas impatiently interrupted them both: "I don't care how you write it, Legal needs to see all logs hit the disk by tomorrow! Deploy it immediately!"


Disaster struck exactly thirty minutes after V3.0 went live.

2:00 PM, the tail end of the morning traffic peak. Simon was holding a cup of coffee, walking past the War Room's glass wall, when suddenly, a violent roar echoing from the depths of his brain threatened to tear his nerves apart!

Buzz—Crack!

This was no auditory hallucination. In Simon's Synesthetic vision, the floor of the entire server room was vibrating violently. He "smelled" an extremely pungent odor of burnt metal, like a grinding wheel tearing into steel at high speed. It was the scent of underlying storage resources being squeezed to the absolute brink of death.

"Alert! The core database's write latency per second is spiking, TPS is falling off a cliff!" The on-duty operations engineer screamed in terror, his voice echoing through the War Room. "CPU load has surged to 98%, but there are no queries executing! The entire database is gridlocked!"

The coffee cup in Silas's hand dropped to the floor with a crash. Scalding liquid splashed over his leather shoes, but completely oblivious, he rushed straight to the main monitoring screen: "What happened?! Did we get killed by a lock escalation again?"

"It's not a lock escalation..."

Simon threw away his coffee, enduring the agonizing pain in his head that felt like a series of collapsing buildings, and slammed both hands onto the console keyboard. Within the grating of his synesthesia, he witnessed a scene of destruction that was extremely horrifying yet physically beautiful.

To ensure ultra-fast querying, traditional relational databases use a data structure at the bottom layer called a B+Tree (B-Tree). It's like a perfect crystal tower built from countless 8KB "Data Pages." Inside this tower, data must be strictly arranged in order.

But now, with the frantic influx of high-frequency, massive audit logs bearing random UUID primary keys, this crystal tower was facing an apocalyptic disaster.

Every random write was like a raging high-speed drill ruthlessly piercing deep into the crystal tower. Due to insufficient space, the originally packed 8KB data pages were violently torn apart and split in two—this is the most expensive, most fatal physical operation at the database's lowest level: the Page Split.

"Page Split Storm..." Simon gritted his teeth, staring at the frantically surging Page Latch Waits instructions on the screen. "Vince! That stupid log table of yours is murdering the core business! Thousands of page splits are happening every single second!"

In the synesthetic world, with every page split, the database engine had to rapidly suspend incredibly heavy "Latches" in the memory buffer pool to prevent the crystal tower from collapsing. Concurrent requests were forced to queue up waiting for these physical-level memory locks. The entire database was like a steel behemoth whose countless tiny gears had completely jammed and crumbled due to congestion, letting out a roar of despair.

"This is impossible! The ten-million-dollar SAN storage array comes with a massive hardware write cache, it can absolutely digest this IO pressure!" Vince was sweating profusely as he hammered the keyboard, staring pale-faced at the throughput plummeting to zero.

"That is the tragedy of underlying architecture! Vince!" Simon roared, pointing to the surging CPU queue on the system monitor. "The ten-million-dollar SAN storage can indeed handle pure writes, but the bottleneck right now isn't the disk at all! Your data hasn't even flowed down to the external storage yet!"

Simon's voice echoed in the server room, every word striking like a dagger: "The real deadlock is in the memory! With every page split triggered by a random UUID insertion, the engine must apply an Exclusive Latch to those few pages of B+Tree nodes in memory! This is an extremely expensive, overwhelmingly tyrannical serial operation! One hundred thousand write requests are trampling over each other because of random key values, fighting over these few tiny memory page locks. This is equivalent to you brutally suffocating the terrifying computational power of a tech giant's multi-million-dollar hardware inside a mere 8KB data grid in memory!"

eBay suffered a catastrophic 22-hour outage in 1999 due to similar massive updates, and now, GenesisSoft was repeating the exact same fatal mistake.

"Stop writing logs immediately! Drop that table!" Simon turned to Silas.

"Absolutely not!" Silas stared at the screen like a cornered wolf. "The Chief Legal Officer is right upstairs! If I turn off the audit logs, federal agents will be here tomorrow to seize our servers! The system can lag, but we absolutely cannot illegally disconnect the logs!"

Caught in a dilemma. A true deadlock. Don't write the logs, die by lawsuit; write the logs, die by system crash.

"Fine."

Simon took a deep breath. His hands, which had been trembling from the severe pain, suddenly became incredibly steady. A desperado-like iciness flashed in his eyes.

He shoved aside the already panic-stricken Vince and sat at the main console.

"What are you doing?!" Vince watched in horror as Simon invoked the highest-level system management terminal of SQL Server. "Don't mess with core parameters! ACID is our bottom line!"

"To hell with ACID."

Simon's hands became a blur on the keyboard. He knew that in the face of physical laws, any attempt to optimize ultra-high-frequency random writes on a B+Tree was futile. As long as that fragile crystal tower existed, the system's concurrency ceiling would be gridlocked by "Latches."

To save the business, the only way was a dimensionality reduction strike: bypass the database engine and completely abandon the tree structure. Downgrade all "random writes" into the most primitive "Sequential I/O (Append)".

Simon typed out a line of command that would induce cardiac arrest in any security engineer or DBA:

EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;

"You're crazy! You've lost your mind!" Vince retreated in terror. "You actually enabled xp_cmdshell! This is the most dangerous system-level backdoor at the base of SQL Server! A hacker only needs to inject one line of code to directly bypass privileges and take over the underlying command line of the entire operating system!"

But Simon completely ignored him. Like a geek walking a tightrope in a hurricane, he used this super backdoor to hand-roll a C++ Extended Stored Procedure right there in memory.

He bypassed the bloated, old-school database core engine (SQL Engine) fraught with consistency checks altogether. He bypassed that shackled B+ crystal tower.

His code was incredibly brutal, incredibly primitive. When the business end tossed over the long audit log, Simon's malicious hook intercepted this string and, bypassing the database table file entirely, tossed it like a sandbag, appending it to the very end of a plaintext .txt file on the most peripheral physical disk!

In his synesthetic world, that violently rampaging high-speed drill vanished instantly.

Taking its place was an extremely smooth, unobstructed high-speed conveyor belt.

No page splits, no B+Tree merges, no life-and-death struggles for latches. The system didn't need to maintain any advanced structures, didn't even need to reorganise magnetic heads and memory pages. Like a tireless vintage typewriter, it just blindly wrote down along the end of the paper tape!

An infinitely extending simple paper tape. Append-Only Log.

"Beep—"

The very instant the code took effect. The Page Latch Waits queue, which had been locked at 100%, plummeted completely straight down to under 5%, as if jumping off a cliff! The drained CPU load instantly dropped back to 10%. The TPS (throughput per second) curve shot upward like a beast released from its cage, directly breaking through the 20,000 threshold! The entire core transaction system recovered its incredibly fluid vitality.

"It recovered... the pressure is gone..." The on-duty operations engineer rubbed his eyes in disbelief. "Simon, what did you do? None of the log data is in the database table anymore!"

"I wrote them into a continuously appending text file." Simon let out a long breath of stale air. The pain from his synesthesia receded like a tide, replaced by an ultimate sensation of smoothness.

"Without the complex structure maintenance of a B+Tree and frequent latch contention, we only retain the purest form of data persistence. The throughput of Sequential I/O (Append) is a dimensionality reduction strike against random writes." Simon stood up, looking coldly at the dumbfounded Vince. "Right now, even if you pull out the crappiest, cheapest IDE physical hard drive on the market and use this idiot-proof sequential append logic to write to it, whether at the disk level or the memory operation level, it will be infinitely faster than a ten-million-dollar database system bogged down in the mire of concurrent page splits."

The entire War Room fell into a deathly silence.

Everyone was shocked by this subversive realization. The sacred tenets that relational databases had defended for decades had been ruthlessly shredded by a twenty-something young man using the most fundamental physical awareness and a highly dangerous backdoor code.


Early the next morning.

The door to the GenesisSoft CTO's office was nearly kicked to pieces by a furious Vince.

"Fire him! Fire Simon Li immediately!" Vince roared, spit flying as he pointed at the security audit report in his hand. "To solve an IO problem, he actually enabled xp_cmdshell in the production database! He even bypassed the database transaction engine and wrote compliance data into a garbage text file with no indexes, unsupported by complex SQL queries! He is a literal system terrorist!"

Silas sat on the sofa, slowly sipping his coffee. Although he had been scared half to death yesterday, the reports this morning pleased him greatly.

"Calm down, Vince." Silas put down his cup. "Legal just checked that file this morning. Every single log is honestly lined up inside in chronological order, not a line missing. It fully complies with the immutable audit requirements."

"But that's not structured relational data! That's a garbage dump! What if they want to search for a specific log by user ID later? Do a full table scan on a pure text file as massive as a mountain range?!" Vince bellowed.

The door was pushed open, and Simon walked in with dark circles under his eyes.

"Searching it is a problem for the future." Simon's voice was as calm as stagnant water. "In a high-concurrency scenario with massive writes, the storage engine's absolute first priority is to receive the data as fast as possible and get it onto the disk alive. The cost of reading and writing can be completely decoupled. At worst, we can just add asynchronous threads in the background later to slowly pull down this text file and rebuild a distributed memory index."

Vince froze. He acutely perceived that the heretical structure Simon was describing—"brutally append-write logs first, then build read indexes asynchronously"—completely deviated from traditional relational database theory.

But this was exactly the storage philosophy of the next era that Simon had realized during his life-and-death synesthetic trance last night. It was also the underlying foundation that had to be built to support high-dimensional telemetry data in the future.

Many years later, top engineers at tech giants would take this "heretical idea" that Simon was forced to hand-roll last night and carry it forward. They would name it LSM-Tree (Log-Structured Merge-Tree) and build stream processing systems around it, thus birthing the cornerstone of the Big Data era that would rule the universe.

But on this morning in 2001, Simon had merely used his livelihood as a bargaining chip to win this battle for resource bottom lines.

"Silas." Simon looked at the secretly rejoicing ambitionist. "I will close the dangerous backdoor and clean up immediately. But you must understand, by bypassing the engine to write logs directly to an external file, while we saved the database engine, we have actually torn an extremely uncontrolled breach outward into the system."

Simon paused, his eyes seemingly seeing through to future disasters.

"We traded the security of the architecture and the purity of the system boundaries for throughput. One day, we will pay a brutally painful price for this."

Silas waved his hand dismissively: "Future problems are for future budgets to solve. Well done, Simon."

At the exact moment Simon turned to leave the office, the high-dimensional fractions hidden within the low-level memory of hundreds of thousands of heterogeneous computers globally recorded, in dead silence, a precious set of telemetry data regarding the ultimate latching frequency of Earth's storage mediums.

The observation of the high-dimensional probe had advanced yet another towering architectural milestone.


Architect's Note / Post-Mortem

Document ID: PM-2001-08-03 Incident Grade: SEV-1 (Core system unavailable) Owner: Simon Li (Senior SDE)

1. What happened? After the V3.0 full audit log system went live, the core SQL Server suffered a massive concurrent deadlock, TPS plummeted to zero, and the piling up of massive write requests caused a service avalanche.

2. Root Cause (5 Whys)

  • Why 1: Why did TPS drop to zero? Because all insert operations were suspended; engine monitoring showed lethal levels of Page Latch Waits.
  • Why 2: Why were there such extreme page latch waits? Because the newly added Audit_Logs table was receiving tens of thousands of writes per second, triggering massive low-level "Page Splits."
  • Why 3: Why were frantic page splits triggered? Because the primary key for the audit logs was a randomly generated UUID (instead of auto-incrementing ordered integers). Disordered data had to be forcefully squeezed into the middle of already-full B+Tree nodes, forcing the physical storage structure to perform splitting and reorganization operations.
  • Why 4: Why couldn't the SAN storage rely on hardware to endure the concurrency? Because the bottleneck occurred before the data even truly hit the disk. While reorganizing the B+Tree structure in the memory buffer pool, the CPU had to apply tyrannical fine-grained mutually exclusive locks (Latches). This is a compute vacuum deadlock at the level of memory lock contention, utterly unrelated to hard drive read/write speeds.
  • Why 5: Why were we forced to face this risk with such an architecture? A fundamental misjudgment in system design occurred. We mistakenly merged "massive log streams possessing black-hole-level instant write characteristics" together with "transactional scenarios requiring strong consistency/strong structure queries," dumping them into the same old relational storage base pool without isolation.

3. Action Items & Architecture Decision Record (ADR)

  • Workaround & Hotfix: Emergently enabled xp_cmdshell to bypass the congested and collapsing B+Tree engine mechanisms, converting pure random write requests into OS-level, plain text Sequential Appends targeted at the file system.
  • Long-term Fix - ADR-003:
    • Prohibit Strong Coupling: Thoroughly strip massive telemetry (Metric/Event Logs) out of the core relational database.
    • Adopt Append-Only Log Model: Establish that pure "infinite append streams" hold a dominant advantage in high-survival and low-consumption for massive high-frequency burst scenarios. Build buffering mechanisms capable of receiving massive flows of non-critical-structure data.

4. Blast Radius & Trade-offs Forcefully relying on a backdoor broke the logical boundaries that were originally completely converged, isolated, and bound within strict database sandbox walls. It introduced highly sensitive bare external dependencies on the system's bottom layer (OS I/O), leaving the application ecosystem's security attack surface wide open. This method of tearing down boundaries in exchange for survival vastly expanded the incubation zone of unknown future disasters.


Architect's Note: Connecting Past and Modern System Design

When reading this chapter, many engineers accustomed to modern, high-spec cloud-native environments might harbor a misconception: Since we have already eliminated ancient Hard Disk Drives (HDDs) today, fully popularized light-speed Solid State Drives (SSDs), or even directly connected PCIe NVMe and Optane god-tier drives, and "physical magnetic head seeking" simply doesn't exist on hard drives anymore, with read and write speeds growing explosively, why do we still fear UUID random writes today? Why must we still learn from Simon's design philosophy of "Sequential Append"?

This is an extremely classic cognitive blind spot in modern systems: Even though physical hard drives eliminated the mechanical arm, the underlying data structures of database engines and the physical iron laws of operating system memory management have never changed.

  • The True Poison of Random Key Values: B+Tree Latch Contention As shown in this chapter, when you use randomly generated UUIDs as primary keys in MySQL (InnoDB) or SQL Server, because the new data is extremely disordered in sorting, it constantly forces itself deep into specific internal positions of already tightly packed B+Tree nodes. This inevitably causes the engine to execute brutal "Page Splits." In the instant of severing and rebuilding the pointers of these two pages in memory, even if the underlying layer is lightning-fast NVMe, the CPU must use an Exclusive Latch to dead-lock the corresponding memory structure to maintain atomicity. Ten thousand concurrent machines fighting for these exclusive latches in memory will forge an utterly terrifying performance collapse (this is what DBAs often refer to as Hot Block Contention and CPU Spiking).

  • SSD Wear and Write Amplification SSDs are not omnipotent. Although solid-state drives have no magnetic heads, the nature of their flash memory cells dictates that they can only read by Page, and must perform far more time-consuming Erases by large Blocks before they can rewrite. Extremely dense random 8KB fragment writes force the SSD controller (FTL) to constantly move data around and perform garbage collection, leading to extreme "Write Amplification." The ultimate result is that top-tier solid-state drives are forcefully dragged down to the speed of a slow USB stick, or even worse, their P/E endurance cycles are exhausted in a very short time, leading to direct destruction. Therefore, for SSDs, smooth, continuous, large-block sequential writing remains the friendliest mode with the highest performance ceiling.

  • Modern Big Tech Architectural Evolution: LSM-Tree and Log Streams The brutal philosophy Simon adopted back then under extreme pressure—"Convert random writes into unobstructed Append-Only Logs, then build read indexes asynchronously"—is precisely the undefeated truth of modern large-scale infrastructure that later directly ruled the entire data era! The ultimate secret as to why today's NoSQL kings (HBase, Cassandra, RocksDB, TiDB) can carry astronomical amounts of concurrent data is the LSM-Tree (Log-Structured Merge-Tree). It discarded the heavy, real-time in-place modification/updates of the B+Tree; instead, like Simon, it mindlessly piles data sequentially into memory, and when full, flushes it to the end of the disk as read-only stable files. As for the flat data conveyor belt that Simon forcefully forged for his logs, if translated into an independent cluster network facility a decade later, it becomes the main artery you use every day to handle terabytes of telemetry data, the God of high-throughput peak-shaving—Apache Kafka. Simon's thought that "at worst, we can just parse the indexes slowly in the background later to handle crazy queries" is exactly the asynchronous consumption responsibility for full-text search borne by Elasticsearch (ES) in modern enterprises. This is why the truths of architecture are eternal: physical structures determine the ceiling. Learn to bow to unchangeable physical limits.