Skip to content

Chapter 16: The Monster Middle-Platform and 150-Degree Fan-out

Autumn 2013, Redmond, GenesisSoft Headquarters.

If you had asked Silas Horn three years ago what architectural design he was most proud of, he would definitely have pointed to the three hundred fragmented microservices and said, "Agility."

But over the past few years, these three hundred microservice teams, each fighting their own battles, had grown wildly across every floor of the company like cancer cells. Every team had their own agenda, constantly reinventing the wheel: the login module was written ten times, and the payment interface was encapsulated in twenty different versions.

To solve this organizational chaos, Silas hired a new CTO from a Silicon Valley giant last year. The first thing this CTO did upon taking office was to unveil the most fashionable artifact in the corporate world at the time—the "Grand Middle-Platform Strategy".

"We are going to knit all the common business logic together! All posts, comments, and user information will be entirely centralized into a unified 'Core Biz Service'!" The CTO declared passionately at the all-hands meeting. "From now on, frontend teams only need to call one single God API from the middle-platform. The middle-platform will handle all the remaining messy details at the bottom layer for you!"

Simon Li watched this "Great Unification" movement coldly from the sidelines. He had privately warned the CTO: "If you forcefully twist the originally clean mesh of calls into an inverted triangular Aggregator, you are actually artificially creating an absolute performance black hole."

But no one listened to him. The middle-platform team became the brightest stars in the company, working day and night to stuff code and logic into that "God API" which claimed to solve all problems.


The climax of the disaster occurred on a weekend, half a year after the middle-platform went live.

On this day, the marketing department launched a "Light up the Global Hello Badge" campaign. As long as users opened the homepage, they could see the latest updates and badges of dozens of friends.

To allow the frontend page to instantly present this incredibly rich information, the frontend gateway called the most famous API of the middle-platform: /api/v1/user/aggregated_feed.

Theoretically, after receiving this request, the middle-platform would very "thoughtfully" call the underlying user service, friend service, badge service, image service... separately, and then assemble them into a gigantic JSON payload to feed to the frontend.

When the first user opened the homepage.

In Simon's synesthesia vision, he saw that the so-called "core middle-platform" was not an elegant transportation hub at all. It was a multi-armed Avalokitesvara capable of performing magic tricks, but today, its arms were outrageously numerous.

When a single, solitary external query request (for example: show me what happened to John Doe and his 10 friends) smashed into the middle-platform.

The middle-platform's internal code started spinning: First, it used 1 request to query John Doe's friend list (pulling up 10 people); Then, it ran a for loop, sending 10 requests to the underlying "user information microservice" to retrieve the basic profiles of these 10 people; Following that, it ran a nested for loop, sending 100 requests to the "badge microservice" to check the 10 possible badges these 10 people might be wearing; Finally, there were another 30 requests to fetch recent image URLs...

"Simon..." The voice of Dave, the Ops Lead, trembled with extreme terror in the War Room. "The underlying database clusters and over a dozen main microservice arteries have all been punched through by red lines in a single second! CPUs are instantly dropping 100% max load alerts!"

"How much traffic came from the outside?!" Silas asked immediately.

"Outside... there are only 10,000 QPS (Queries Per Second) coming from the outside." Dave felt like his eyes were deceiving him because, on that giant topology map, a scene that severely defied common sense was playing out. "But... the internal QPS initiated by the middle-platform down to the underlying microservices... has exceeded 1.5 million!"

"Fan-out Effect."

Simon stood up abruptly, a trace of sorrow flashing in his eyes; the physics punishment he feared most had still descended.

"In distributed computing, when an external request hits, in order to assemble complex data, it needs to initiate N subsequent queries to the bottom layer. This ratio is called the Degree of Fan-out."

Simon pulled up the Distributed Trace of that "God API": "Look at what the middle-platform developers have done! To let the frontend get all the data in one go, they wrote incredibly stupid, fragmented calls in this API—serial plus nested parallel calls with zero concept of Batching. When one request comes in, the middle-platform fans out 150 micro-queries to the bottom layer!"

In the blinding glare of his synesthesia, a scorching 150x amplifier was frantically destroying the data center.

The robust underlying microservice cluster, which originally could have handled hundreds of thousands of concurrent requests, was instantly back-pressured to explosive failure by this kind of "nanny-style," extremely fragmented calling pattern from the middle-platform.

This is the most classic performance tumor in microservice architecture: the ultimate amplified version of the N+1 Query Problem at the network RPC level.

"Then just add more machines to the underlying services! Scale-out!" The CTO rushed into the War Room, still trying to defend his middle-platform's dignity.

"Scale-out my ass!" Simon roared back. "This isn't about lacking compute power at all! This is the direct strangulation of this massive fan-out by the law of Long-tail Latency!"

This was extremely high-level system common sense. When the fan-out degree reaches 150, even if the reliability of every single underlying microservice is an astonishingly high 99% (meaning each call has only a 1% chance of timing out or responding slowly).

But mathematically speaking, the probability of the entire massive API call succeeding becomes: $(0.99)^{150} \approx 0.22$.

This meant that this arrogant "God Aggregation API" had a pitiful true success response rate of only 22%! The remaining 78% of users would have their entire page's final rendering completely stuck just because even one tiny service out of those 150 underlying calls suffered a 1-second stutter.

"A wooden barrel doesn't just have a short stave," Simon stared at the CTO, his voice freezing. "When your barrel is made of 150 wood planks patched together, as long as any single plank leaks, your entire barrel is wasted. High fan-out is inherently an active embrace of Murphy's Law!"

The War Room fell into dead silence. Everyone was crushed by this cold mathematical formula.

"Now... what do we do? The system has completely locked up, the whole site is a white screen," Silas's face was livid.

Simon took a deep breath, suppressing the sensation of a thousand arrows piercing his heart caused by the web-tearing feedback of his synesthesia.

"Step one: Split the aggregation, degrade and fallback."

Simon directly seized master control, beginning to perform live hot surgery on the middle-platform gateway that was on the verge of collapsing.

"Immediately sever the real-time fetching for all non-core links like the 'Badge Service' and 'Image Computation Service' at the gateway! Set up a strict time wall—if core user information doesn't return within 50 milliseconds, suspend and wait; but for the dozens of other non-core peripheral requests, wait no more! If they time out, return null immediately!"

Simon was forcefully snipping the redundant planks that were causing the barrel to leak. The page restored display a few seconds later. But because dozens of peripheral data points had been forcibly discarded, it morphed into an extremely barren, "beggar's version" of a page.

"This page is too ugly! The user experience is totally ruined!" a marketing executive complained over the phone.

"At least they can read the text, instead of a 503 error," Simon mercilessly hung up the phone.

During this rescue operation, Simon keenly detected the low-frequency vibration of the higher-dimensional probe. This was no longer an exploration of the physical limits of hardware, but pointed directly at the deeper system organization theory and topology.

In the early hours of the morning, as the War Room regained its calm. Simon stood alone in front of the holographic whiteboard and drew two diagrams. One was the original, clean, but siloed microservice mesh diagram. The other was today's funnel diagram of this giant "Monster Middle-Platform" that attempted to govern everything but became a disaster amplifier.

Silas walked over carrying two cups of coffee, handing one to Simon.

"Simon, is the middle-platform strategy wrong? If dividing things into frontend, middle-platform, and backend is wrong, how on earth should we manage these three hundred microservices?" Silas's tone revealed exhaustion and confusion.

Simon took the coffee, looking at the code repository commit logs on the screen. In this colossal middle-platform codebase, hundreds of programmers were overwriting each other's code and arguing over requirements every single day.

"Silas, have you ever heard of Conway's Law?"

Simon heavily wrote down on the whiteboard this ultimate curse that had dominated software engineering for fifty years.

"'Any organization that designs a system will produce a design whose structure is a copy of the organization's communication structure.'"

"What does that mean?"

Simon pointed at that bloated middle-platform icon. "You forced one team (the middle-platform organization) to bear the extremely complex communication and iteration between all other thirty frontend teams and fifty backend teams. Biologically speaking in terms of an organization, it is a complete Bottleneck."

"These thirty frontend teams have countless new requirements to add every day, and they are all squeezing in to queue at the desks of the middle-platform developers. To cope with these never-ending demands, the middle-platform team has no choice but to stack if-else blocks day after day inside that 'God API' like piling up trash."

"Code bloat is essentially a projection of failed communication in organizational structure." Simon's eyes were piercingly clear. "We are trying to use code to solve problems of corporate politics and departmental silos. This gave birth to today's monster with a 150x fan-out."

Simon aggressively circled that giant middle-platform and then struck a massive red cross through it.

To defeat this monster spawned by human greed and inertia, they had to return to the most ruthless, unyielding essence of distributed systems—physical isolation and business autonomy.

And this was exactly the dawning light of the next phase, Volume Three.

If the ocean of microservices was destined to evolve into a mutually dragging abyss; If middleware and middle-platforms only caused the blast radius to be reverse-magnified back to the global scale.

Then the sole ultimate antidote was to pack them into extremely tiny, yet fully functional, and absolutely mutually isolated vacuum capsules.

In his subconscious, Simon faintly saw that future matrix beckoning to him—10,000 absolutely isolated Cells (Units/Pods), free of any mesh intersections and middle-platform dependencies.

That was the ultimate armor to choke off the blast radius, and also the final form that would allow the higher-dimensional algorithm to see the light of day again.

But before advancing into the true "Cell" era of Volume Three, Simon still had to resolve the massive operations hell generated by these three hundred microservices zooming around in the cloud like flies every single day.

He must first build a physical foundation that could forcefully load these microservices into standardized shipping containers—an automated legion of containers and orchestration.

That would be the story of Chapter 17.


Architecture Decision Record (ADR) & Incident Post-Mortem

Document ID: PM-2013-10-09 Severity Level: SEV-1 (Core aggregation layer dragged down by long-tail latency, instant global site freeze/downtime) Lead: Simon Li (Principal Engineer)

1. What happened? The frontend initiated a request to the "Core Biz Service" (middle-platform). To achieve "one-stop data aggregation" (providing full user info, feeds, badges, etc.), this middle-platform API utilized a mix of serial and parallel logic on the backend to launch up to 150 internal RPC calls to peripheral microservices. This extreme Fan-out Effect not only instantly pushed the QPS of underlying basic microservices to a hundred times their max capacity, but also caused the response time of this single aggregated API to be infinitely stretched out by any minor unstable node at the bottom layer (the killer effect of long-tail latency), leading the middle-platform Tomcat connection pool to be fully exhausted and crash within dozens of seconds.

2. 5 Whys Root Cause Analysis

  • Why 1: Why did supposedly small frontend traffic crash the microservice cluster? Because the critically important middle-platform aggregation gateway API generated a 1-to-150 external-to-internal traffic amplification multiplier—Fan-out Effect.
  • Why 2: Why did the middle-platform API fan out so many times? To fulfill the frontend's extreme demand for "bulk fetching," and due to the failure to logically consolidate underlying microservice queries with batch combinations—Batch API. This was the eruption of the classic N+1 API Call Problem in microservices.
  • Why 3: Why did the middle-platform lock up while the bottom layer didn't actually crash? This is the extremely obscure probabilistic assassin of distributed systems: Tail Latency. When a massive API strictly depends on 150 small APIs returning harmoniously... If just one out of the 150 underlying machines stutters for 500ms due to a JVM Garbage Collection (GC) pause, the return time of the entire massive API will be permanently dragged beyond 500ms.
  • Why 4: Why was such a deformed, "heavy aggregator" allowed to exist in the intermediate zone? Because of a blind faith in the "Grand Middle-Platform" concept, forcing the formerly lightweight orchestration of microservices (BFF - Backend for Frontend) into a unified, monolithic giant dispatcher center.
  • Why 5: Why was such an architecture designed in the first place? This is the systemic backlash of Conway's Law. To resolve complex frontend-backend communication and coordination issues, the company forcefully mandated a centralized, consolodating "Middle-Platform Department." Consequently, the physical form of this department's code inevitably evolved into a bloated, coupled Central Single Point of Failure (SPOF) that violates the original intention of decoupling.

3. Action Items & ADR

  • Workaround: Urgently severed RPC request blocking/waiting for non-critical peripheral assets (like badges, unimportant ad tags) inside the aggregation API, implementing a forceful Timeout & Fallback drop cut-off to salvage the throughput of core communication links.
  • Long-term Fix:
    • ADR-016A: Absolute prohibition of giant aggregator fan-outs. Promote adopting BFF and experimenting with GraphQL. Giant aggregator monsters will no longer be permitted in deep infrastructural waters. Data assembly should be lightweighted by dedicated BFF proxy layers located extremely close to the frontend. Underlying services must provide Batch Get API support to eliminate parallel isolated looped queries.
    • ADR-016B: Systemic defense boundary for controlling Tail Effects—Hedged Requests. If long-tail probabilistics still exist at the extremely sensitive fan-out bottoms, introduce low-level hedged request mechanisms: trailing just after an ultra-small delay threshold (e.g. the P95 line) of unreturned responses, the framework instantly fires identical duplicate queries to another healthy microservice replica within the cluster—whichever returns first wins. Use minor concurrent CPU redundancy to brutally sever the fatal long-tail latency delays.

4. Blast Radius & Trade-offs The distributed ocean is not a utopia where "stuffing in machines equals infinite performance scaling." The massive internal mesh friction drag and the long-tail probability multiplier laws will cold-bloodedly crush the dreams of centralized management into powder. We attempted to use the middle-platform to conceal the clutter, but practically, we re-lashed the life and death of the entire network rigidly onto a single, uniquely fragile core bottleneck.


Architect's Note: System Design Connecting Past and Present

1. The Invisible Assassin in Microservices: The N+1 Problem and Request Amplification When writing monoliths (like PHP/Java connecting to old MySQL). If we want to query a list of 10 people and bring along their avatars. A novice might query the list table once, and then pull a for loop to query the database 10 times carrying the IDs. This is called the N+1 problem. Because the database is right next door, the performance is garbage but somewhat tolerable. But if placed in a modern microservice or even cloud-native network. Your single external HTTP request gets forcefully pulled into a terrifying for loop at an intermediate gateway, subsequently dispatching hundreds of high-latency internal network RPC calls (inter-microservice inquiries) in all directions. This is wildly dangerous fan-out amplification. In high-pressure environments like Alibaba or ByteDance, this sort of code would instantly blow up clusters and trigger downtime during stress testing; it represents an absolute architectural red line that must be ruthlessly culled. The countermeasure: you must utilize IN (Batch Retrieval APIs) to forcibly compress the fan-out!

2. The Foundation of Jeff Dean's Paper: Tail Latency and Its Remedies The mathematical equation referenced in this chapter—where a 99% survival rate plummets to 22%—is precisely one of the deepest distributed pain points highlighted by legendary Google architect Jeff Dean in his acclaimed paper The Tail at Scale. Because computer hardware (SSD seek jitters, NIC packet drops, or Java/Go running GCs) will always statically suffer from brief stutters to a certain degree of probability. When your system relies on synchronizing and collecting results from thousands of such hardware components to summon a unified response, you are guaranteed to step in those stutter probabilities forever. To solve this—which doesn't even throw an error but merely hangs and drags down operations (which is far more destructive to the system than just outright dying)—major tech companies invented the renowned Hedged Requests algorithm: When you fetch data from Server A and it delays for 20ms (meaning it might be stuttering on GC), don't wait indefinitely; have the framework directly fire off an identical exact request to Server B within the same cluster group. Whichever finishes and returns first (A or B), immediately abandon the other. By expending incredibly cheap and minor network bandwidth, it effectively paves over the fatal latency risk where "one single machine taking a nap" might otherwise nuke your entire system's overall response time. This is the mandatory maneuver Simon must use when fighting at limits trying to tame distributed systems.