DEV Community

Cover image for From Embedded Engine to Distributed Database: LioranDB's Cluster Architecture
Swaraj Puppalwar
Swaraj Puppalwar

Posted on

From Embedded Engine to Distributed Database: LioranDB's Cluster Architecture

LioranDB begins with a local transactional storage engine, but its architecture extends beyond one process.

The DBMS backend can operate in several modes:

Local
Multi-core
Multi-node
Remote cluster
Enter fullscreen mode Exit fullscreen mode

One DBMS interface

The document layer talks through a backend abstraction.

A read transaction may therefore target:

Local(ReadTxn)
MultiCore
MultiNode
Cluster
Enter fullscreen mode Exit fullscreen mode

The document query layer does not need a completely different API for each deployment model.

Multi-core routing

In multi-core mode, a table and key are mapped to one engine partition.

table + key
    ↓
partition hash
    ↓
local engine partition
Enter fullscreen mode Exit fullscreen mode

Multi-node routing

In multi-node mode, the operation first selects a node and then a partition inside that node.

table + key
    ↓
node
    ↓
partition
    ↓
engine
Enter fullscreen mode Exit fullscreen mode

Global scans visit several partitions or nodes and merge the returned keys.

WAL-based replication

The cluster crate includes a leader-driven replication abstraction.

A replicator:

  1. Fetches WAL entries from a starting LSN.
  2. Limits the batch by entries and bytes.
  3. Sends the batch to a follower.
  4. Receives the follower's acknowledged LSN.
  5. Continues from the next LSN.

The current abstraction is synchronous, but it cleanly separates WAL production from transport.

That transport can later be backed by RPC.

gRPC server

The server crate opens a node using:

  • Cluster configuration
  • Node identity
  • On-disk engine configuration
  • TLS certificates
  • Certificate authority
  • ACL rules
  • gRPC listen address
  • Metrics address

This is the boundary where the database becomes a network service instead of an embedded library.

The larger idea

A distributed database should not be designed by gluing networking onto a single global engine at the end.

It needs internal seams for:

Partition ownership
Request routing
WAL shipping
Follower application
Read preferences
Node configuration
Security
Observability
Enter fullscreen mode Exit fullscreen mode

LioranDB's architecture is building those seams from the storage layer upward.

The result is a path from one Rust process to a multi-core and eventually replicated database system without replacing the entire core halfway through.

That is the architectural long game.


LioranDB is developed by Swaraj Puppalwar under Lioran Group.

Explore the project:

Top comments (0)