Skip to content
Back to Deployment

Deploying with FaunaDB

Serverless document DB with ACID transactions, temporal queries, and multi-region.

PlatformsIntermediate

Why

FaunaDB is a serverless document database with ACID transactions, temporal (time-travel) queries, and automatic multi-region replication. No capacity planning — pay per query.

Platform-as-a-Service adoption grew 24% in 2024 as teams shift from VM management to git-push deploys. the cloud infrastructure market reached $330B in 2024, growing 22% year-over-year (Synergy Research), and PaaS layers capture the majority of new workloads.

When

Use FaunaDB for serverless apps needing ACID across documents. Avoid for heavy read/write (cost adds up).

How

1. Create — fauna.com → New Database 2. Collection — CreateCollection({ name: "users" }) 3. Index — CreateIndex for queryable fields 4. FQL — Fauna Query Language, composable 5. Auth — Fauna key or token-based auth 6. Temporal — .ts() for time-travel queries 7. SDK — fauna from 'fauna' for JS

Example

import { Client, query as q } from "faunadb"; const client = new Client({ secret: process.env.FAUNA_SECRET }); // Create and query await client.query( q.Create(q.Collection("users"), { data: { name: "Alice", email: "[email protected]" } }) ); const result = await client.query( q.Map(q.Paginate(q.Match(q.Index("users_by_email"), "[email protected]")), q.Lambda("ref", q.Get(q.Var("ref")))) ); // Temporal query — get user as of past time await client.query(q.Get(q.Ref(q.Collection("users"), "123")).ts("2024-01-01T00:00:00Z"));

Common Problems

  • ⚠No index — can't query by field, create index first
  • ⚠Cost surprises — per-query pricing, monitor usage in dashboard
  • ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical

Best Practices

  • ✓Create indexes for all query patterns — Fauna requires explicit indexes
  • ✓Use FQL for complex transactions — composable, ACID across documents
  • ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit

FAQ