Chapter 356: A Few Problems
My IQ Grows Every Year by Quiet Art (介安艺)
Shenzhen, Nanshan Science and Technology Park.
Eleven at night.
An office on the twelfth floor was brightly lit. It was an open-plan workspace of more than three hundred square meters, carpeted in gray anti-static carpet. Along one side, a clear glass partition walled off an independent server room of about forty square meters.
The server room's constant-temperature, constant-humidity air conditioning gave off a steady hum. Inside, four standard black server cabinets stood side by side.
The cabinets held more than a dozen brand-new Dell commercial-grade 2U rack servers. Across their black metal faceplates, rows of green status lights blinked at an even pace.
It was the purchasing budget the company had approved just two months ago, and it had eaten nearly half the cash on the books.
Chu Ge sat at the main control computer outside the server room.
His hair was a bit of a mess, and a layer of stubble had come up on his chin.
To his right sat the company's backend lead, Lao Wang. Lao Wang wore heavy black-framed glasses and plastic slippers, and he held a can of Red Bull with the tab already popped.
Wang Xing, the man in charge of the company, stood behind their two chairs.
A dozen or so other people were in the office, sitting at their own workstations. Nobody spoke. Every so often their eyes drifted to the monitors in front of Chu Ge.
"Ready?" Wang Xing asked.
"The backend code's fully deployed to the test cluster."
Chu Ge kept his eyes on the command-line window, his hands on the keyboard.
"The front-end concurrency simulation scripts are mounted too. I've checked the parameters twice. We can start anytime."
"Start," Wang Xing said.
Chu Ge hit Enter.
Line after line of white log data began scrolling up the main screen.
"Initial concurrency, fifty thousand."
Chu Ge read the number off the parameters.
Lao Wang stared hard at a performance-monitoring screen off to one side.
"CPU usage four percent, memory usage twelve percent, average system response time eleven milliseconds."
Lao Wang read the figures off the monitor in an even voice.
"Take it to a hundred thousand," Wang Xing said.
Chu Ge typed, entered new script parameters into the terminal, and hit Enter again.
The data on the screen scrolled noticeably faster.
"A hundred thousand concurrent."
Lao Wang glanced at the monitor.
"CPU usage seven percent, memory usage fifteen percent, response time twelve milliseconds. Connection pool normal, no queue blocking."
The core servers in the server room were still running quietly, and their lights blinked at about the same rate as before.
Out in the office, a few programmers sitting farther away stood up, walked over behind Chu Ge, and watched the screens in silence.
"Three hundred thousand."
Chu Ge didn't wait for Wang Xing to say anything. He went straight on entering commands.
Three hundred thousand concurrent.
That was the real peak their live service hit during the evening rush. On the old low-level architecture they had been using all along, the system started lagging badly once traffic reached that scale, and it would even drop some requests from users at the edges outright.
The data stream on the main screen was moving too fast now for the eye to make out individual characters. It had become a blurred band of white.
Lao Wang pushed his glasses up his nose and leaned forward slightly.
"Three hundred thousand concurrent."
Lao Wang paused two seconds, waiting for the monitoring data to refresh.
"CPU usage fifteen percent, memory usage twenty-two percent, average response time fourteen milliseconds."
Lao Wang turned his head and looked at Chu Ge.
"Not a hitch," Lao Wang said.
Standing behind them, Wang Xing let out a long breath. He pulled over an empty swivel chair and sat down.
"This architecture really is something."
Wang Xing looked at the screen, his tone clearly relaxed.
"With our old architecture, by the time the stress test hit three hundred thousand, the machines' fans were already throwing alarms. Now we're not even using twenty percent of the capacity."
Chu Ge said nothing.
He knew what this architecture could really do.
It was something new, rebuilt from the lowest-level algebraic logic on the basis of those few open papers on the Boston preprint site that had recently set the whole tech world on fire.
He and his people had typed out the code line by line.
"Take it straight to our projected launch peak," Wang Xing said.
"The new service has to go out to everyone next Thursday. The entry points on all the major channels are ready. Conservatively, the moment we go live we'll get eight hundred thousand to a million concurrent in an instant. We have to find the floor today."
"Okay."
Chu Ge nodded.
He cleared the command-line history, pulled the stress-test script back up, and entered new parameters.
"One million concurrent. Ready."
The office was so quiet that the only sound was the air conditioning blowing in the server room.
Chu Ge hit Enter.
The command went out.
On the main computer's screen, the band of white data that had been racing upward suddenly stopped.
No buffering. It simply froze.
It wasn't just the data that had stopped scrolling. Even the white cursor at the end of the command line had stopped blinking.
Chu Ge was stunned for a moment, then immediately turned to the performance-monitoring screen.
Lao Wang was staring hard at it too.
In that one instant, the live line graphs on the monitor had made a jump that made no sense.
The green line for CPU usage had shot from fifteen percent straight up, vertically, to one hundred percent in an instant.
The blue line for memory usage hit the ceiling right along with it.
"What's going on?"
Wang Xing stood up. His chair rolled back half a step with a grating screech.
Chu Ge rattled off a few keystrokes, trying to bring the terminal back up or enter a forced-interrupt command.
The keyboard didn't respond at all.
The system had completely stopped responding.
At the same moment, a tremendous noise came from the glass server room just one door away.
Inside those brand-new Dell core servers, the cooling fans had all spun up to their physical limit at once, and the roar of air came right through the glass and echoed across the whole office.
"It's down," Lao Wang said.
He put down his can of Red Bull, stood, strode to the glass door of the server room, pulled it open and went in.
The moment the door opened, the huge fan noise and the hot air blasting out of the backs of the servers hit him in the face.
Lao Wang went up to the frozen core servers. He didn't bother hooking up an external monitor or keyboard to troubleshoot. One look at the fault lights on the panels told him the system kernel was completely locked.
He reached out his index finger and pressed the forced power button on a server's front panel.
He held it for five seconds.
The roar cut off abruptly.
The server room went quiet at once, except for the air conditioning.
Lao Wang let go, waited a few seconds, then pressed the power button again to boot the server.
The dozen-odd people in the office exchanged looks. The easy mood from the three-hundred-thousand stress test had vanished without a trace.
Lao Wang came out of the server room and pulled the glass door shut behind him.
"Hard reboot. Once the system's up I'll pull the kernel logs from the moment it crashed," Lao Wang told Chu Ge.
Chu Ge nodded, his eyes still fixed on the unresponsive screen in front of him.
The hours that followed were extremely long and tedious.
Two in the morning.
Wang Xing sent his assistant down to the 24-hour convenience store to haul back two cases of bottled water and a big plastic bag of instant noodle cups. They were piled on the long table in the break room.
Chu Ge and Lao Wang sat side by side at their workstations.
Lao Wang's monitor showed the system crash logs exported from the servers.
Hundreds of thousands of lines of code and hexadecimal memory addresses.
They went through the error messages line by line.
"Out of memory."
Lao Wang pointed at a key entry on the screen.
"In the second concurrent requests hit a million, the system spawned a massive number of worker threads. Memory use ate through all the physical memory and the swap partition in zero point three seconds, then Linux's self-protection kicked in, and the OOM Killer killed our main process outright."
"That's not right." Chu Ge stared at the screen.
"The whole point of this architecture is the non-contiguous algebraic cache pool. It doesn't need to open and hold a separate block of memory for every concurrent request the way our old architecture did."
Chu Ge picked up a pen and drew a simple structure diagram on the scratch paper beside him.
"Going by the logic in the paper, it should reduce the dimension of the high-dimensional matrix at the extremum point and reclaim and release resources instantly in that process. It shouldn't run out of memory."
"But the reality is it didn't release. Or rather, it didn't have time to release," Lao Wang said.
"Check the code."
Chu Ge put down the pen.
"When we reproduced the low-level logic from the pseudocode, we must have left out a reclamation mechanism somewhere, or messed up the pointer handling."
The two of them started going through the core code of the new architecture from the top.
Five in the morning.
The sky outside the window began to turn a faint grayish white.
Most of the programmers in the office hadn't been able to hold out and had fallen asleep slumped over their desks. Only a few computer screens still gave off a faint glow.
Chu Ge got up, went to the restroom, splashed cold water on his face, came back and sat down again.
Lao Wang's black-framed glasses lay on the desk. He was rubbing his eyes hard with both hands.
"Twenty-four thousand lines of core scheduling code, and we've been through it twice." Lao Wang's voice had gone very hoarse.
"No memory leaks."
Lao Wang put his glasses back on and pointed at the source code on the right-hand screen.
"The thread pool's reclamation logic matches the algebraic formula in the paper exactly. No pointers out of bounds, and not a single syntax error in the garbage collection triggers."
Chu Ge looked at the code on the screen and said nothing.
"Chu Ge, the code is fine."
Lao Wang leaned back in his chair.
"We wrote it really clean. We didn't even add a single redundant variable."
"If the code's fine, then why does it crash the moment it hits a million?" Chu Ge asked.
Lao Wang shook his head.
Eight in the morning.
People in the office woke up one after another. Some went to the break room to make noodles, some went to the restroom to wash up.
Chu Ge had them clear the cached data from the test environment so they could run the stress test again.
"Bring the concurrency parameter down a bit," Chu Ge told Lao Wang.
"Eight hundred thousand." Lao Wang entered the parameter in the terminal.
Enter.
Run.
Thirty seconds later, the server fans in the glass room were roaring again. The monitoring curves hit the ceiling, and the system hung.
Lao Wang got up and went into the server room for a hard reboot.
"Six hundred thousand."
Enter.
Run.
A minute later the fans got louder, and the system hung again.
Lao Wang went into the server room. Hard reboot.
"Five hundred thousand."
Enter.
Run.
This time, the system didn't hang right away.
Chu Ge and Lao Wang watched the monitoring screen. The system barely held on for five minutes.
But after five minutes, as data kept piling up, the average response time began to balloon from fourteen milliseconds, up to a hundred, then three hundred, and finally past five hundred milliseconds.
Right after that, the memory curve maxed out. The system ran out of memory, and Linux forcibly killed the main process again.
The test stopped.
Five physical stress tests in a row, and the result was clear.
The new low-level architecture they had spent two months developing behind closed doors, which had taken the whole technical team's effort to reproduce, had a hard limit of four hundred thousand concurrent on these servers, the best commercial-grade machines they could buy.
Go over that number, and the system was certain to crash.
Ten in the morning.
Wang Xing came in from outside. He had managed a few hours of sleep on the office sofa last night.
"How's it looking?"
Wang Xing came up behind Chu Ge and Lao Wang.
Lao Wang didn't say anything. He just reached out, tapped the keyboard, and brought up the crash log from the last stress test at five hundred thousand concurrent.
The only thing Wang Xing saw was the red word at the end: Killed.
"Still crashing?"
Wang Xing pulled over a chair and sat down.
"It can't even hold five hundred thousand?"
"It can't."
It was Chu Ge who spoke. He hadn't had any water in a long time, and his voice came out a little dry.
"You still haven't found the bug in the code?" Wang Xing asked.
"There's no bug."
Lao Wang cut in, a strong note of defeat in his voice.
"Mr. Wang, the code logic is perfect. We've checked it three times."
Wang Xing's brows knitted tightly.
"If the code is perfect, why does it crash? Is the hardware not good enough?"
Wang Xing turned to look at the server room behind the glass partition.
"What we bought is already Dell's newest server, with every memory slot filled. If it's not enough machines, I'll go buy more. Add five? Ten? As long as it solves the problem, I'll find the money."
"It's not about how many," Chu Ge said.
Chu Ge swung his chair around to face Wang Xing.
"Xing, adding machines won't help. Even if you bought twenty more of the same servers right now and put them in there, the moment it hits a million concurrent, it'll crash just the same."
Wang Xing looked at Chu Ge.
"Explain."
Chu Ge reached out and picked up a printed document from the desk.
It was a paper written entirely in English. The edges of the pages had gone a little fuzzy from being thumbed through, and it was covered in complicated mathematical formulas and algebraic-geometry matrix diagrams.
"The problem is in the underlying mathematical model."
Chu Ge laid the paper flat on the desk.
"When this three-in-one architecture handles peak concurrency, its basic principle isn't traditional queuing and dispatch at all. It takes every concurrent request that floods in at that instant, uses homology mapping to turn them into a high-dimensional algebraic matrix, and then does one instantaneous dimension reduction inside that matrix."
Chu Ge tried to explain it to Wang Xing with as little technical jargon as possible.
"Mathematically, that dimension-reduction process is airtight. It guarantees the data will never collide and never get lost."
"But the matrix is too big."
Chu Ge pointed at the server room behind the glass door.
"The Silicon Valley giants can run this architecture because they're using top-of-the-line large blade clusters, or unified memory pools on the level of a supercomputing center. Their hardware has the computing power to grind through this complicated high-dimensional matrix in a fraction of a second and then release the resources."
Chu Ge pulled his hand back.
"Our machines can't."
"The commercial servers we bought have physical limits on a single machine's CPU cache and motherboard bus bandwidth."
"When a million concurrent requests flood in at once and the system builds that huge matrix by the formula, our servers' CPUs get swamped by the sheer volume of calculation instantly."
"The CPU can't finish the matrix's dimension-reduction calculation in time, and more data keeps pouring in behind it. It all gets jammed up in memory. Three seconds, the physical memory runs out, and the system dies."
When he finished, Wang Xing was silent for a long time.
He understood.
This wasn't a mistake in his team's engineering code. It was an absolute generation gap in hardware.
It was like getting hold of a perfect blueprint for an aircraft engine, with every part's dimensions specified to the micron, when their existing machine tools were so imprecise that as soon as one spun up too fast, the parts would shatter on their own from the uneven stress.
"So we can't use this new architecture?" Wang Xing asked.
"Not unless we can come up with one or two hundred million right now to build a world-class computing cluster."
Lao Wang pulled out a cigarette, lit it, and took a drag before adding that.
The office was quiet to the point of feeling oppressive. Even the tapping of keyboards had stopped.
With startup funds of a million or so on the books, they could afford the best commercial machines on the market, but they couldn't swing this top-tier theoretical architecture.
Wang Xing leaned back in his chair, hands clasped in front of him, his eyes on the office carpet.
"The new service has to go live next Thursday."
Wang Xing's voice wasn't loud, but it was very firm.
"The warm-up campaigns are all out there already, and the server bandwidth fees are paid. We have no way back."
He looked up at Chu Ge.
"If we go back to our old architecture, how much concurrency can it take?"
"The old architecture maxes out at three hundred thousand."
Chu Ge answered bluntly, without the slightest attempt to soften it.
"Go over three hundred thousand and the system starts denying service across the board. If it hits a million all at once, it won't just deny service. The database could end up generating dirty data and losing user records."
Wang Xing closed his eyes and rubbed hard between his brows.
Go forward and it crashed. Go back and it crashed.
Lao Wang heaved a heavy sigh and stubbed out his half-smoked cigarette in a soda can beside him.
"What kind of god wrote this low-level algebraic logic, anyway?"
Lao Wang stared at the paper on the desk.
"When he derived that dimension-reduction constant, did he not care at all whether ordinary commercial hardware lived or died? The model's too heavy, too perfect. Ordinary machines just can't handle it."
"Is there any way to change it?"
Wang Xing opened his eyes, his gaze moving between Chu Ge and Lao Wang.
"Can we simplify the model? Take out some of the calculation steps we don't need, make it lighter, so it fits the hardware we have now?"
Chu Ge looked at Wang Xing, then down at the paper on the desk.
"Xing, at the end of the day, this paper is a breakthrough in mathematics."
Chu Ge's voice was low.
"I can follow the engineering logic of the discrete algebra and the homology mapping in it. I know what each step of the code is supposed to do."
"If we have to change the code, we can do that."
"But changing this mathematical model, taking apart a set of formulas that closes the loop perfectly, deleting the so-called redundant variables, and then closing it back up again in the mathematical logic…"
Chu Ge shook his head.
"Nobody in this room could do it, not even every programmer in Shenzhen put together. Touch one constant the wrong way and the whole low-level logic collapses."
Wang Xing fell silent again.
So did Lao Wang.
The servers in the server room still gave off their steady hum, the green lights blinking tirelessly. Cold air from the air conditioning came down from the ceiling vents and felt chilly on the backs of their necks.
Chu Ge sat in his swivel chair, staring at the frozen crash log on the right-hand monitor.
His gaze slowly drifted down.
It came to rest on the cover of the paper lying flat on the desk.
Under the title, 《Discrete Memory Scheduling Algorithms on the Algebraic Base》, was printed the name of the author of the cited paper, the first and only name there.
Zhuo Chen.
The name was printed in black ink on white paper, and under the incandescent light it looked unusually sharp.