Datahike provides pluggable storage through konserve, allowing you to choose the backend that best fits your deployment model and performance requirements.
| Backend | Best For | Distribution | Durability | Write Throughput |
|---|---|---|---|---|
| File | Unix tools, rsync, git-like workflows | Single machine | High | Good |
| LMDB | High-performance single machine | Single filesystem | High | Excellent |
| RocksDB | Embedded high-write workloads | Single machine | High | Excellent |
| Memory | Testing, ephemeral data | Single process | None | Excellent |
| JDBC | Existing SQL infrastructure | Multi-machine | High | Good |
| Redis | High write throughput | Multi-machine | Medium | Excellent |
| S3 | Distributed scale-out, cost-effective | Multi-region | Very high | Good |
| GCS | Google Cloud scale-out | Multi-region | Very high | Good |
| Azure Blob | Azure-native object storage | Multi-region | Very high | Good |
| DynamoDB | Low latency, AWS-native | Multi-region | Very high | Excellent (expensive) |
| IndexedDB | Browser persistence | Browser | Medium | Good |
On Windows, the JVM file backend requires JDK 22+ and
--enable-native-access=ALL-UNNAMED for Konserve's directory persistence barrier.
This does not raise the Unix JVM requirement. Native binary builds use GraalVM
25. Persistence errors fail the write; do not enable unsafe directory-sync
fallback to bypass them.
Use when: You want to use Unix tools (rsync, git, backup scripts) to manage your database.
Key advantage: Deltas in persistent data structures translate directly into individual file deltas, making incremental backups and synchronization highly efficient.
{:store {:backend :file
:path "/var/lib/myapp/db"}}
Characteristics:
Use when: You need maximum performance on a single machine within a single filesystem.
Key advantage: Lightning-fast memory-mapped database with ACID transactions, optimized for read-heavy workloads.
;; Requires: org.replikativ/konserve-lmdb
{:store {:backend :lmdb
:path "/var/lib/myapp/db"}}
Characteristics:
Note: The LMDB backend is available as the separate
konserve-lmdb library. It is not
part of the portable server artifact: it requires Java 22+, native access, and
a platform liblmdb installation.
RocksDB is available through
konserve-rocksdb. It remains a
separate server deployment dependency: its rocksdbjni artifact is about 68
MiB because it carries native libraries for several operating systems and CPU
architectures. Bundling it would nearly double the portable server JAR.
Native-store server variants therefore have different contracts from the portable artifact:
liblmdb plus native
access at launch.Until those distributions are published, use the thin server artifact from a Clojure project that adds and requires the corresponding Konserve backend.
Use when: Testing, development, or ephemeral data that doesn't need to survive process restarts.
{:store {:backend :memory
:id #uuid "550e8400-e29b-41d4-a716-446655440030"}}
Characteristics:
:idAll distributed backends support Distributed Index Space (DIS): multiple reader processes can directly access shared storage without database connections, enabling massive read scalability.
Important: a connection owns its branch head and serializes commits through it. :writer-ownership :exclusive asserts that all of a database's writers live in one JVM (it does not enforce it); under :shared (the default) several processes may write the same branch, protected by fenced head writes on backends that support conditional writes (:require-fencing true refuses to write unfenced elsewhere). Maintenance that runs on the writers' side — notably garbage collection — can see only the commits in flight in its own process, so under shared ownership it needs the sweep floor described there. Readers are unconstrained. A writer endpoint (see Distributed) remains the way to funnel all writes through one process.
Use when: You already have PostgreSQL or another JDBC database in your infrastructure.
Key advantage: Leverage existing SQL database skills, backup procedures, and monitoring tools.
;; Requires: org.replikativ/konserve-jdbc
{:store {:backend :jdbc
:dbtype "postgresql"
:host "db.example.com"
:port 5432
:dbname "datahike"
:user "datahike"
:password "..."}}
Characteristics:
Note: The standalone server includes konserve-jdbc and the PostgreSQL driver. Embedding applications add the driver for the SQL database they use.
Use when: You need high write throughput and can tolerate weaker durability guarantees.
Key advantage: Excellent write performance with in-memory speed.
;; Requires: org.replikativ/konserve-redis
{:store {:backend :redis
:host "redis.example.com"
:port 6379}}
Characteristics:
Use when: You want cost-effective distributed storage that scales to massive datasets.
Key advantage: Extremely scalable, pay-per-use pricing, natural fit for cloud-native architectures.
;; Requires: org.replikativ/konserve-s3
{:store {:backend :s3
:bucket "my-datahike-bucket"
:region "us-east-1"}}
Characteristics:
Performance note: Higher latency than local storage, but cost-effective for billions of datoms.
Use when: You're on Google Cloud Platform and want distributed storage.
Key advantage: Similar to S3 but optimized for GCP infrastructure.
;; Requires: org.replikativ/konserve-gcs
{:store {:backend :gcs
:bucket "my-datahike-bucket"
:project-id "my-project"}}
Characteristics:
The standalone server carries the Google SDK's default HTTP/JSON client. GCS production endpoints are still HTTPS with the normal Google authentication and integrity checks; only the optional gRPC implementation is omitted.
Use when: You're on Azure and want distributed object storage.
;; Requires: org.replikativ/konserve-azure-blob
{:store {:backend :azure-blob
:container "datahike"
:account-name "my-storage-account"}}
The standalone server uses Azure's portable JDK HTTP provider. It does not bundle the alternative Netty provider or its platform-native TLS binaries.
Use when: You need low-latency distributed storage and are willing to pay premium pricing.
Key advantage: Single-digit millisecond latency with strong consistency options.
;; Requires: org.replikativ/konserve-dynamodb
{:store {:backend :dynamodb
:table "datahike"
:region "us-east-1"}}
Characteristics:
Use when: Building offline-capable browser applications with persistent local storage.
Key advantage: Durable browser-local storage with ClojureScript support.
;; ClojureScript only
{:store {:backend :indexeddb
:id "my-app-db"}}
Characteristics:
TieredStore creates memory hierarchies by layering backends, with faster storage in front of slower, more durable storage.
Use cases:
;; Example: Fast memory cache backed by S3
{:store {:backend :tiered
:id #uuid "550e8400-e29b-41d4-a716-446655440031"
:frontend-config {:backend :memory
:id #uuid "550e8400-e29b-41d4-a716-446655440031"}
:backend-config {:backend :s3
:bucket "persistent-store"
:region "us-east-1"
:id #uuid "550e8400-e29b-41d4-a716-446655440031"}
:write-policy :write-through
:read-policy :frontend-first}}
How it works:
Common patterns:
Browser with offline support:
{:store {:backend :tiered
:id #uuid "550e8400-e29b-41d4-a716-446655440032"
:frontend-config {:backend :memory
:id #uuid "550e8400-e29b-41d4-a716-446655440032"}
:backend-config {:backend :indexeddb
:id #uuid "550e8400-e29b-41d4-a716-446655440032"}
:write-policy :write-through}}
AWS Lambda with S3 backing:
{:store {:backend :tiered
:id #uuid "550e8400-e29b-41d4-a716-446655440033"
:frontend-config {:backend :lmdb
:path "/tmp/cache"
:id #uuid "550e8400-e29b-41d4-a716-446655440033"}
:backend-config {:backend :s3
:bucket "lambda-data"
:region "us-east-1"
:id #uuid "550e8400-e29b-41d4-a716-446655440033"}}}
Each backend may have additional configuration options. See the konserve backend documentation for details:
A new database compresses what it stores with zstd
when its store can: every backend built on konserve's default store (file, JDBC,
S3, GCS, Azure, DynamoDB, Redis, RocksDB, IndexedDB, and a tiered store over
one of them). The memory store and LMDB keep values as they are and stay
uncompressed. On the JVM this needs no native library; in ClojureScript it uses
the npm package @replikativ/zstd; on Jolt it needs the system libzstd (1.4.0
or newer), without which new databases stay uncompressed and zstd databases
cannot be opened.
The choice is made once, when the database is created, and recorded with it, so
later connects need not repeat it. Databases created before this default keep
writing uncompressed. To choose yourself, name a compressor in the store config,
:none included:
{:store {:backend :file
:path "/var/lib/myapp/db"
:id #uuid "550e8400-e29b-41d4-a716-446655440000"
:config {:encoding {:compressor {:type :none}}}}} ; or :zstd, :lz4 (JVM)
A compressor named when a connection is opened decides how new values are written, and from the next commit on it is the one the database records, so later connects that name none keep it. A connect that finds the connection already open gets that connection and its compressor. Every stored value records its own compressor, so a database may hold several and reads all of them. For a tiered store, a compressor named for one tier is respected and no default is added.
Older Datahike versions refuse a database created by a newer one; their
konserve reads zstd only with com.github.luben/zstd-jni on the classpath.
→ Memory or File backend for simplicity
→ LMDB for best performance → File if you need Unix tool integration
→ S3/GCS for cost-effective scale → DynamoDB for low latency (higher cost) → JDBC if you already operate PostgreSQL
→ Redis if you can tolerate some data loss → LMDB for durable local writes → DynamoDB for distributed writes (expensive)
→ IndexedDB for persistence → TieredStore (Memory → IndexedDB) for speed + durability
→ File backend with rsync for cheap backups → S3 for large datasets (pennies per GB) → TieredStore to minimize expensive tier access
To migrate from one backend to another:
(require '[datahike.migrate :refer [export-db import-db]])
(export-db source-conn "/tmp/datoms-export")
(d/create-database new-config)
(def dest-conn (d/connect new-config))
(import-db dest-conn "/tmp/datoms-export")
The export format (CBOR) preserves all data types including binary data.
Datahike can use any konserve backend. To create a custom backend:
See the konserve documentation for details on implementing custom backends.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |