Concord

Build StatusHex.pmDocumentationLicense

A distributed, strongly-consistent embedded key-value store built in Elixir using the Raft consensus algorithm.

Concord is an embedded database for Elixir applications — think SQLite for distributed coordination. Starts with your application, no separate infrastructure needed. Strong consistency guarantees with ETS-backed read performance.

Key Features

Installation

def deps do
[{:concord, "~> 2.0"}]
end

Quick Start

# Store and retrieve data
Concord.put("user:1001", %{name: "Alice", role: "admin"})
{:ok, user} = Concord.get("user:1001")
# TTL (auto-expires after 1 hour)
Concord.put("session:abc", session_data, ttl: 3600)
{:ok, {data, remaining_ttl}} = Concord.get_with_ttl("session:abc")
# Bulk operations
Concord.put_many([{"k1", "v1"}, {"k2", "v2", 600}])
{:ok, results} = Concord.get_many(["k1", "k2"])
# Conditional update (compare-and-swap)
Concord.put_if("counter", 1, expected: 0)
# Read consistency levels
Concord.get("key", consistency: :eventual) # Fast, may be stale
Concord.get("key", consistency: :leader) # Default, balanced
Concord.get("key", consistency: :strong) # Linearizable

Multi-Node Cluster

iex --name n1@127.0.0.1 --cookie concord -S mix # Terminal 1
iex --name n2@127.0.0.1 --cookie concord -S mix # Terminal 2
iex --name n3@127.0.0.1 --cookie concord -S mix # Terminal 3

Performance

Performance varies significantly depending on hardware, cluster size, network topology, and consistency level. ETS-backed reads are inherently fast, but actual throughput and latency depend on your deployment. Run mix run benchmarks/run_benchmarks.exs on your own hardware to get representative numbers.

When to Use Concord

Use CaseFit
Feature FlagsExcellent
Session StorageExcellent
Distributed LocksExcellent
Config ManagementExcellent
Rate LimitingGood
API Response CacheGreat
Primary DatabaseAvoid (use PostgreSQL)
Large Blob StorageAvoid (use S3)

Comparison

FeatureConcordetcdConsulZooKeeper
LanguageElixirGoGoJava
ConsistencyStrong (Raft)Strong (Raft)Strong (Raft)Strong (Zab)
StorageIn-memory (ETS)Disk (WAL)Memory + DiskDisk
Read Latency1-5ms5-20ms5-15ms5-20ms
EmbeddedYesNoNoNo
Multi-DCNoYesYesYes

Documentation

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass (mix test)
  5. Submit a pull request

License

MIT License — See LICENSE for details.

Acknowledgments