Improving MariaDB performance after scale-down events

Agiler’s MariaDB durable objects respond to load by scaling up and down to ensure every request has sufficient database capacity to keep the website fast.

Scaling up has always been a warm operation, since it only requires adding resources to the database and notifying MariaDB that they are available. Scaling down is more complicated, because MariaDB holds on to resources under the assumption that they may be useful later — even when a reduction in web traffic has triggered a scale-down of everything else.

Previously, we handled MariaDB scale-down events by waiting for a pause in traffic and then resetting MariaDB’s connection and data caches. While no downtime was required for the scale-down, MariaDB did have to reload its data, and every PHP worker had to reestablish its database connection - adding latency to the first requests after a scale-down.

What has changed is that we can now scale MariaDB down without resetting its caches or dropping its connections, eliminating the performance impact of these events. MariaDB scale-downs now complete as seamlessly as scale-ups, allowing more responsive resource matching.