CockroachDB Serverless: Free Forever. Seriously.

CockroachDB Serverless: Free Forever. Seriously.

Traditionally, one of the stickiest decisions developers need to make when creating a database is choosing how many servers to use based on expected application traffic. Guess too low and your db could fall over under load, causing an outage. Guess too high, you pay for servers that just sit idle most of the time. Spiky loads? Uh oh, gotta overprovision to make sure those surges get handled even if it means wasted capacity 90%+ of the time. 

Serverless databases are the cure for this perennial headache because now developers never need to think about allocating, configuring or maintaining servers. (This is why we call it serverless, which is kind of awkward as a name but easier than Servers-as-a-Service). A serverless database will also expand and contract based on workload, all without intervention from a developer or ops personnel, automatically scaling up to handle a sudden spike in traffic and then back down post-event. 

Elastic, automated scaling and consumption-based usage rates are core tenets of serverless anything, not just databases. The implicit promise of serverless is “You pay for what you use when you use it. When not in use, everything scales down to zero” — so you always have the right capacity and never overspend.

The problem is, not all serverless databases actually scale to zero. 

When is a “serverless database” not actually serverless?

There are, of course, many distributed databases that can scale out automatically. The problem? Almost every distributed state store on the planet has a minimum scale required to operate and not everyone has a limitless budget — whether you’re a startup, a midsize company, or a development team at a larger org trying to spend efficiently on your testing infrastructure.

This is when a serverless database is a developer’s new best friend. You pay only for what your application (or testing environment) actually consumes, without needing to figure out up front what that might be. If your workloads surge then more hardware is automatically allocated to handle the increased load; when the surge passes, it spins back down again. If your app is making zero requests against the database, then your usage is zero and your bill is zero. 

It’s important to read the fine print when choosing a serverless database. To make sure that, when not in use, it does indeed scale down to nothing and stops charging you. As Corey Quinn points out on his blog, Last Week in AWS, “Buried in the documentation, AWS states that ‘Currently, Aurora Serverless v2 writers and readers don’t scale all the way down to zero ACUs’. As a result, the lowest you’ll pay a month for one of these things is the princely sum of just shy of $45.” 

In other words, even if your application makes not one single request against that serverless database, you still have to pay for usage you never actually used…Which violates the fundamental “scaling to zero” premise of serverless. 

Q: When is a free serverless database truly free as in beer?


A: When it’s CockroachDB serverless.

CockroachDB serverless, now in general availability, lets you create a free, cloud-hosted CockroachDB instance in seconds with just a few clicks or an API call. You can program against  it using your favorite language, SDK, or tooling in the application development environment of your choice, including many popular Postgres tools. CockroachDB serverless automatically and transparently scales capacity and storage to meet demand, no matter how big or small, with no changes to your application. You can make schema changes live in production without taking the database offline. And, yes, it scales all the way down to zero. With CockroachDB serverless, you truly only pay for what you use. 

And did we mention that what you pay may actually be…zero?  Because you can use CockroachDB serverless for free, forever.

Seriously: Free. Forever. For everybody. Including a 99.99% uptime service level agreement for all CockroachDB serverless clusters.

The initial tier for all CockroachDB serverless users is a generous (and never-ending) monthly credit for requests and storage. If you have lighter workloads you’ll pay less, or even nothing at all. Even if your usage goes above the free allotment, you’ll never be surprised by a bill because you designate a monthly spend limit. We’ll alert you as you approach that limit, and even continue providing a free baseline level of performance if you exceed it. 

(If you’re curious about how we are able to give all this away for free, read about the innovative serverless architecture Cockroach Labs engineers created to securely host thousands of virtualized CockroachDB serverless clusters on a single underlying physical CockroachDB database cluster).

Request Units

CockroachDB serverless charges you only for the actual data storage and activity of your cluster, with automatic monthly account credits so that low usage equals low or even no charge. 

  • Data storage is straightforward, measured in GiB per month based on the total volume of storage used over the billing period. 
  • Cluster activity is measured in Request Units (RUs), an abstracted metric that represents the size and complexity of requests made to your database. This includes SQL queries, bulk operations, and background jobs. RU consumption scales to zero when your cluster has no activity, so you will only be charged for what you actually use. Learn about Request Units in the CockroachDB docs.

CockroachDB serverless clusters scale according to workload. Baseline performance for requests to your serverless database cluster is 100 RUs per second. This baseline is always there and always free. Any surge above that baseline is called “burst capacity” and that is when the usage meter starts running (and of course stops again when the surge ends). Every serverless account gets an abundance of free monthly RU credits to cover traffic spikes/burst usage, and automatic email alerts let you know when your free cluster reaches 75% and 100% of its burst capacity or storage limit. (This is actually a good problem to have — it means users are hitting your app like kids grabbing birthday cupcakes, so congrats!)

If you do reach that month’s free limit, you have two options. First, you can simply stay free forever (we said free, we meant free), but with the potential of cluster throttling at higher load periods — meaning your data still gets processed but only at the baseline performance level, so jobs may take longer to complete. Or you could set a spend limit (i.e., choose the maximum amount you would be charged in any given month) to maintain a high level of performance with larger workloads. You are guaranteed to never exceed your set spend limit, so there will never ever be an end-of-the-month charge that comes as a shocking surprise. 

Our docs contain a great deal more than we can cover in a single blog post: CockroachDB serverless burst pricing and spend limits, tuning your serverless workload to optimize usage, and understanding how request units work. This is also where you will find current information on the current free serverless storage and RU credits and burst pricing.

Now that we’ve established what it truly means to offer a free serverless database, it’s time to head on over to https://cockroachlabs.cloud/ and give it a try for yourself. Cockroach University also offers a free course, Introduction to Serverless Databases and CockroachDB Serverless, exploring serverless database core concepts and providing the tools you need to get started with CockroachDB serverless. And of course you can always consult the CockroachDB serverless FAQ in our docs.

If you have questions about any of this, please join the CockroachDB slack channel and ask away. We’d also love to hear about your experience with CockroachDB serverless — or, even better, show us what you are building! Finally, if you’d like to help us take CockroachDB to the next level, we’re hiring.

About the author

Michelle Gienow

Michelle Gienow is a recovering journalist turned front end developer based in Baltimore, MD. She creates content around her central obsessions: Jamstack, distributed architecture and developing a cloud native mindset.

github link linkedin link

Keep Reading

How CockroachDB Operates Serverless Clusters with Kubernetes

Welcome! If you find yourself here wondering What does “serverless database" even mean? you may want to start with …

Read More
How to build a serverless polling application

Very few traditions can melt the corporate ice as well as an ugly holiday sweater contest. Which is why, this past …

Read More
How to Build a Complete Next.js App with Vercel & CockroachDB

In this tutorial, we’ll create an app for coordinating social events. In the process, you’ll see how simple it can …

Read More
x
Developer Resources