The easy way to make apps fast from anywhere on earth
Tags: database, cloud, serverless, fauna
Published: 2022-11-17 14:00:05

_Leveraging globally replicated serverless databases with intelligent routing to enable fast application response times anywhere around the globe_

Most of the widely-used apps on the web have become popular because they are fast, at all times of the day, from any location on the globe, even when serving hundreds of millions of users. At those levels of traffic, these global apps take advantage of many advances in cloud services, such as content delivery networks and serverless functions. 

What may be surprising is that many of these benefits of scale are now available to most app developers by writing their applications to use serverless (versus traditional) databases or moving existing applications to them. Rather than having to implement and maintain complex distributed data clusters to get these sub-second responses in any part of your application, developers can delegate this complexity to the more robust, mature, and battle-tested serverless database services.  

Recently, Fauna published a white paper that describes how it implements database clusters that efficiently route requests to the closest copies (or replicas) of application databases without compromising data consistency. From a developer’s point of view, they can query and write to this database without changing their app logic to leverage clusters, routing, and replicas. 

![Driving in the fast lane from a remote location](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k92tilp4fubtw75ei56j.jpg)

### The shortest route via the fastest lane

Developers have come a long way from having to change their app logic to deal with complex layers like load balancers and connection pools.  This becomes more critical at high-traffic times in slow public networks. So, how do you get to the fastest lane quickly and, once there, use the best route to your requested destination without having to have an expert in distributed databases? 

These days, your app can leverage third-party authentication providers to log in their users to their app often with a single click and, once the user’s identity is known, JSON web tokens as session keys to pass database requests. Think of these keys as your express lane pass, as they help the request through its journey; the same easy device that ensures your security also helps get your data results faster.  How convenient is that? 

Because developers can do this on edge servers geographically closest to the requesting user, Fauna can move the request from the slower, more congested public network to the robust backend networks of the largest cloud providers. Once there, the same key has enough information to allow Fauna to route the request to the closest database replica* that is best equipped to respond to the request. Even when unpredictable traffic spikes occur, Fauna is architected to balance load within its servers to keep response times efficient and minimal.  

___

### High data availability without compromises

It almost sounds too good to be true, right? How do you get to the point of having many database replicas that are close to the user in the first place? Just as you use a serverless database like Fauna to delegate the complexity of the optimal network and data routing, you get the benefit of its highly distributed data clustering capabilities with its data consistency guarantees while complying with strict locality regulations and sovereignty policies.  

The Fauna white paper concisely explains some architectural details that have distinguished it from other serverless database offerings. Because the fundamental architecture is mature and has been proven with demanding workloads over recent years, many of these additional regulations and policies can be handled elegantly out of the box.  

Although existing relational databases like MySQL and PostgreSQL have recently become available as serverless services, many (if not most) of its long-standing users know that these data stores were not originally designed for distributed cloud workloads. These newer offerings still have to contend with complex implementation details behind the scenes.  

Similarly, while most of the NoSQL and document data stores like MongoDB, CockroachDB, and AWS’ DynamoDB feature similar scaling characteristics as part of their original designs, transactional guarantees in many of these implementations have been recent additions. As the white paper outlines, neither the distributed data challenges nor transactional guarantee concerns apply to Fauna database implementations.   

Further, although Fauna provides these global benefits out of the box, it provides implementation options that efficiently handle regulations and policies such as GDPR for app users in the European Union. As a data engineer, you can decide which geographical regions to use for your database, as well as which of the top public cloud providers to leverage.  

Additionally, you can choose to leverage multi-tenancy or single tenancy for further database isolation, should your requirements dictate it. Finally, that same express lane key that enables optimal routing also allows for strict security controls with attribute-based access control. Even with these often necessary restrictions, the routing and replication benefits described above remain as the app’s data features, usage, and requirements change and grow over time. 

___

### Getting good at delegating operational complexity

From this article and what is covered in more detail in the referenced Fauna white paper, it should be apparent that the reason why the benefits of fast global apps can be realized quickly is that you are _delegating_ operational implementation complexity to a world-class serverless database offering, like Fauna. As a recent Harvard Business Review article* explains, the future belongs to companies that can balance operational activities (running the organization) with strategic and tactical projects (changing the organization). 

If you are building a new app or are looking at speeding up an existing one, it will be worthwhile to look into a service like Fauna. Wiring up a working prototype at a minimal cost is quick, and you can use GraphQL and many of the web languages and frameworks you already use to do it. And before you know it, the benefit of having a highly performant web app will turn into an opportunity to delegate other data-related complexities further as well. 

___

#### Further reading

The Fauna white paper referenced here, “Balance global user experience and data sovereignty in your database” is freely available at the Fauna website through this [link](https://go.fauna.com/guide/global-applications?utm_source=dev.to&utm_medium=referral&utm_campaign=global_apps
).

To learn more about database replication, this recent TechTarget [article](https://www.techtarget.com/searchdatamanagement/definition/database-replication) explains many of the benefits of using replicas, and outlines how replica techniques have changed over the years.

The article [“The Project Economy Has Arrived”](https://hbr.org/2021/11/the-project-economy-has-arrived) was published by Harvard Business Review in 2021, and outlines perspectives on balancing operations and projects in your organization.

If you want to see how Fauna compares to other databases like [PostgreSQL](https://fauna.com/blog/compare-fauna-vs-postgres) and [MongoDB](https://fauna.com/blog/comparing-fauna-and-mongodb), you can check these articles as well.

___

#### About the author

Luis Colon is a data scientist that focuses on modern database applications and best practices, as well as other serverless, cloud, and related technologies. He currently serves as a Senior Technology Evangelist at Fauna, Inc. You can reach him at [@luiscolon1](https://twitter.com/luiscolon1) on [Twitter](https://twitter.com/luiscolon1) and [Reddit](https://www.reddit.com/user/luiscolon1).