Speed, reliability, and accessibility of your applications across geographically distributed customers is easier than you think with edge computing architecture. Fastly’s high-scale, globally distributed edge computing network, paired with Fauna’s geographically distributed, low-latency, and strongly consistent database, gives you the power to easily build and operate REST APIs that offer speed, reliability, and scale with extremely low operational overhead. This article demonstrates how easy it is to build a distributed REST API with Fastly’s Compute@Edge and Fauna.

Learning goals

If you want to follow along quickly, you can find the complete code for this tutorial here on GitHub.

Why Fastly Compute@Edge and Fauna

Building with Fauna and Fastly Compute@Edge enables you to create a geographically distributed, strongly consistent, fully serverless REST API in a single code repository. You can develop your application as if it were a monolith but gain the resilience and reduced latency of a distributed application running at the edge.

Fauna is particularly well-suited for applications running on edge computing platforms – such as Fastly Compute@Edge – due to its low latency, strong consistency, distributed architecture and API delivery model. Fauna provides a powerful yet easy TypeScript-inspired query language called FQL – pairing well with Fastly’s excellent support for application code written in JavaScript.

Getting Started with Fastly Compute@Edge

To get started, make sure you have a Fastly account. Then, simply clone the Fastly Compute@Edge Starter Kit for Fauna:

git clone <https://github.com/fauna-labs/fastly-compute-at-edge-starter-kit.git>

“cd” into the project directory and install dependencies

npm install

Next, you’ll need to obtain a Fauna database access token to configure the project.

Create a Fauna database and generate a database access token

Head over to dashboard.fauna.com and create a new database. You can create a new database by selecting the ‘Create Database’ option.

Screenshot_2023-09-01_at_12_51_32_PM.png

Give your database a name, select the global Region Group, and then select ‘Create’. You can turn off backups for this particular sample application.