Skip to content

Cold Start

Large-scale game operations have their own discipline.

The end of a maintenance window is a battlefield. Players are waiting. The instant maintenance ends, logins flood in. If the DB is cold at that moment, it dies.

Right after a server restart, database performance tanks. The reason is simple: the OS disk cache is empty. Linux uses free memory as page cache, transparently caching disk reads and writes. Run free and it looks like memory is almost fully used, but most of it is cache. When an application requests memory, the kernel reclaims cache and hands it over. If you don't know this, you panic about "running out of memory."

MySQL and PostgreSQL read data from disk, but once read, that data sits in page cache. Second access onward comes from memory. Fast. Restart the server and the cache is gone. Every query hits disk I/O.

So there's a ritual before the maintenance window ends. Warm-up.

"Warm-up script" sounds fancy, but often it's just cat /var/lib/mysql/... > /dev/null to force-read the data files. cat is enough to populate page cache. You can also dump and restore InnoDB's buffer pool.

Confirm the cache is warm, then open the load balancer to traffic. Never send production traffic to a cold database. That was the first lesson drilled into me in game operations.