---
title: "Deno KV internals: building a database for the modern web"
description: "Deno KV's production backend runs on FoundationDB, with a custom \"transaction layer\" in front of it that handles multi-tenant configuration, JavaScript-native types such as bigint sums, and cross-region replication."
url: "https://swe.quest/articles/deno-kv-internals-building-a-database-for-the-modern-web-61dddae321d95df6"
canonical: "https://deno.com/blog/building-deno-kv"
source: "Deno"
published: "2023-09-14"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 10
tags: ["distributed-databases","consistency","storage-engines","javascript"]
---

# Deno KV internals: building a database for the modern web

A post on [Deno](https://swe.quest/sources/deno.md), published 2023-09-14, 10 min read, Deep dive. Original: [https://deno.com/blog/building-deno-kv](https://deno.com/blog/building-deno-kv)

## Summary

Deno KV's production backend runs on FoundationDB, with a custom "transaction layer" in front of it that handles multi-tenant configuration, JavaScript-native types such as bigint sums, and cross-region replication. To keep latency low, every atomic operation is non-interactive: a single bag of versionstamp checks, set/delete writes and conflict-free mutations that completes in one or two network trips. A sequencer assigns monotonic transaction sequence numbers, and an evaluator turns each batch into a dataflow graph of AND/MUX operations and evaluates it concurrently. Results are reused speculatively before a writer commits them to FoundationDB, which raises throughput without locks.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Distributed databases](https://swe.quest/tags/distributed-databases.md) (Data & databases)
- [Consistency models](https://swe.quest/tags/consistency.md) (Distributed systems)
- [Storage engines](https://swe.quest/tags/storage-engines.md) (Data & databases)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)

## Prerequisites

- database transactions ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))
- optimistic concurrency control ([easy posts on Concurrency](https://swe.quest/tags/concurrency.md?difficulty=easy))
- key-value stores

## Keywords

Deno KV, FoundationDB, Deno Deploy, SQLite, speculative execution, versionstamp

## Related posts

- [Announcing Deno KV](https://swe.quest/articles/announcing-deno-kv-d97d28c9a7128cf3.md): Deno · 2023-05-01 · Medium · 5 min read · Databases, Consistency models, Replication, JavaScript
  Deno KV is a strongly consistent key-value database built into the Deno runtime.
- [Announcing Deno Queues](https://swe.quest/articles/announcing-deno-queues-6220a78d2486588f.md): Deno · 2023-09-27 · Medium · 6 min read · Queues & messaging, Serverless, JavaScript, Consistency models
  Deno Queues adds two APIs to Deno KV, \`enqueue()\` and \`listenQueue()\`, for offloading or delaying background work with no infrastructure to configure.
- [Deno KV vs. Cloudflare Workers KV, Upstash Redis, AWS DynamoDB, and Google Firestore](https://swe.quest/articles/deno-kv-vs-cloudflare-workers-kv-upstash-redis-aws-dynamodb-and-google-firestore-e5a149ce3d17d354.md): Deno · 2023-12-13 · Medium · 9 min read · Databases, Serverless, Performance engineering, Consistency models, CDN & edge
  A vendor-run benchmark compares Deno KV with Upstash Redis, DynamoDB Global Tables, Google Firestore and Cloudflare Workers KV by timing 10-record reads and writes from colocated serverless functions, with warm-up reads excluded.
- [Use Deno KV in Node with the new official npm package](https://swe.quest/articles/use-deno-kv-in-node-with-the-new-official-npm-package-b89917dc2e71fbde.md): Deno · 2023-12-12 · Medium · 4 min read · JavaScript, Databases, Serverless
  Deno KV is now usable from Node.js through the official @deno/kv npm package, which exposes the same API as Deno's built-in KV through a single openKv function.
- [How we built a general purpose key value store for Facebook with ZippyDB](https://swe.quest/articles/how-we-built-a-general-purpose-key-value-store-for-facebook-with-zippydb-852970eb82fe8238.md): Meta Engineering · 2021-08-06 · Hard · 10 min read · Distributed databases, Replication, Consistency models, Consensus, Multi-tenancy
  ZippyDB is Facebook's largest strongly consistent, geo-distributed key-value store, built by layering a reusable replication library (Data Shuttle) on RocksDB, Shard Manager and a ZooKeeper-based config service.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
