Since the emergence of cloud computing more than a decade ago, many have been waiting for a completely cloud-based, elastic database that could expand (and even contract) its footprint dynamically and would eliminate the significant operational effort of maintaining a production database system.
Truly elastic cloud-native databases have emerged—Amazon’s DynamoDB and Microsoft CosmosDB, for instance—but even now that we are past the cloud database tipping point, the majority of cloud-based databases are running the same software as their on-premise equivalents.
A modern distributed database platform such as MongoDB or CockroachDB can run as a fully managed cloud service quite happily. And the advantages of doing so are real; when you buy a MongoDB Atlas service or a CockroachDB dedicated cloud service, you get a highly functional database cluster running on dedicated cloud infrastructure, but your operational overhead is largely eliminated. It’s a good deal. However, these kinds of “dedicated” deployments aren’t quite what the “elastic” cloud originally promised. In particular, you have to pay for the hardware that hosts your cluster, even when there is no workload running.
Serverless Cloud Offerings
To move us closer to the ideal of a fully elastic, pay-only-for-what-you-use cloud database platform, both MongoDB and CockroachDB recently announced “serverless” cloud offerings—and you can bet that the other database vendors will be quick to follow.
In a serverless offering, you really pay only for what you use. Of course, databases are hardly stateless, so if you store terabytes of data, you’ll have a storage cost, regardless of utilization, but you’ll pay only for CPU and I/O if you run workloads.
Both MongoDB and CockroachDB charge in terms of abstract units—MongoDB uses Read and Write Processing Units (RPUs and WPU) while CockroachDB uses “Request Units.” Both are roughly equivalent to a very simple database request—single row or document lookup by an index, for instance.
Under the hood, both serverless offerings employ a shared tenancy architecture. In the case of CockroachDB, every serverless database’s data is stored on shared storage nodes. As workload demands increase, CockroachDB launches processing nodes to perform SQL and transactional processing. MongoDB uses a similar approach. And vendors provide you with a guaranteed free number of request units per month.
The advantages of the serverless approach are very significant for applications that have a variable workload—as almost all do. In existing offerings, you configure enough resources to cope with your peaks—which usually means you are wasting money during the troughs.
Key Considerations
Serverless might not suit everybody, however. In a serverless deployment, your application shares some physical resources with other serverless users. In particular, an individual storage node will contain data from multiple users. Of course, you can’t see data from other users, but some organizations with hypersensitive security requirements might find this “co-tenanting” unacceptable.
This co-tenanting also allows for the possibility that a “noisy neighbor” might disrupt your performance. Furthermore, during periods of low activity, your data in cache memory may be replaced by data from other tenants. When your application starts to ramp back up, it will experience a “cold cache” scenario in which physical I/O rates are higher than normal.
In serverless mode, you “cap” your bill at a certain amount; if your resource utilization exceeds that cap, then you’ll be throttled back to the performance limitations provided by the free tier. There are, of course, ways to monitor and manage your resource utilization, but, nevertheless, if you are not paying attention to your application’s workload, you might be surprised by an unusually large bill or by the throttling of resources.
Balancing Requirements
These are minor drawbacks, however, when compared to the strong economic advantages of paying only for the CPU and memory that you actually use and the ability to rapidly ramp up resources when workload demands. I expect serverless offerings, such as those from MongoDB and CockroachDB, to be very popular!