MLambda.Data
The actor-native distributed database: typed queries instead of SQL text, mailboxes instead of connection pools, a ring instead of consensus.
Released admin 1.3.4; the store under every MLambda service
MLambda.Data
The actor-native distributed database.
MLambda.Data is a distributed database built on the actor model and written in Aleph. Distribution is not bolted onto a single-node design: every component is an actor, and the actor framework (MLambda.Actor) is the cluster. It compiles to one native executable per node.
Why a new architecture?
Traditional databases were designed for single machines, and distribution came later:
- SQL text is parsed into a tree, planned, then executed before any data is touched;
- connection pools manage sockets because the server cannot serve concurrent clients natively;
- consensus protocols are added because the storage engine was not designed for distribution;
- wire protocols serialize and deserialize at every boundary.
MLambda.Data replaces these with the actor model:
- typed values instead of query text: a query is data the compiler checks, so there is nothing to parse and nothing to inject;
- mailboxes instead of connection pools: each actor handles one message at a time, with no locks;
- routing instead of consensus: the ring decides which replicas own a key, and the actor framework carries the messages, locally or across nodes.
Quick example
An entity maps a type to a table, once:
data User = User { userId :: String, name :: String, email :: Maybe String, age :: Int }
instance Entity User where
mapping = mappedTo "app"
(btreeIndex "ix_age" ["age"]
(partitionKey ["id"]
(column "age" Int64Type
(nullableColumn "email" TextType
(column "name" TextType
(column "id" TextType (tableBuilder "users")))))))
toColumns u = Columns (withEmail u.email [fieldOf "id" u.userId, fieldOf "name" u.name, fieldOf "age" u.age])
fromColumns cs = ...
keyOf u = B.bytesFromString u.userId
A repository stores it. Opening the repository defines the table:
case openRepository engine of
Right users -> case save users (User "u-1" "Alice" (Just "[email protected]") 30) of
_ -> find users (B.bytesFromString "u-1") -- Right (Just (User "u-1" "Alice" ...))
Left fault -> ...
select users (selecting (Where (Filter "age" OpGt (toValue 30)))) -- the users over 30, through ix_age
Architecture at a glance
┌────────────────────────────────────────────────────────────┐
│ API — REST, live channels (SignalR over WebSockets), auth │
├────────────────────────────────────────────────────────────┤
│ ORM — entities, repositories, specifications, joins │
├────────────────────────────────────────────────────────────┤
│ Distributed — ring, replicas, coordinator (One/Quorum/All) │
├────────────────────────────────────────────────────────────┤
│ Engine — tables' stores, query planner, joins │
├────────────────────────────────────────────────────────────┤
│ Table — schemas, constraints, evolution │
├────────────────────────────────────────────────────────────┤
│ Indexes — B-tree, hash, bloom, inverted │
├────────────────────────────────────────────────────────────┤
│ Storage — WAL, memtable, SSTables, compaction, snapshots │
├────────────────────────────────────────────────────────────┤
│ MLambda.Actor — actors, supervision, cluster, Fortress │
└────────────────────────────────────────────────────────────┘
Key features
- LSM-tree storage: write-ahead log, memtable, SSTables with bloom blocks, size-tiered compaction, snapshots.
- Four index kinds: B-tree (ranges, prefixes), hash (equality), bloom (skip a table), inverted (full text).
- A query planner that answers a filter through an index, or by a scan when none fits.
- Specifications: filters combined with and, or and not, with an order and a page.
- Joins across repositories, a hash join inside the engine.
- Replication on a consistent-hash ring, with One, Quorum or All per request and read repair.
- Schema evolution that keeps old rows readable, and constraints checked on every write.
- A REST API and five live channels (metrics, ring, cluster, alerts, compaction), with JWT auth and permissions.
- Four topologies in Docker: standalone, hybrid, cluster and fortress, each surviving a restart.
Where next
- Getting Started
- Developer Guide
- Deployment
- API Spec: the REST API.
Every page
- Why MLambda.Data? · Architecture · Core Concepts · Getting Started · API Reference · Deployment · Consistency Model · Performance · Developer Guide
- Research: Whitepaper · Executive Summary
- Proved: the ring’s consistency is a TLA+ specification, model-checked; the specification is kept
with the code, in the repository’s
docs/formal.
The admin
MLambda Data’s admin, in the browser and as an Ubuntu package from the Store: the stores, their records and who may read them.
