How CockroachDB Operates Serverless Clusters with Kubernetes
CockroachDB, a distributed SQL database, has developed a method for running serverless databases on Kubernetes. The architecture separates the system into two layers: SQL and Key/Value (KV) storage. In a dedicated deployment, these layers communicate in the same process; however, in a multi-tenant deployment, each layer is split into its own process. This results in one large stateful cluster of storage pods that act as the back end for many stateless SQL pods. The KV Cluster is essentially a dedicated CockroachDB deployment. The SQL pods are where the uncharted territory lies. These pods, like the storage ones, are still CockroachDB but with a slightly different entry point. Thanks to the architecture of CockroachDB's SQL execution layer, SQL pods are horizontally scalable. This means that the quality of service tenants experience can be controlled by adjusting resource limits and requests on SQL pods or modifying the number of replicas allocated to them. The low latency resumption process allows for SQL Pods to spin up in an un-bound state, which are then bound to a tenant when needed. This enables CockroachDB Serverless to avoid pod start-up times and provide fast startup times. The autoscaler component within the operator decides the number of SQL pods that each tenant needs at any point in time by monitoring CPU load across all SQL pods for each tenant in the Kubernetes cluster. The CrdbTenant controller updates the actual state to the desired state at a controlled rate, ensuring the desired number of SQL pods are allocated. The draining process prevents constant churning of unstamped pods and allows for more efficient resource usage by tenants. The SQL Proxy component is what end users connect to when they use CockroachDB Serverless. It routes connections to corresponding stamped SQL pods, and if there are no active SQL pods due to scaling down, the low-latency resumption process comes into play. The user can get started with a free CockroachDB Serverless account by signing up at https://cockroachlabs.cloud/signup.
Company
Cockroach Labs
Date published
March 24, 2022
Author(s)
Chris Seto
Word count
1884
Hacker News points
2
Language
English