Rhei pairs Rusqlite (OLTP) with a pluggable OLAP layer (DataFusion or DuckDB), connected by trigger-based CDC replication and automatic SQL query routing. It can also operate as a sidecar DBMS, following an external database (SQLite, PostgreSQL) via timestamp-based CDC and maintaining temporal (SCD Type 2) history for point-in-time queries.
Highlights:
- Zero-config HTAP: writes go to OLTP, analytical queries auto-route to OLAP
- CDC-powered sync with background replication and pruning
- Sidecar mode: attach to any SQLite/PostgreSQL as a read-only analytical mirror
- Arrow Flight SQL server for network-accessible OLAP queries (ADBC/JDBC/DBeaver)
- Python bindings via PyO3 (fully async, asyncio + anyio)
- CLI tool (
rh) with interactive REPL, live TUI dashboard, and headless service mode - Docker-ready: multi-stage Dockerfile, 66MB optimized binary
Performance
Rust API (release mode, LTO)
| Operation | DataFusion | DuckDB |
|---|---|---|
| Insert 700 rows | 10,267/s | 8,797/s |
| CDC sync | 141,326 evt/s | 43,579 evt/s |
| CRUD 225 ops | 12,072/s | 13,998/s |
| Concurrent 8x50 | 10,654/s | 14,779/s |
Python API (asyncio via PyO3)
| Operation | Throughput |
|---|---|
| Insert 500 rows | 2,491/s |
| CDC sync | 32,142 evt/s |
| Batch 400 rows | 30,733/s |
Sidecar (DataFusion temporal, InMemory baseline)
| Metric | Value |
|---|---|
| INSERT sync p50 (10 rows/cycle) | 228us |
| INSERT sync p99 (10 rows/cycle) | 943us |
| Initial sync @ 10K rows | 488K evt/s |
| Initial sync @ 100K rows | 466K evt/s |
FlightSQL (100K rows, streaming + zstd)
| Query type | Local | Network | Overhead |
|---|---|---|---|
| Full scan | 1,713 q/s | 67 q/s | 26x |
| Filtered | 466 q/s | 181 q/s | 2.6x |
| GROUP BY | 261 q/s | 23 q/s | 11x |
Vortex storage cross-mode — the durability dial (v2.0, 50-cycle steady-state sync, 10 rows/cycle):
| Storage mode | sync p50 | sync p99 | Initial @ 100K |
|---|---|---|---|
InMemory (volatile) |
308 µs | 699 µs | 387K rows/s |
Vortex local (durable) |
5.5 ms | 7.2 ms | 473K rows/s |
Vortex S3-compatible (durable + distributed) |
209 ms | 437 ms | 186K rows/s |
See E2E_TEST_REPORT.md for the full v2.0 methodology and the Postgres-source numbers.
Architecture
Standard HTAP Mode
==================
Client ──> HtapEngine (facade)
|
|-- SqlParserRouter ──> AST-based routing (OLTP or OLAP)
|
|-- RusqliteEngine (OLTP)
| |-- Write connection (dedicated thread + crossbeam channel)
| |-- Read pool (round-robin, WAL mode)
| +-- CDC triggers ──> _rhei_cdc_log (json_array)
|
|-- OlapBackend
| |-- DataFusion (pure Rust, async, InMemory / Vortex { url })
| +-- DuckDB (C++ via FFI, MVCC concurrent reads)
|
+-- CdcSyncEngine
|-- Background sync loop (configurable interval)
|-- Batch INSERT grouping + CDC pruning
+-- Destructive (mirror) or Temporal (SCD Type 2)
Sidecar Mode
============
External DB (SQLite / PostgreSQL)
| polls by updated_at > watermark
v
TimestampCdcConsumer ──> CdcSyncEngine ──> OlapBackend
| |
+-- INSERT/UPDATE/DELETE heuristics +-- Point-in-time queries
+-- Soft-delete detection via _rhei_valid_from/_rhei_valid_to
Quick Start
Rust
use Arc;
use ;
use ;
async
Python
await
await
await
await
= await
CLI (rh)
Docker
Service Mode
Features
| Feature | Default | Description |
|---|---|---|
datafusion-backend |
Yes | DataFusion OLAP engine (pure Rust, async) |
duckdb-backend |
No | DuckDB OLAP engine (C++, bundled build) |
full |
No | Both OLAP backends |
sidecar |
No | Timestamp-based CDC from external DBs (SQLite + PostgreSQL), incl. RocksDB-persistent watermarks |
flight-sql |
No | Arrow Flight SQL gRPC server for OLAP queries (bearer-token auth optional) |
rocksdb-cdc |
No | RocksDB-backed CDC log / bridge (5-7× faster writes, crash-durable trigger → sync pipeline) |
metrics |
No | Counters/gauges via the metrics crate facade |
metrics-exporter |
No | Prometheus HTTP metrics endpoint on rhei-tui |
cloud-storage |
No | S3-compatible object-store backend for DataFusion Vortex storage (s3:// URL scheme). Local Vortex paths work without this feature. GCS is not supported in v2.0 — use an S3-compatibility shim (e.g. MinIO over gcsfuse) and set AWS_ENDPOINT_URL. |
API Reference
| Method | Description |
|---|---|
HtapEngine::new(config) |
Create engine (auto-starts sync if sync_interval set) |
execute(sql, params) |
Write to OLTP (errors in pure sidecar mode) |
execute_batch(stmts) |
Multi-statement transaction (much faster) |
query(sql) |
Auto-routed: OLTP for point reads, OLAP for analytics |
query_with_hint(sql, hint) |
Force OLTP or OLAP routing |
register_table(schema) |
Register for replication (CDC triggers + OLAP mirror) |
sync_now() |
Single CDC sync cycle |
start_sync(interval) / stop_sync() |
Background sync loop |
initial_sync(table) / initial_sync_all() |
Bulk-load OLTP rows to OLAP |
add_column(table, col, type) |
Schema evolution: registry + OLAP + triggers |
drop_column(table, col) |
Schema evolution: teardown triggers + ALTER |
sync_status() |
CDC lag, last synced seq, running state |
oltp() / olap() |
Direct engine access |
Sidecar Mode
Attach to an external database as a read-only analytical mirror with full temporal history:
let config = HtapConfig ;
let engine = new.await?;
// Time-travel query: "What was order 42 at time T?"
let batches = engine.query.await?;
Arrow Flight SQL
With --features flight-sql, Rhei exposes OLAP queries over gRPC using the Arrow Flight SQL protocol. Queries stream directly from the OLAP engine (via query_stream()) with zstd compression — no buffering of full results in memory.
# config/htap.toml
[]
= 50051
# Python client (ADBC)
=
=
=
Compatible with: Python (adbc_driver_flightsql), Java (Arrow Flight JDBC), DBeaver, Go (adbc/driver/flightsql).
Features: streaming execution, zstd/lz4 compression, deferred query execution (no double-execute), read-only (OLAP only).
Testing
RHEI_TEST_FLIGHT=1
See E2E_TESTING_SOP.md for the full testing procedure and E2E_TEST_REPORT.md for the latest v2.0 numbers.
Workspace Crates
| Crate | Description |
|---|---|
rhei |
Facade: HtapEngine, HtapConfig, integration tests |
rhei-core |
Traits (OlapEngine, OltpEngine, CdcConsumer), types, SchemaRegistry |
rhei-tokio-rusqlite |
Async rusqlite wrapper (dedicated thread + crossbeam) |
rhei-oltp-rusqlite |
Rusqlite OLTP: write conn + read pool + CDC producer |
rhei-olap |
Backend-agnostic OLAP dispatcher (OlapBackend enum) |
rhei-datafusion |
DataFusion engine (InMemory / Vortex { url } — local + S3-compatible) |
rhei-duckdb |
DuckDB engine (write conn + read pool, MVCC) |
rhei-sync |
CdcSyncEngine, SqlParserRouter, CDC-to-DML converter |
rhei-cdc-rocksdb |
RocksDB-backed CDC log (durable, 5-7x faster) |
rhei-sidecar |
TimestampCdcConsumer (SQLite + PostgreSQL) |
rhei-flight |
Arrow Flight SQL gRPC server (streaming + zstd) |
rhei-tui |
CLI tool (rh) + TUI dashboard |
Citation
If you use Rhei in your research, please cite it as:
License
Apache-2.0