Webinar: Accelerate development of your frontend apps with Fauna | August 23rd @ 9:00 a.m. PT
Register now
Fauna logo
Product
Solutions
Pricing
Resources
Company
Log InContact usSign Up
Fauna logo
Pricing
Customers
Log InContact usSign Up
© 2022 Fauna, Inc. All Rights Reserved.

Related posts

Comparing databases for Vercel and NetlifyProduct Updates - July 2022Why everyone wants to go serverless

Table of Contents

Homepage - database-scaling

Overcoming database scaling issues with Fauna’s serverless offering

Kovid Rathee|Jul 6th, 2022|

Categories:

FeaturesServerless
With the amount of data generated every second, scaling high-volume applications is hard. Scaling databases is harder, even if you’re hosting your database in the cloud. You need to choose the right database for your application, but what if you need data modeled in several different ways? Spinning up MongoDB as your document database, MySQL as your relational database, and a few additional databases might be an option, but that could prevent you from scaling your application.
One solution is Fauna, a serverless document-relational database that gives you the freedom of a document-oriented database along with the safety of using a relational database. Although many databases now come with a serverless offering, Fauna is the only one designed and built as a serverless database to enable schema flexibility, easy integration, and reliable scaling.
This article will take you through some of the prominent features of Fauna and demonstrate why it’s a better option than MongoDB or CockroachDB.

Why you should choose Fauna

Fauna stands out compared to competitors like MongoDB, CockroachDB, and DynamoDB. Because it’s natively serverless, it scales quickly and efficiently. It’s one of the few databases that solves the problem of globally distributed ACID transactions, which is an essential feature that neither MongoDB nor CockroachDB offers.
The following is a closer look at what Fauna offers and why it’s superior to other databases.

It’s fully serverless

There are a lot of databases that come with a serverless offering, such as MongoDB Atlas. However, MongoDB Atlas has essentially been repurposed to work as a serverless database and wasn’t designed for that. Meanwhile, Fauna is only serverless. It’s designed to help you concentrate on making your product better rather than on managing database infrastructure just to keep your application running.
Because it’s serverless, you don’t have to take care of any routine database operations (DBOps) tasks that require a lot of time, such as sharding, cluster management, replication, and version upgrades. You also don’t have to manage any connection pools, because it works on a serverless invocation model. Additionally, it doesn’t have a cold start problem.
All of this makes Fauna much more developer-friendly than any other multipurpose database.

It scales automagically

MongoDB was built to scale horizontally at the expense of ACID transactions, meaning that instead of immediate consistency, you get eventual consistency. This won’t work for many use cases. Moreover, sharding in MongoDB requires maintenance and downtime, and you must set a custom shard key per collection. As for resiliency, MongoDB can be vulnerable to failures caused by network partitions or cluster node outages.
Fauna, however, was built to be a globally distributed, multi-data-center, active-active, serverless database from the get-go. It succeeds with high scalability because its Calvin-based architecture allows for both horizontal and vertical scaling and ensures that every node in a Fauna cluster performs the same roles (unlike in many other distributed databases) as a query coordinator, data replica, and log replica. The beauty of this architecture is that the provisioning and management of cluster nodes happen entirely behind the scenes without bothering you.

It offers global low latency

Database calls are costly. To improve database performance and enhance the user experience by lowering the response latency, you need to reduce the number of calls to your database as much as possible. Fauna does precisely that by batching the transactions and applying them across geographical regions, so that you can go through and update multiple collections in one query.
Fauna is still dependent on external network latency. The low latency lays the foundation for enabling strong or immediate consistency. Many use cases require strong consistency to work, such as high-frequency trading, banking, or high-volume booking systems. If you attempt to use MongoDB or CockroachDB for these use cases, you might not be able to scale them efficiently.

It provides distributed ACID transactions

Guaranteeing ACID transactions in a globally distributed database was a complex problem to solve, but Yale University’s Calvin paper changed everything. FaunaDB implemented a system based on Calvin in which, according to Fauna, “Every read issued by an application is guaranteed to reflect the writes of transactions that have been completed before when the read was issued.”
Databases such as CockroachDB don’t offer a high level of serializability. They have traditionally needed Network Time Protocol (NTP) clocks to be synchronized across nodes to ensure that the serializability isn’t violated because of time drift.
In MongoDB, dirty reads and lost transactions are plausible if and when the database fails. Because MongoDB doesn’t have read-side coordination for transactions spanning multiple shards, consistency can be violated because the default read consistency level allows that to happen.
Only Fauna has implemented a Calvin-style protocol that guarantees the highest level of transaction serializability without using a clock and without increasing latency. Fauna uses strict serializability to enable consistency across all nodes in all geographical regions and prevent stale reads. It achieves this by maintaining a log position that helps guarantee a monotonically increasing number of global transactions. To enable transactional order monotonicity, each of Fauna’s data centers uses a synchronization schema for sharing the log position with all query coordinators. Fauna also shares systems information publicly.

It provides security natively

Fauna has a host of database security features that you usually have to build separately for other databases. In addition to standard fine-grained attribute-based access control, Fauna offers OAuth 2.0 integration out of the box. You can use an identity provider to authenticate your users to Fauna.
Fauna’s key-based API is great at authenticating connections with particular permissions down to the level of database objects. Even after authentication, the queries use further token-based authentication on a case-by-case basis. You’d probably need to have a token lease manager like HashiCorp Vault to do this for another database. This feature isn’t available in either MongoDB or CockroachDB.
Having said that, the security implementation of both CockroachDB and MongoDB is quite advanced, as both databases provide basic authentication, encryption, and authorization—but not all features are available in all the plans. Encryption at rest in CockroachDB, for instance, is only available in the Enterprise version, while MongoDB doesn’t have that restriction. Fauna, on the other hand, provides all of these features in all its plans.

It enables more powerful queries

MongoDB and CockroachDB both have minimal support for custom or user-defined functions. Fauna uses an API-first approach to reading and writing data, meaning you can query the data using several interfaces (such as GraphQL) by exposing its API. Fauna comes with its own query language, FQL, which is an expression-oriented query language. You can also write user-defined functions (UDFs). In contrast, CockroachDB doesn’t support GraphQL by default, but you can find ways to work around that. MongoDB provides support for GraphQL via the Atlas App Services API.
In FQL, everything returns values. This enables you to use complex control structures and conditionals to process and compute your data in the shape and form you want. You can also use a mix of these interfaces to develop your applications. If you’re going to query documents, relational data, graph data, or a combination of all of those, you should be able to do it pretty easily with Fauna.
FQL also allows you to query different types of data. For instance, you can use the temporality feature of Fauna to issue point-in-time (PIT) queries. This is especially useful when dealing with time series data or streaming data, which is a real possibility with Fauna. While MongoDB natively supports streaming data, CockroachDB has limited support for streaming, which you can capitalize on by building on top.

Conclusion

There are multiple reasons why Fauna is a better choice for building highly scalable and blazing fast applications. Its Calvin-based architecture has enabled Fauna to be one of a kind, providing globally distributed transactions with the highest level of ACID compliance possible.
With its support for GraphQL and FQL, Fauna also proves to be highly developer-friendly. It gives you the option to use document-oriented database storage and retrieval while providing a relational-database-like experience.
Fauna offers fully managed provisioning, maintenance, scaling, sharding, replication, and correctness. Using Fauna, all you have to do is focus on creating great applications.
To see how Fauna can help you, request a demo or sign up and start using Fauna for free.
Kovid Rathee is a data and infrastructure engineer working as a senior consultant at Servian in Melbourne, Australia.

If you enjoyed our blog, and want to work on systems and challenges related to globally distributed systems, serverless databases, GraphQL, and Jamstack, Fauna is hiring!

Share this post

TWITTERLINKEDIN
‹︁ PreviousNext ›︁

Subscribe to Fauna's newsletter

Get latest blog posts, development tips & tricks, and latest learning material delivered right to your inbox.