GBase Rescue Report: Midnight Crisis in Core Module Resolved Through Precision Performance Tuning

Published on 2025-07-04

At three in the morning, inside the duty room of a provincial-level power dispatch center, operations engineer Lao Zhang was frantically typing at his keyboard. On the screen, the historical data curve for the core business system remained completely blank, while the application log was flooded with dense "Error 25571 — Unable to create user thread" messages, each one like a blaring alarm jangling everyone's nerves.

"If this keeps up, the dispatchers won't be able to review historical load data, and if a sudden emergency strikes..." Before Lao Zhang could finish, the office door swung open. GBase 8s technical expert Xiao An strode in with his laptop. "Stay calm. Let's first check the database status." 

 

On-Site Investigation: Hidden Risks Behind a Normal Appearance

The first thing Xiao An did was log into the database console. "Session count is 123, still far from the upper limit," Lao Zhang explained, standing nearby. "But new connections just won't establish. The online log keeps reporting shared memory allocation failures."

Xiao An pulled up the database log, and a red error line stood out starkly:

"The server could not allocate shared memory because an operating system limit was reached."

"It's not a database issue. The operating system is creating a bottleneck," he said while typing sysctl -a | grep kernel.shm to inspect the system parameters.

The values that popped up on the screen made Xiao An frown: kernel.shmall was set to only 200000, and the kernel.sem configuration was "100 2000 50 100."

"There's your problem," he said, pointing at the screen and speaking to Lao Zhang. "The shared memory page limit and semaphore configuration are both way too low. The memory the database needs exceeds the system's quota, so new connections naturally can't get any resources."

 

Emergency Tuning: Parameters Prove Their Worth

"We need to adjust the configuration in /etc/sysctl.conf," Xiao An said while rapidly typing. After pulling up the configuration file, he changed the critical parameters to:

  • kernel.shmmax=4398046511104 (Maximum single shared memory segment size in bytes)

  • kernel.shmall=4294967295 (Total shared memory pages)

  • kernel.shmmni=4096 (Maximum number of shared memory segments)

  • kernel.sem=250 32000 100 4096 (Semaphore configuration)

"Will changing these parameters really work?" Lao Zhang asked, a little worried. "Think of shared memory as the database's 'workshop.' shmmax is the size of a single room, and shmall is the total floor area of all rooms. The old rooms were too small, so they could only be partitioned into 20 tiny cubicles. The database had to constantly run back and forth to fetch data, which was inefficient and prone to congestion. Now, by making a single room much larger, only 4 cubicles are needed. All that wasted effort is eliminated, and naturally, the traffic jam disappears," Xiao An explained with an analogy.

After the changes were made, Xiao An executed sysctl -p to apply the new configuration, then restarted the database service. Ten minutes later, Lao Zhang refreshed the business system interface — the historical data curve loaded smoothly, and new connections could be established without issue.

 

Performance Validation: From "Jammed" to "Smooth" 

Xiao An opened the shared memory segment monitoring tool, and two sets of data presented a sharp contrast:

Under the original configuration, the system was fragmented into 20 shared memory segments, the largest of which was only 268MB. The database processes had to switch frequently between multiple segments. After optimization, the shared memory segments were reduced to 4, with one segment reaching 2GB in size, directly boosting process access efficiency by several times.

"You see," Xiao An said, pointing at the monitoring charts, "before, the excessive number of memory segments caused significant I/O overhead, and the system couldn't handle high concurrency. Now that the number of segments is lower and the data access path is shorter, the system can naturally withstand high concurrency." Lao Zhang breathed a long sigh of relief as he watched the business system return to normal.

 

Advice from GBase: A Pitfall Avoidance Guide for Kernel Parameter Tuning

This rescue operation is a classic case in point — kernel parameters are like the database's "foundation." If the foundation is unstable, even the most powerful database can't perform to its potential. Here are a few critical recommendations:

Parameter Configuration Matters: shmmax and shmall need to be adjusted in tandem. If shmmax is too small, it leads to memory segment fragmentation, while an insufficient shmall directly limits total memory. The four values in the kernel.sem semaphore configuration (SEMMSL, SEMMNS, SEMOPM, SEMMNI) must meet the communication needs of database processes; values that are too low will cause "poor communication" between processes.

Right-Sizing is More Reasonable: Environments with constrained resources can use the parameters from this case as a reference (shmmax=4398046511104, etc.). For servers with large memory, it is advisable to set shmmax and shmall to 18446744073692774399 to fully unleash the hardware performance.

Advance Planning is Key: Before deploying a database, you must evaluate memory requirements based on peak business concurrency and data volume. Don't wait for a business meltdown to rush an emergency parameter adjustment. Regular monitoring of shared memory usage is also necessary to avoid the "boiling frog" style of creeping failure.

Kernel parameter tuning is not about showing off technical skills — it is the key to getting your database and operating system to work in perfect harmony. Lay a solid foundation, and your high-concurrency business will run stably and smoothly.