Side-by-side comparison of serverless databases
Dec 29th, 2022|
Serverless databases make it easy to build and scale your application because they abstract away the underlying infrastructure and automatically scale to meet the need of your application. A serverless database lets you focus on your code without worrying about capacity planning, infrastructure maintenance, and server management.
There are quite a few options for serverless databases, including established solutions like DynamoDB and newer offerings such as Mongo Atlas and CockroachDB serverless. This article compares commonly used serverless databases so you can make an informed decision when picking a new database for your project.
MongoDB (Mongo Atlas)
MongoDB is a widely used NoSQL database. MongoDB Atlas offers a provisioned managed service as well as a serverless offering. In this article we will compare the serverless offering.
MongoDB Atlas offers fully managed serverless instances of MongoDB. With Mongo Atlas, you don’t have to manage any infrastructure by yourself.
Check out this MongoDB vs. PostgreSQL comparison for further insights into how MongoDB stacks up to a traditional relational database.
✅ Connection over HTTP
Mongo Atlas allows your application to connect to your database through an HTTP connection.
⚠️ Multi-region availability
By default, MongoDB Atlas is deployed in a single region. However, MongoDB Atlas can automatically replicate data across multiple servers for improved reliability and availability. It is partially automated, and you’ll need prior knowledge of sharding and replication.
⚠️ Schema design (Schema-less, non-relational)
MongoDB is flexible and suitable for both structured and unstructured data. Unlike a relational database, MongoDB doesn’t support foreign key joins. Because of this modeling, your data relationships can be tricky with Mongo. There are other ways to get around this problem in MongoDB. Review this thread to learn more about data modeling in MongoDB.
❌ No cold starts
If you have a large database then MongoDB Atlas clusters can have a long cold start time.
⚠️ ACID transactions
Multi-document transactions are not enabled by default in MongoDB or MongoDB Atlas clusters. However, you can configure MongoDB to support multi-document ACID transactions based on your use case.
DynamoDB
DynamoDB is a fully managed No-SQL database from Amazon. It supports key-value and document data structures. DynamoDB has a pay-as-you-go model, and it provides auto-scaling.
✅ Connection over HTTP
DynamoDB allows connection over HTTP.
⚠️ Multi-region availability
You can setup multi-region availability with DynamoDB’s global tables feature. However, keep in mind there is significant configuration required to get it up and running properly.
DynamoDB requires users to choose a partition key that determines how data is grouped and distributed among partitions. How you choose this key impacts DynamoDB’s scalability. Having a thorough understanding of how your data will be accessed will be critical to selecting the most appropriate partitioning key and strategy.
⚠️ Schema design (Schema-less)
DynamoDB is largely schema-less. Like many of its NoSQL siblings, DynamoDB lacks explicit support for relational data. It is designed with a denormalized schema in mind. Document sizes are also limited to 400kb in DynamoDB, forcing developers to denormalize the application data.
✅ No cold starts
DynamoDB doesn’t have any cold start-related concerns.
⚠️ ACID transactions
DynamoDB transactions are only ACID-compliant within a single region. DynamoDB does not support strongly consistent reads across regions.
Follow this article for a detailed comparison of Fauna and DynamoDB.
CockroachDB
Like Mongo here we are focusing on the Serverless offering of the CockroachDB not the provisioned managed service since provisioned service doesn’t offer pay per usage.
CockroachDB is a distributed SQL database system. It is based on the idea of a "cockroach cluster," a group of nodes that work together to provide fault tolerance and high availability. Each node in a CockroachDB cluster can serve read and write requests, and the cluster can automatically recover from failures and distribute data evenly across the nodes.
✅ Connection over HTTP
CockroachDB supports connection over HTTP.
✅ Multi-region availability
CockroachDB provides out-of-box multi-region availability without further configuration.
⚠️ Schema design (SQL )
CockroachDB has a Dynamic schema. It is relational and supports SQL. Since cockroach is based on traditional RDBMS it may take a lot of work to evolve unstructured data as your application grows.
❌ No cold starts
For large amounts of datasets CockroachDB clusters may experience cold starts.
✅ ACID transactions
CockroachDB fully supports strong consistency and ACID transactions.
Fauna
Fauna is a serverless database that combines the flexibility of NoSQL with the relational querying capabilities and consistency of SQL. You get the best of both worlds when using Fauna. It is fully managed, auto-scales, and does not require infrastructure management.
✅ Connection over HTTP
Fauna allows your applications to connect to the database over HTTP. You can use a Fauna driver or Fauna's GraphQL interface to communicate with the database.
✅ Multi-region availability
Fauna provides multi-region availability out of the box; it will auto-replicate your data across servers. It is distributed by default within a geographic region or across the globe. You always get strong consistency among region groups. Fauna is designed to keep the data closest to your users, improving reliability and availability.
✅ Schema design (Document-relational)
Fauna follows a document-relational database model. It combines the flexibility and familiarity of JSON documents with the relationships and querying power of a traditional relational database.
In short, you get the best of both SQL and NoSQL worlds with Fauna. Because of the flexible nature of the Fauna database, it is effortless to scale and evolve your data schema as your application grows.
✅ No cold starts
Fauna has zero cold starts.
✅ ACID transactions
One of the features of Fauna that has generated the most excitement is its strongly consistent distributed ACID transaction engine. Fauna provides strong consistency of data globally through an implementation of the Calvin protocol.
Below you’ll find a visual comparison of all these serverless database offerings.
If you are considering Fauna, create a free account (no credit card required) and give it a go. If you have questions, you can reach out in the Fauna Discord channel or Fauna community forum.
If you enjoyed our blog, and want to work on systems and challenges related to globally distributed systems, and serverless databases, Fauna is hiring
Subscribe to Fauna's newsletter
Get latest blog posts, development tips & tricks, and latest learning material delivered right to your inbox.