Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsMay 28, 2026·3 min de lecture

LiteFS — FUSE-Based SQLite Replication Across a Cluster

LiteFS is an open-source FUSE-based file system by Fly.io that transparently replicates SQLite databases across a cluster of machines. It enables read replicas and disaster recovery for SQLite-backed applications without changing application code.

Prêt pour agents

Installation avec revue préalable

Cet actif nécessite une revue. Le prompt copié demande un dry-run, affiche les écritures, puis continue seulement après confirmation.

Needs Confirmation · 64/100Policy : confirmer
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
LiteFS Overview
Commande avec revue préalable
npx -y tokrepo@latest install c927cdd6-5a4e-11f1-9bc6-00163e2b0d79 --target codex

Dry-run d'abord, confirmez les écritures, puis lancez cette commande.

Introduction

LiteFS lets you run SQLite in production across multiple servers. It works as a FUSE file system that intercepts SQLite write-ahead log (WAL) transactions and replicates them to other nodes in real time. Applications read and write to SQLite normally while LiteFS handles distribution transparently.

What LiteFS Does

  • Replicates SQLite databases across multiple nodes using FUSE interception
  • Provides a single primary writer with multiple read replicas
  • Supports automatic failover via Consul-based lease management
  • Handles transaction-level replication for consistency guarantees
  • Works transparently with any SQLite-based application

Architecture Overview

LiteFS runs as a FUSE file system that mounts over the directory containing your SQLite databases. When the application writes to SQLite, LiteFS intercepts the WAL frames and ships them to replica nodes over HTTP. One node holds the primary lease (managed via Consul or a static configuration), and only the primary accepts writes. Replicas apply received transactions to stay in sync. The application connects to the SQLite file on the FUSE mount and requires no code changes.

Self-Hosting & Configuration

  • Install the litefs binary on each node in your cluster
  • Create a litefs.yml configuration specifying the mount directory and lease settings
  • Configure Consul or use static leases for primary election
  • Run litefs mount as a background service (typically via systemd or as a Docker entrypoint)
  • Point your application at the SQLite database inside the FUSE mount directory

Key Features

  • Transparent replication requires zero application code changes
  • Transaction-level consistency ensures replicas see complete transactions
  • FUSE-based approach works with any language or framework that uses SQLite
  • Built-in HTTP API for monitoring replication lag and cluster health
  • Supports backup and restore through point-in-time recovery snapshots

Comparison with Similar Tools

  • Litestream — Streams WAL to S3 for backup; LiteFS provides live multi-node replication
  • rqlite — Raft-based distributed SQLite; LiteFS uses primary-replica model with FUSE
  • libSQL/Turso — SQLite fork with built-in replication; LiteFS works with standard SQLite
  • Marmot — SQLite replication via NATS; LiteFS uses direct HTTP streaming
  • dqlite — Canonical's replicated SQLite library; requires code changes, LiteFS is transparent

FAQ

Q: Does LiteFS support multi-writer? A: No. LiteFS uses a single-primary model. One node accepts writes while others serve as read replicas. Write requests to replicas are forwarded to the primary.

Q: How fast is replication? A: Replication happens at the transaction level and is typically sub-second. Replicas receive and apply WAL frames as they are committed on the primary.

Q: Do I need to change my application code? A: No. LiteFS is transparent. Your application reads and writes to a normal SQLite file path. LiteFS handles replication at the filesystem level.

Q: Can I use LiteFS outside of Fly.io? A: Yes. LiteFS is open source and works on any Linux system with FUSE support. It was designed at Fly.io but is not tied to their platform.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires