Goroutine Scheduling & Elastic Admission Control in CockroachDB
Blog post from Cockroach Labs
CockroachDB v26.1 introduces an innovative approach to balancing background operations and user queries by integrating elastic admission control with a modification to the Go runtime scheduler. This combination allows background tasks—such as backups and schema changes—to utilize available CPU capacity without impacting the latency of user queries. The elastic admission control dynamically adjusts the CPU allocation for background work based on real-time scheduler latency, while a new cooperative yielding mechanism ensures that lower-priority tasks can step aside when high-priority work needs to run. This system significantly reduces scheduling delays, maintaining foreground query performance even at high CPU utilization. The approach is validated through extensive testing, showing minimal overhead and improved throughput for background operations, and is now incorporated into CockroachDB's latest version. This methodology, while currently specific to CockroachDB, has potential applications across systems needing to manage background processing alongside interactive traffic.