Orbit-RS Architecture
Security and Durability Invariants
- Network-facing database protocols must fail closed when required credentials are absent. MySQL and CQL credentials are supplied through environment variables; Redis requires
ORBIT_REDIS_PASSWORDfor non-loopback binding. - REST data and transaction-management routes require a bearer token from
ORBIT_API_TOKEN; health and OpenAPI discovery remain separate public routes. - Metrics bind to
127.0.0.1by default throughORBIT_METRICS_BIND. - Unified cross-protocol storage uses synchronous RocksDB writes in production. The in-memory backend is reserved for explicit tests.
- Transaction-log entries remain buffered until the database batch succeeds; failed flushes are retryable rather than silently destructive.
Project Overview
Orbit-RS is a next-generation distributed actor system framework built in Rust, providing a comprehensive multi-model database platform with advanced query capabilities. It extends the original Orbit concept with native support for graph databases, time series analytics, and unified query processing.
Key Features
- Virtual Actor Model: Addressable actors with persistent state and distributed execution
- Multi-Model Database: Native support for graphs, documents, time series, and relational data
- ✨ AI-Native Database (NEW Nov 2025): 8 production-ready intelligent subsystems for autonomous optimization
- Multi-Protocol Support: 10+ protocol adapters for seamless integration
- RESP (Redis): Production-ready Redis-compatible protocol (50+ commands)
- PostgreSQL Wire Protocol: Complete PostgreSQL v3.0 implementation
- MySQL Wire Protocol: MySQL-compatible protocol adapter
- CQL (Cassandra): Cassandra Query Language support
- Cypher/Bolt (Neo4j): Graph database compatibility
- AQL (ArangoDB): ArangoDB Query Language support
- OrbitQL: Native query language with ML extensions
- REST API: HTTP/JSON with OpenAPI documentation and WebSocket support
- MCP (Model Context Protocol): LLM integration for natural language queries
- gRPC: Actor system management and inter-node communication
- Advanced Query Languages: Cypher, AQL, CQL, SQL, OrbitQL, and natural language support
- High-Performance Time Series: Real-time analytics with advanced compression and partitioning
- Distributed by Design: Built for horizontal scaling and fault tolerance
- Actor Integration: Direct database access through the actor system
- Zero Compiler Warnings: 100% clean compilation across 148,780+ lines of Rust code
System Architecture
High-Level Architecture
┌─────────────────────────────────────────────────────────────────────────────┐
│ Protocol Adapter Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ RESP │ │ PostgreSQL │ │ MySQL │ │ CQL │ │
│ │ (Redis) │ │ Wire │ │ Wire │ │ (Cassandra) │ │
│ │ │ │ Protocol │ │ Protocol │ │ │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Cypher │ │ AQL │ │ OrbitQL │ │ REST │ │
│ │ / Bolt │ │ (ArangoDB) │ │ (Native) │ │ API │ │
│ │ (Neo4j) │ │ │ │ │ │ + WebSocket│ │
│ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │
│ ┌─────────────┐ ┌─────────────┐ │
│ │ MCP │ │ gRPC │ │
│ │ (LLM/NLP) │ │ (Actors) │ │
│ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ AI-Native Layer (NEW) │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────────────────┐ │
│ │ AI Master │ │ Intelligent │ │ Predictive Resource │ │
│ │ Controller │ │ Query Optimizer│ │ Manager │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────────────────┘ │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────────────────┐ │
│ │ Smart Storage │ │ Adaptive TX │ │ Learning & Decision │ │
│ │ Manager │ │ Manager │ │ Engines + Knowledge Base │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ Query Engine Layer │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────────────────┐ │
│ │ Query Planner & │ │ Execution │ │ Query Optimization & │ │
│ │ Optimizer │ │ Engine │ │ Distributed Routing │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ Multi-Model Storage Layer │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────────────────┐ │
│ │ Graph Database │ │ Time Series │ │ Document & Key-Value │ │
│ │ │ │ Engine │ │ Storage │ │
│ │ • Node Storage │ │ • In-Memory │ │ • JSON Documents │ │
│ │ • Relationship │ │ • Redis TS │ │ • Relational Tables │ │
│ │ Storage │ │ • Timescale │ │ • Actor State Storage │ │
│ │ • Graph ML │ │ • Compression │ │ │ │
│ │ • Analytics │ │ • Partitioning │ │ │ │
│ │ • GraphRAG │ │ │ │ │ │
│ │ Persistence │ │ │ │ │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ Hybrid Storage Tier Management │
│ ┌───────────────────────────────────────────────────────────────────────┐ │
│ │ HOT TIER (0-48h) │ WARM TIER (2-30d) │ COLD TIER (>30d) │ │
│ │ • Row-based (RocksDB) │ • Columnar batches │ • Apache Iceberg │ │
│ │ • HashMap index │ • In-memory │ • Parquet files │ │
│ │ • OLTP optimized │ • Hybrid format │ • S3/Azure │ │
│ │ • Point queries │ • Mixed workloads │ • Metadata prune │ │
│ │ • Writes/Updates │ • Analytics ready │ • Time travel │ │
│ │ │ │ • Schema evolution │ │
│ │ │ │ • 100-1000x plan │ │
│ └───────────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ Actor System Layer │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────────────────┐ │
│ │ Virtual Actors │ │ Persistence │ │ Cluster Management │ │
│ │ │ │ │ │ │ │
│ │ • Addressable │ │ • COW B-Tree │ │ • Node Discovery │ │
│ │ Leasing │ │ • LSM Tree │ │ • Load Balancing │ │
│ │ • State Mgmt │ │ • RocksDB │ │ • Fault Tolerance │ │
│ │ • Lifecycle │ │ • Memory │ │ • Health Monitoring │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ Cluster Coordination & Distributed Storage │
│ ┌───────────────────────────────────────────────────────────────────────┐ │
│ │ CLUSTER COORDINATION │ DISTRIBUTED STORAGE │ │
│ │ • Raft Consensus │ • Data Partitioning │ │
│ │ • Leader Election │ • Replication (3x factor) │ │
│ │ • Node Membership │ • Consistency Levels │ │
│ │ • Health Monitoring │ • Quorum-based Writes │ │
│ │ • Failure Detection │ • Cross-node Shuffling │ │
│ │ • Network Transport │ • Actor-aware Placement │ │
│ │ │ • Distributed Transactions │ │
│ └───────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────────────────────────────┐ │
│ │ STORAGE BACKENDS (Multi-Cloud) │ │
│ │ • S3 (AWS) • Azure Blob Storage │ │
│ │ • Local Filesystem • MinIO (S3-compatible) │ │
│ │ • Iceberg Catalog (REST) • FileIO abstraction │ │
│ └───────────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
Module Architecture
Orbit-RS is structured as a Rust workspace with the following main crates:
Core Crates
orbit-shared
- Purpose: Shared data structures, traits, and utilities
- Key Components:
- Graph database types (
GraphNode,GraphRelationship,GraphStorage) - Time series engine (
TimeSeriesEngine, compression algorithms) - Actor system primitives (
NodeId,AddressableReference) - OrbitQL query language implementation
- Transaction and persistence traits
- Graph database types (
orbit-server
- Purpose: Server-side actor hosting and cluster management
- Key Components:
AddressableDirectory: Actor location trackingClusterNodeProvider: Node management- Persistence backends (Memory, COW B-Tree, LSM Tree, RocksDB)
- Kubernetes operator integration
- Dynamic persistence configuration
orbit-protocols
- Purpose: Protocol implementations and query engines
- Key Components:
- RESP (Redis Protocol) - Production-ready Redis-compatible protocol (50+ commands)
- PostgreSQL Wire Protocol - Complete PostgreSQL v3.0 implementation with SQL parsing
- MySQL Wire Protocol - MySQL-compatible protocol adapter
- CQL (Cassandra Query Language) - Cassandra-compatible protocol adapter
- Cypher/Bolt Protocol - Neo4j graph database compatibility
- AQL (ArangoDB Query Language) - ArangoDB-compatible query language support
- OrbitQL - Native Orbit query language with ML extensions
- REST API - HTTP/JSON interface with OpenAPI documentation and WebSocket support
- MCP (Model Context Protocol) - LLM integration for natural language queries
- gRPC - Actor system management and inter-node communication
- Protocol buffer definitions
orbit-engine
- Purpose: Core storage engine with tiered storage and cluster coordination
- Key Components:
- Hybrid Storage Manager - Three-tier storage (Hot/Warm/Cold)
- Iceberg Cold Store - Apache Iceberg integration for cold tier analytics
- Columnar Storage - SIMD-optimized columnar batches
- Cluster Coordinator - Raft consensus and distributed coordination
- Replication Manager - Multi-node data replication
- Storage Backends - S3, Azure Blob, local filesystem support
- Vectorized Executor - SIMD-optimized query execution
Specialized Modules
orbit-operator
- Purpose: Kubernetes operator for cluster management
- Key Components:
- Custom Resource Definitions (CRDs)
- Operator controller logic
- Persistence configuration management
Examples and Testing
- Hello World actor example
- OrbitQL usage examples
- Time series analytics demo
- Persistence configuration examples
- tests/: Integration and performance tests
- Graph database tests
- Time series engine tests
- Protocol compatibility tests
Core Concepts
Addressables (Virtual Actors)
Addressables are the core abstraction in Orbit. They are virtual actors that:
- Have a unique identity (type + key)
- Are instantiated on-demand when first invoked
- Can be automatically migrated between nodes
- Support lifecycle callbacks (OnActivate, OnDeactivate)
- Can be either keyed (with identity) or keyless
use async_trait::async_trait;
use orbit_shared::{Addressable, AddressableReference, Key, OrbitResult};
#[derive(Debug, Clone)]
pub struct GreeterActor {
name: String,
}
#[async_trait]
impl Addressable for GreeterActor {
fn addressable_type() -> &'static str {
"GreeterActor"
}
}
impl GreeterActor {
pub async fn greet(&self, name: String) -> OrbitResult<String> {
Ok(format!("Hello {}", name))
}
}
Node Management
Nodes in the cluster are identified by:
NodeId: Combination of key and namespaceNodeCapabilities: What services/actor types the node can hostNodeStatus: Current operational status- Lease-based lifecycle with automatic renewal
Message System
Communication uses a structured message system:
Message: Container with content, source, target, attemptsMessageContent: Various message types (invocation requests/responses, errors, connection info)MessageTarget: Unicast or routed unicast delivery- Protocol Buffer serialization for network transport
Invocation Model
Actor method calls are handled through:
AddressableReference: Type-safe actor references with compile-time checkingAddressableInvocation: Structured representation of method callsInvocationSystem: Routes calls to appropriate nodes via gRPC- Serialization/deserialization of arguments and results using Protocol Buffers
Lease Management
Both actors and nodes use lease-based management:
- Automatic lease renewal to indicate liveness
- Configurable lease duration
- Cleanup of expired leases
- Grace periods for lease renewal failures
Dependencies
Core Rust Dependencies
- Rust: Edition 2021 (main language)
- Tokio: 1.48+ (async runtime with full features)
- Tonic: 0.12 (gRPC framework for inter-node communication)
- Prost: 0.13 (Protocol Buffers serialization)
- Serde: 1.0 (JSON and general serialization)
- Tracing: 0.1 (structured logging)
- Metrics: 0.23 (Prometheus metrics integration)
Build and Testing
- Cargo: Rust package manager and build system
- Tokio Test: 0.4 (async testing utilities)
- Mockall: 0.13 (mocking framework)
- Criterion: Performance benchmarking (via benchmarks crate)
- Cucumber: 0.21 (BDD testing framework)
Communication Flow
- Client Invocation: Client calls method on actor via
AddressableReference - Reference Resolution:
AddressableReferenceprovides type-safe actor access - Message Creation: Call is serialized into
AddressableInvocationusing Protocol Buffers - Routing: System determines which node hosts the actor via directory lookup
- Network Transport: Message sent via gRPC (Tonic) to target node
- Server Processing: Target node deserializes and executes call on actor instance
- Response: Result serialized and sent back to client
- Completion: Client receives response and completes the async future
Scalability Features
- Horizontal Scaling: Add nodes to increase capacity
- Actor Migration: Actors can move between nodes for load balancing
- Cluster Discovery: Automatic node discovery and membership
- Health Monitoring: Node health checks and failure detection
- Backpressure: Built-in flow control mechanisms
Advanced Transaction Features
The Rust implementation extends the original architecture with a comprehensive transaction system:
Transaction Module Architecture
The transaction system is organized into specialized modules:
orbit/shared/src/transactions/
├── core.rs - 2-Phase Commit protocol implementation
├── locks.rs - Distributed locks with deadlock detection
├── metrics.rs - Prometheus metrics integration
├── security.rs - Authentication, authorization, audit logging
└── performance.rs - Batching, connection pooling, resource management
Distributed Lock System
Components:
DistributedLockManager: Coordinates lock acquisition and release across the clusterDeadlockDetector: Performs wait-for graph analysis to detect and resolve deadlocksLockMode: Supports both Exclusive and Shared locking semanticsLockRequest: Encapsulates lock acquisition with timeout and priority
Deadlock Detection:
- Wait-for graph construction tracking resource dependencies
- DFS-based cycle detection with O(N) complexity
- Automatic deadlock resolution with configurable policies
- Lock expiration and timeout handling
Lock Lifecycle:
Request → Wait Queue → Deadlock Check → Acquire → Hold → Release → Cleanup
Metrics and Observability
Metric Types:
- Transaction Metrics
- Counters: started, committed, aborted, failed, timeout
- Gauges: active transactions, queued operations
- Histograms: duration, prepare time, commit time, participant count
- Saga Metrics
- Counters: started, completed, failed, compensated, step execution
- Gauges: active sagas, queued sagas
- Histograms: saga duration, step duration, compensation duration
- Lock Metrics
- Counters: acquired, released, timeout, deadlock detected/resolved
- Gauges: held locks, waiting requests
- Histograms: wait duration, hold duration
Prometheus Integration:
- Automatic metric registration and collection
- Node-scoped metrics for cluster-wide aggregation
- Standard Prometheus metric naming conventions
- Compatible with Grafana dashboards
Security Architecture
Authentication:
- Token-based authentication with JWT-style tokens
- Configurable token expiration and renewal
- Pluggable authentication providers (in-memory, external)
Authorization:
- Scope-based permission model
- Fine-grained transaction permissions:
- Begin, Commit, Abort (lifecycle operations)
- Read, Write (data operations)
- Coordinate, Participate (coordination roles)
- Hierarchical scope inheritance
Audit Logging:
- Immutable audit trail for all transaction operations
- Query support for forensics and compliance
- Automatic retention management with configurable limits
- Structured log entries with timestamps and outcomes
Security Context:
Request → Authenticate → Authorize → Execute → Audit Log
✨ AI-Native Database Architecture (NEW - Nov 2025)
Overview:
Orbit-RS includes a production-ready AI-Native layer that autonomously optimizes database operations through 8 intelligent subsystems working in concert. This is not experimental ML integration - it’s a complete, tested, zero-warning implementation with 100% test coverage.
AI Master Controller (orbit/server/src/ai/controller.rs):
- Central orchestration hub for all AI subsystems
- 10-second control loop for continuous system optimization
- Real-time metrics collection and aggregation
- Subsystem registration and lifecycle management
- Autonomous decision execution across all layers
Intelligent Query Optimizer (orbit/server/src/ai/optimizer/):
- Cost Estimation Model: Calculates CPU time, memory usage, and I/O operations for query plans
- Pattern Classifier: Analyzes query complexity, identifies optimization opportunities
- Index Advisor: Recommends indexes based on query patterns and access frequency
- Learning Integration: Improves recommendations based on actual execution results
- Confidence Scoring: Provides reliability metrics for optimization decisions
Predictive Resource Manager (orbit/server/src/ai/resource/):
- Workload Predictor: Forecasts CPU, memory, and I/O demand using historical patterns
- Daily/Weekly Patterns: Identifies cyclical resource usage trends
- Predictive Scaling: Proactively allocates resources before demand spikes
- Anomaly Detection: Identifies unusual resource consumption patterns
Smart Storage Manager (orbit/server/src/ai/storage/):
- Auto-Tiering Engine: Automatically moves data between hot/warm/cold tiers
- Access Pattern Analysis: Tracks read/write frequency and recency
- Benefit-Cost Analysis: Optimizes tiering decisions for performance vs. cost
- Data Reorganization: Rebalances storage without service interruption
Adaptive Transaction Manager (orbit/server/src/ai/transaction/):
- Deadlock Preventer: Predicts and prevents deadlocks using cycle detection
- Dependency Graph Analysis: Tracks transaction wait-for relationships
- Dynamic Isolation: Adjusts isolation levels based on contention patterns
- Proactive Conflict Resolution: Resolves potential conflicts before they occur
Learning Engine (orbit/server/src/ai/learning.rs):
- Continuous Learning Mode: Real-time model updates from system observations
- Batch Learning Mode: Periodic retraining on accumulated data
- Pattern Analysis: Identifies correlations between actions and outcomes
- Model Retraining: Automatic model updates when sufficient data is available
Decision Engine (orbit/server/src/ai/decision.rs):
- Policy-Based Decisions: Rule-based decision making with configurable policies
- Multi-Criteria Optimization: Balances performance, cost, and resource usage
- Confidence Thresholds: Only executes high-confidence decisions
- Decision Tracking: Monitors effectiveness of executed decisions
Knowledge Base (orbit/server/src/ai/knowledge.rs):
- Pattern Storage: Persistent storage of learned patterns and outcomes
- Observation Tracking: Records system behavior and performance metrics
- Feature-Outcome Correlation: Links patterns to performance improvements
- Pattern Retrieval: Fast lookup of relevant patterns for decision making
AI System Integration:
┌───────────────────────────────────────────────────────────────┐
│ AI Master Controller │
│ (10-second control loop) │
└───────────────────────────────────────────────────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Query │ │ Resource │ │ Storage │
│ Optimizer │ │ Manager │ │ Manager │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
└────────────┬───────┴──────────┬─────────┘
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ Transaction │ │ Learning & │
│ Manager │ │ Knowledge Base │
└─────────────────┘ └─────────────────┘
Production Statistics:
- Source Files: 17 Rust files (3,925+ lines of production code)
- Test Coverage: 14 comprehensive integration tests (100% passing)
- Code Quality: Zero compiler warnings, full async/await support
- Documentation: Complete API docs, integration examples, usage guides
Performance Optimization System
Batch Processing:
- Adaptive batch sizing based on load
- Priority queue for operation ordering
- Configurable flush triggers (size, time, or manual)
- Automatic batch optimization
Connection Pooling:
- Generic connection pool supporting any connection type
- Health checking with configurable intervals
- Automatic connection lifecycle management
- Connection reuse and cleanup
Resource Management:
- Memory usage tracking and limiting
- Concurrency control with semaphores
- RAII resource guards for automatic cleanup
- Backpressure handling under resource constraints
Saga Pattern Implementation
Orchestration:
- Step-by-step execution with forward progress tracking
- Automatic compensation on failure (backward recovery)
- Persistent saga state for recovery after crashes
- Event-driven coordination between saga steps
Compensation:
- Declarative compensation actions per step
- Automatic rollback in reverse execution order
- Idempotent compensation handlers
- Compensation failure handling and retry logic
State Management:
Saga States: NotStarted → Running → Completed | Compensating → Compensated | Failed
Transaction Recovery
Coordinator Failover:
- Automatic detection of coordinator failures
- Transaction state recovery from persistent log
- Continuation of in-flight transactions
- Participant coordination after recovery
Persistence:
- SQLite-based transaction log with WAL journaling
- Durable state for all transaction phases
- Integrity verification and corruption detection
- Automatic cleanup of completed transactions
Protocol Support Details
Production-Ready Protocols
- RESP (Redis Protocol) - Port 6379
- Status: ✅ Production-Ready
- Implementation: Complete RESP2 protocol implementation with 50+ Redis commands
- Features:
- All core Redis data types (String, Hash, List, Set, Sorted Set)
- Pub/Sub messaging with pattern matching
- Connection management (PING, ECHO, AUTH, QUIT)
- Server commands (INFO, DBSIZE, FLUSHDB)
- TTL and expiration support
- Full redis-cli compatibility
- Command Coverage: 50+ commands including GET, SET, DEL, HSET, HGETALL, LPUSH, RPUSH, PUBLISH, SUBSCRIBE, SADD, ZADD, and more
- Actor Integration: Maps Redis commands to Orbit actors (KeyValueActor, HashActor, ListActor, PubSubActor)
- Extensions: Vector operations (VECTOR.), Time Series (TS.), Graph DB (GRAPH.) - *Planned
- Test Coverage: Comprehensive integration tests with redis-cli validation
- PostgreSQL Wire Protocol - Port 5432
- Status: Production-Ready
- Implementation: Complete PostgreSQL v3.0 wire protocol implementation
- Features:
- Full protocol message types (Startup, Query, Parse, Bind, Execute, Describe, Close, Sync, Terminate)
- Simple query protocol (Query → RowDescription → DataRow → CommandComplete)
- Extended query protocol with prepared statements
- Trust authentication (MD5/SCRAM-SHA-256 planned)
- Transaction status tracking
- Error handling with PostgreSQL-compatible error responses
- SQL Support: SELECT, INSERT, UPDATE, DELETE with WHERE clauses, JSON state management
- PostgreSQL 18 clone-control compatibility: session-level
file_copy_methodvalues (copyandclone) are persisted andCREATE DATABASE ... STRATEGY = FILE_COPYis represented in database metadata. Orbit-RS does not use a PostgreSQL data directory, so filesystem reflink/CoW behavior is not implied; logical snapshot isolation will be implemented in the durable storage layer. - Integration: 9 integration tests (100% passing) with psql client validation
- Compatibility: Works with standard PostgreSQL clients (psql, pgAdmin, DataGrip, etc.)
- Future Enhancements: JOINs, aggregates, window functions, pgvector extension support
Durable compatibility boundaries:
CHECKexpressions are stored with table metadata and evaluated for every durableINSERTandUPDATE; false results return SQLSTATE23514, while NULL follows PostgreSQL check semantics. The legacy wire catalog handlers expose primary-key and secondary-index metadata throughpg_catalog.pg_indexandpg_catalog.pg_indexes. Durable writes use a single writer gate, the dataset is memory-resident, and Raft snapshots currently travel as one bounded frame. Arbitrary system-catalog joins and universal index-backed query lookup remain future compatibility work. - OrbitQL - Port 8081 (or 8080 via REST)
- Status: Production-Ready (90% core functionality complete)
- Implementation: Native query language with comprehensive SQL support
- Features:
- SQL-compatible queries (SELECT, INSERT, UPDATE, DELETE)
- Multi-model operations (Document, Graph, Time-Series)
- Advanced query processing (JOINs, GROUP BY, ORDER BY, LIMIT/OFFSET)
- Graph traversal and relationship queries
- Time-series analysis with temporal queries
- Query optimization with cost-based optimizer
- Query profiling (EXPLAIN ANALYZE)
- Intelligent query caching with dependency tracking
- Live query streaming with change notifications
- ML Extensions: ML function autocompletion, neural network integration
- Developer Experience: Language Server Protocol (LSP) with VS Code extension
- Test Coverage: 20+ integration tests covering all major functionality
- REST API - Port 8080
- Status: ✅ Production-Ready
- Implementation: Complete HTTP/JSON interface with OpenAPI documentation
- Features:
- RESTful actor management endpoints
- Transaction management APIs
- Natural language query endpoints
- WebSocket support for real-time updates
- OpenAPI/Swagger documentation
- Authentication and authorization
- Endpoints: Actor CRUD operations, transaction coordination, query execution
- Use Cases: Web applications, API integration, MCP server backend
- gRPC - Port 50051
- Status: Production-Ready (Core Protocol)
- Implementation: Complete gRPC framework using Tonic
- Features:
- Actor system management
- Inter-node communication
- Cluster coordination
- Protocol Buffer serialization
- Streaming support
- Use Cases: Cluster coordination, actor invocation, internal node communication
Supported Protocols (In Development)
- MySQL Wire Protocol - Port 3306
- Status: In progress; compatibility not yet measured
- Implementation: MySQL wire protocol 4.1+ with full query execution
- Features:
- ✅ MySQL wire protocol (packet encoding/decoding, all major commands)
- ✅ Complete query execution (SELECT, INSERT, UPDATE, DELETE)
- ✅ Prepared statements with parameter binding and metadata
- ✅ Result set building with type inference
- ✅ Error handling with complete SQL→MySQL error code mapping (20+ error codes)
- ✅ Authentication with password verification (native password, clear password)
- ✅ Metrics and monitoring (query counts, error tracking, connection stats)
- ✅ Edge case handling and input validation
- ✅ Comprehensive test coverage (unit, integration, query execution)
- ✅ All MySQL commands implemented (COM_QUERY, COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_CLOSE, COM_STMT_RESET, COM_FIELD_LIST, COM_STATISTICS, COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_PING, COM_QUIT, COM_INIT_DB)
- Current State:
- ✅ Query Execution: 100% complete (all DML operations working)
- ✅ Prepared Statements: 100% complete (parameter binding, metadata encoding, reset support)
- ✅ Result Sets: 100% complete (type inference, proper encoding)
- ✅ Error Handling: 100% complete (20+ error codes mapped, comprehensive error reporting)
- ✅ Authentication: 100% complete (password verification implemented)
- ✅ Metrics: 100% complete (comprehensive metrics implemented)
- ✅ Test Coverage: 100% complete (unit, integration, query execution tests)
- ✅ Edge Cases: 100% complete (empty queries, invalid inputs, error handling)
- ✅ Command Support: 100% complete (all 13 MySQL commands implemented)
- Use Cases: MySQL client compatibility, migration from MySQL, standard SQL access
- Test Coverage:
- Unit Tests: 16/16 passing (authentication, error codes, types, parameters, new commands)
- Integration Tests: 11/11 passing (auth flow, prepared statements, error handling, new commands)
- Query Execution Tests: 5/5 passing (100% pass rate)
- Syntax Tests: 36/36 passing (100% pass rate)
- Total: 68+ tests passing
- Production Readiness: 100% - Fully production ready, all commands implemented
- Documentation: See MySQL Complete Documentation
- CQL (Cassandra Query Language) - Port 9042
- Status: In progress; compatibility not yet measured
- Implementation: Complete CQL 3.x wire protocol v4 with full query execution
- Features:
- ✅ Full CQL wire protocol (frame encoding/decoding, all 16 opcodes)
- ✅ Complete parser for SELECT, INSERT, UPDATE, DELETE, CREATE/DROP TABLE/KEYSPACE
- ✅ WHERE clause parsing with all operators (=, >, <, >=, <=, !=, IN, CONTAINS, CONTAINS KEY)
- ✅ Query execution via SQL engine integration (SELECT, INSERT, UPDATE, DELETE)
- ✅ Result set building with proper CQL protocol encoding and metadata
- ✅ Prepared statements with metadata encoding (column types, variable metadata)
- ✅ Batch operations with execution (LOGGED, UNLOGGED, COUNTER)
- ✅ Type system with complete CQL to SQL value conversion
- ✅ Error handling with complete SQL→CQL error code mapping (all 15 error codes)
- ✅ WHERE clause support in DELETE and UPDATE (MVCC executor integration)
- ✅ Authentication with password verification (AUTH_RESPONSE handling, password authenticator)
- ✅ Metrics and monitoring (query counts, error tracking, connection stats)
- ✅ Collection types support (List, Map, Set, Tuple with JSON encoding)
- ✅ Production deployment guide (complete deployment documentation)
- Current State:
- ✅ Parser: 95% complete (all major statements, WHERE clauses, value parsing)
- ✅ Query Execution: 100% complete (all DML operations working)
- ✅ Result Sets: 100% complete (proper protocol encoding with metadata)
- ✅ Prepared Statements: 90% complete (metadata encoding implemented)
- ✅ Batch Operations: 80% complete (execution implemented, transaction handling pending)
- ✅ Error Handling: 100% complete (complete error code mapping, all ProtocolError types mapped)
- ✅ Authentication: 100% complete (password verification implemented)
- ✅ Metrics: 100% complete (metrics implemented, production hooks ready)
- ✅ Collection Types: 100% complete (List, Map, Set, Tuple support)
- ✅ Deployment Guide: 100% complete (production deployment documentation)
- ✅ Test Infrastructure: Integration test framework with shared storage
- Use Cases: Cassandra client compatibility, wide-column store access, cqlsh integration
- Test Coverage: 38/38 tests passing (100% pass rate) - All tests passing!
- Unit Tests: 8/8 (100%)
- Integration Tests: 7/7 (100%)
- Query Execution Tests: 23/23 (100%)
- Production Readiness: 100% ✅ - Fully production ready, all tests passing (38/38), complete feature set including collection types, authentication, and deployment guide
- Documentation: See CQL Complete Documentation for comprehensive details
- Cypher/Bolt Protocol (Neo4j) - Port 7687
- Status: ✅ Production-Ready (Full Bolt v4.4 + 70+ Cypher Functions)
- Features: Complete Neo4j Bolt v4.4 protocol, comprehensive Cypher query language, RocksDB persistence
- Bolt Protocol v4.4:
- ✅ PackStream encoding/decoding (Null, Bool, Int, Float, String, List, Map, Structure)
- ✅ Connection handshake and version negotiation
- ✅ Authentication (HELLO with auth token)
- ✅ Transaction management (BEGIN/COMMIT/ROLLBACK)
- ✅ Streaming results (RUN/PULL/DISCARD)
- ✅ Connection routing (ROUTE message)
- Cypher Query Language:
- ✅ All clauses: MATCH, CREATE, MERGE, DELETE, SET, REMOVE, RETURN, WITH, WHERE
- ✅ Advanced clauses: UNWIND, FOREACH, CASE expressions
- ✅ Variable-length path patterns (
*1..3) - ✅ ORDER BY, SKIP, LIMIT
- ✅ 70+ built-in functions (string, list, math, date/time, type, path)
- Graph Engine:
- ✅ Pattern matching with node/relationship filters
- ✅ Graph algorithms (PageRank, Community Detection, Shortest Path)
- ✅ GraphRAG integration for AI-enhanced graph queries
- Storage:
- ✅ RocksDB persistence at
data/cypher/rocksdb/ - ✅
CypherGraphStoragewith nodes, relationships, metadata column families - ✅ Automatic data loading on startup
- ✅ In-memory caching for fast access
- ✅ RocksDB persistence at
- Tests: 68+ tests passing
- Use Cases: Graph database queries, Neo4j client compatibility, persistent graph storage
- Documentation: See Protocol Persistence Status
- AQL (ArangoDB Query Language) - Port 8529
- Status: ✅ Production-Ready (RocksDB Persistence)
- Features: ArangoDB-compatible query language, RocksDB persistence
- Current State:
- ✅ Server initialized in
main.rs - ✅ RocksDB persistence at
data/aql/rocksdb/ - ✅
AqlStoragewith collections, documents, edges, graphs, metadata column families - ✅ Automatic data loading on startup
- ✅ In-memory caching for fast access
- ✅ Server initialized in
- Persistence: Full RocksDB persistence with column families
- Use Cases: Multi-model database queries, ArangoDB client compatibility, persistent document/graph storage
- Documentation: See Protocol Persistence Status
Experimental Protocols
- MCP (Model Context Protocol) - Via REST API
- Status: ✅ Production-Ready (100% Complete)
- Features: LLM integration, natural language to SQL conversion, schema discovery
- Current State:
- ✅ MCP server initialized in
main.rs - ✅ Connected to PostgreSQL storage (
TieredTableStorage) - ✅ Connected to query engine (
QueryEngine) - ✅ Schema discovery with real-time updates
- ✅ NLP processor (intent classification, entity extraction)
- ✅ SQL generator (schema-aware query building)
- ✅ Result processor (data summarization, statistics)
- ✅ Orbit-RS integration layer
- ✅ MCP tools (
query_data,describe_schema,analyze_data,list_tables) - ✅ All handlers implemented (resources/read, prompts/get, tools/call)
- ✅ Dynamic resource fetching with server integration
- ✅ Enhanced prompt system with context-aware prompts
- ✅ 25+ comprehensive tests
- ✅ MCP server initialized in
- Capabilities: SQL query execution, vector search, actor management, natural language queries
- Use Cases: AI agent integration, conversational queries, LLM tool access
- Documentation: See MCP Implementation Status
MCP Architecture Details
The MCP server provides a complete natural language to SQL pipeline for LLM integration:
┌─────────────────────────────────────────────────────────┐
│ LLM Client │
│ (Claude, GPT-4, etc.) │
└────────────────────┬────────────────────────────────────┘
│ MCP Protocol
↓
┌─────────────────────────────────────────────────────────┐
│ MCP Server │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Natural Language Query Processor │ │
│ │ - Intent Classification (Rule-based + ML) │ │
│ │ - Entity Recognition │ │
│ │ - Condition Extraction │ │
│ └──────────────────────────────────────────────────┘ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ SQL Generation Engine │ │
│ │ - Schema-aware building │ │
│ │ - Parameter binding │ │
│ │ - Optimization hints │ │
│ └──────────────────────────────────────────────────┘ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Orbit-RS Integration Layer │ │
│ │ - Query execution │ │
│ │ - Schema discovery │ │
│ │ - Result conversion │ │
│ └──────────────────────────────────────────────────┘ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Result Processor │ │
│ │ - Summarization │ │
│ │ - Statistics │ │
│ │ - Visualization hints │ │
│ └──────────────────────────────────────────────────┘ │
└────────────────────┬────────────────────────────────────┘
│
↓
┌─────────────────────────────────────────────────────────┐
│ Orbit-RS Query Engine │
│ (PostgreSQL Wire Protocol) │
└─────────────────────────────────────────────────────────┘
MCP Components:
- Natural Language Processing (
nlp.rs- 651 lines)- Intent classification (SELECT, INSERT, UPDATE, DELETE, ANALYZE)
- Entity recognition (tables, columns, values, functions)
- Condition extraction (WHERE clauses)
- Projection extraction (SELECT columns)
- Confidence scoring
- Aggregation detection
- Limit extraction
- Ordering extraction
- SQL Generation (
sql_generator.rs- 450 lines)- Schema-aware query building
- Parameter binding for SQL injection protection
- Query type detection (Read/Write/Analysis)
- Complexity estimation (Low/Medium/High)
- Optimization hints (indexes, partitioning, etc.)
- Support for all SQL operations
- Result Processing (
result_processor.rs- 485 lines)- Data summarization
- Statistical analysis (min, max, mean, median, quartiles)
- Visualization hints (bar charts, line charts, scatter plots)
- Data preview formatting
- Pagination support
- Column statistics
- Schema Management (
schema.rs- 327 lines,schema_discovery.rs- 220 lines)- Thread-safe schema cache with TTL
- Real-time schema discovery
- Background refresh mechanism
- Schema change notifications
- Cache statistics
- Table and column metadata
- Orbit-RS Integration (
integration.rs- 247 lines)- Query execution via PostgreSQL wire protocol
- Schema discovery from Orbit-RS
- Result conversion (PostgreSQL → MCP format)
- Type mapping and conversion
- Error handling and recovery
- ML Framework (
ml_nlp.rs- 320 lines)- ML model integration framework
- Hybrid ML + rule-based processing
- Model manager
- Confidence-based fallback
- Model configuration management
- Ready for actual model integration
MCP Performance Characteristics:
- NLP Processing: <10ms (rule-based), <50ms (with ML)
- SQL Generation: <5ms
- Query Execution: Depends on Orbit-RS (typically <100ms)
- Result Processing: <20ms for 1000 rows
- Schema Cache Hit: <1ms
- Schema Cache Miss: <50ms (with discovery)
MCP Security Features:
- API key authentication
- Parameterized SQL queries (SQL injection protection)
- Origin-based access control
- Rate limiting
- TLS/SSL support
- Input validation
- Query complexity limits
MCP Implementation Statistics:
- 12 modules created
- 12 modules created
- 3,672 lines of Rust code
- 100% of planned core features implemented
- Comprehensive test suite with 12+ test cases
- Production deployment configuration ready
Transaction Layer Architecture
MVCC (Multi-Version Concurrency Control)
Orbit-RS uses MVCC to provide snapshot isolation and high concurrency without read-write conflicts.
Transaction Timeline:
T1: BEGIN (snapshot_id=100)
│
├─ Read row X (sees version with xmin<100, xmax>100)
│
T2: BEGIN (snapshot_id=101)
│
├─ Update row X (creates new version: xmin=101, xmax=∞)
│
T1: ├─ Read row X (still sees old version: xmin<100)
│
T2: ├─ COMMIT (version xmin=101 becomes visible to new txns)
│
T1: ├─ Read row X (still sees old version: snapshot isolation)
│
└─ COMMIT
T3: BEGIN (snapshot_id=102)
└─ Read row X (sees new version: xmin=101 < snapshot_id=102)
Row Versioning
pub struct RowVersion {
pub data: HashMap<String, SqlValue>,
pub xmin: TransactionId, // Creating transaction
pub xmax: Option<TransactionId>, // Deleting transaction
pub created_at: DateTime<Utc>,
pub committed: bool,
}
// Visibility rules
fn is_visible(version: &RowVersion, snapshot: SnapshotId) -> bool {
version.committed
&& version.xmin < snapshot
&& (version.xmax.is_none() || version.xmax.unwrap() > snapshot)
}
Benefits:
- Readers never block writers
- Writers never block readers
- Snapshot isolation provides consistency
- Higher concurrency than 2PL (Two-Phase Locking)
Trade-offs:
- Higher storage overhead (multiple versions)
- Garbage collection needed for old versions
Distributed Transactions (2PC)
Two-Phase Commit protocol for distributed ACID transactions across multiple nodes.
Coordinator Participant A Participant B
│ │ │
├─ BEGIN │ │
├─ Prepare ────────────────────┼──────────────────────────┤
│ │ │
│ PREPARE PREPARE
│ │ │
│ Vote YES Vote YES
│ ◄─────────────────────────┼──────────────────────────┤
│ │ │
├─ Decision: COMMIT │ │
├─ Commit ─────────────────────┼──────────────────────────┤
│ │ │
│ COMMIT COMMIT
│ ◄─────────────────────────┼──────────────────────────┤
│ │ │
├─ DONE │ │
Implementation Features:
- Coordinator failover with transaction state recovery
- SQLite-based transaction log with WAL journaling
- Automatic cleanup of completed transactions
- Participant coordination after recovery
Deadlock Detection
pub struct DeadlockDetector {
// Wait-for graph: transaction -> waiting for transaction
wait_graph: Arc<RwLock<HashMap<TransactionId, HashSet<TransactionId>>>>,
}
impl DeadlockDetector {
// Detect cycles using DFS
pub fn detect_deadlock(&self, tx_id: TransactionId)
-> Option<Vec<TransactionId>> {
// Returns cycle if deadlock detected
}
// Resolve by aborting youngest transaction
pub fn resolve_deadlock(&self, cycle: Vec<TransactionId>)
-> TransactionId {
// Returns transaction to abort
}
}
Deadlock Detection:
- Wait-for graph construction tracking resource dependencies
- DFS-based cycle detection with O(N) complexity
- Automatic deadlock resolution with configurable policies
- Lock expiration and timeout handling
Lock Lifecycle:
Request → Wait Queue → Deadlock Check → Acquire → Hold → Release → Cleanup
Saga Pattern Implementation
Long-running distributed transactions with compensation.
Orchestration:
- Step-by-step execution with forward progress tracking
- Automatic compensation on failure (backward recovery)
- Persistent saga state for recovery after crashes
- Event-driven coordination between saga steps
Compensation:
- Declarative compensation actions per step
- Automatic rollback in reverse execution order
- Idempotent compensation handlers
- Compensation failure handling and retry logic
State Management:
Saga States: NotStarted → Running → Completed | Compensating → Compensated | Failed
Transaction Metrics and Observability
Metric Types:
- Transaction Metrics
- Counters: started, committed, aborted, failed, timeout
- Gauges: active transactions, queued operations
- Histograms: duration, prepare time, commit time, participant count
- Saga Metrics
- Counters: started, completed, failed, compensated, step execution
- Gauges: active sagas, queued sagas
- Histograms: saga duration, step duration, compensation duration
- Lock Metrics
- Counters: acquired, released, timeout, deadlock detected/resolved
- Gauges: held locks, waiting requests
- Histograms: wait duration, hold duration
Prometheus Integration:
- Automatic metric registration and collection
- Node-scoped metrics for cluster-wide aggregation
- Standard Prometheus metric naming conventions
- Compatible with Grafana dashboards
Query Execution Architecture
Vectorized Execution
Orbit-RS uses vectorized execution for high-performance analytical queries.
Traditional Row-at-a-Time:
┌─────┐ ┌──────┐ ┌─────┐
│ Row │ → │Filter│ → │ Agg │
└─────┘ └──────┘ └─────┘
1 row 1 row 1 row
Vectorized Batch-at-a-Time:
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Batch │ → │ Filter │ → │ Agg │
│ 1024 rows│ │ 1024 rows│ │ 1024 rows│
└──────────┘ └──────────┘ └──────────┘
Benefits:
- Better CPU cache utilization
- Reduced function call overhead
- Enables SIMD optimizations
- 5-10x faster aggregations
SIMD Optimization
// Scalar (1 comparison at a time)
for i in 0..values.len() {
if values[i] > threshold {
results.push(i);
}
}
// SIMD (8 comparisons at a time with AVX2)
for chunk in values.chunks(8) {
let vec = _mm256_loadu_si256(chunk);
let threshold_vec = _mm256_set1_epi32(threshold);
let mask = _mm256_cmpgt_epi32(vec, threshold_vec);
// Process mask to extract matching indices
}
Performance Gains:
- 5-10x faster aggregations
- 3-5x faster filters
- 2-3x better compression
Columnar Format
Row-Based Storage:
┌────┬──────┬───────┐
│ id │ name │ price │
├────┼──────┼───────┤
│ 1 │ A │ 10.0 │
│ 2 │ B │ 20.0 │
│ 3 │ C │ 15.0 │
└────┴──────┴───────┘
[1,A,10.0][2,B,20.0][3,C,15.0]
Columnar Storage:
┌────┬────┬────┐
│ id │ id │ id │
├────┼────┼────┤
│ 1 │ 2 │ 3 │
└────┴────┴────┘
[1,2,3]
┌──────┬──────┬──────┐
│ name │ name │ name │
├──────┼──────┼──────┤
│ A │ B │ C │
└──────┴──────┴──────┘
[A,B,C]
┌───────┬───────┬───────┐
│ price │ price │ price │
├───────┼───────┼───────┤
│ 10.0 │ 20.0 │ 15.0 │
└───────┴───────┴───────┘
[10.0,20.0,15.0]
Benefits:
- Better compression (similar values together)
- Cache-friendly for column scans
- Skip irrelevant columns
- SIMD-friendly contiguous data
Clustering and Replication
Raft Consensus
Leader Election:
Node A (Leader) Node B (Follower) Node C (Follower)
│ │ │
├─ Heartbeat ──────────┼────────────────────┤
│ (term=5) │ │
│ │ │
│ (timeout) │
│ │ │
│ RequestVote │
│ ◄───────────────────┤ │
│ (term=6) │
│ │ │
├─ Vote Granted ───────┤ │
│ │ │
│ ├─ RequestVote ──────┤
│ │ (term=6) │
│ │ │
│ │ Vote Granted ─────┤
│ │ │
│ (becomes leader) │
Replication
Write Path with Replication:
Client
│
├─ Write Request
│
▼
Leader (Node A)
│
├─ 1. Write to local log
├─ 2. Replicate to followers
│ │
│ ├─────────────────┬─────────────────┐
│ ▼ ▼ ▼
│ Node B Node C Node D
│ │ │ │
│ ├─ Write log ├─ Write log ├─ Write log
│ ├─ ACK ├─ ACK ├─ ACK
│ │ │ │
│ ◄──┴─────────────────┴─────────────────┘
│
├─ 3. Wait for quorum (2 of 3)
├─ 4. Commit
│
▼
Response to Client
Change Data Capture (CDC)
pub enum CdcEvent {
Insert { table: String, row: Row },
Update { table: String, old: Row, new: Row },
Delete { table: String, row: Row },
Ddl { statement: String },
}
// Subscribe to changes
let mut stream = cdc.subscribe("users", CdcFilter::All).await?;
while let Some(event) = stream.next().await {
match event {
CdcEvent::Insert { table, row } => {
// Handle insert
}
_ => {}
}
}
Protocol Test Coverage Summary
| Protocol | Test Coverage | Production Status | Notes |
|---|---|---|---|
| RESP (Redis) | High | ✅ Production-Ready | 50+ commands, full compatibility |
| PostgreSQL | High | In progress | Conformance: 789 of 816 records (96.7%), 2026-10-27 |
| OrbitQL | High | In progress | Conformance to the OrbitQL 1.0 specification not yet measured; 20+ tests |
| REST API | High | ✅ Production-Ready | OpenAPI documentation, WebSocket support |
| gRPC | High | ✅ Production-Ready | Core protocol, fully integrated |
| MySQL | High | In progress | Compatibility not yet measured; 68+ tests passing. See MySQL Complete Documentation |
| CQL | High | In progress | Compatibility not yet measured; 38/38 tests passing. See CQL Complete Documentation |
| Cypher/Bolt | High | ✅ Production-Ready | 100% complete: Bolt protocol server, WHERE clause, 10+ tests, RocksDB persistence |
| AQL | High | In progress | Compatibility not yet measured; HTTP server, query engine, 30+ tests, RocksDB persistence |
| MCP | High | ✅ Production-Ready | 100% complete: All handlers, dynamic resources, 25+ tests |
Network Layer Architecture
gRPC Services
Orbit-RS uses gRPC for high-performance inter-node communication and actor invocation.
ConnectionService
Bidirectional streaming service for actor communication.
service ConnectionService {
rpc OpenStream(stream MessageProto) returns (stream MessageProto);
rpc GetConnectionInfo(ConnectionInfoRequestProto) returns (ConnectionInfoResponseProto);
}
Implementation:
pub struct OrbitConnectionService {
connections: Arc<Mutex<HashMap<String, mpsc::UnboundedSender<MessageProto>>>>,
}
impl connection_service_server::ConnectionService for OrbitConnectionService {
type OpenStreamStream = tokio_stream::wrappers::UnboundedReceiverStream<Result<MessageProto, Status>>;
async fn open_stream(
&self,
request: Request<Streaming<MessageProto>>,
) -> Result<Response<Self::OpenStreamStream>, Status> {
// Bidirectional message streaming
}
}
HealthService
Standard health check service for monitoring.
service HealthService {
rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse);
}
enum ServingStatus {
UNKNOWN = 0;
SERVING = 1;
NOT_SERVING = 2;
SERVICE_UNKNOWN = 3;
}
Protocol Buffer Definitions
Message Protocol
message MessageProto {
int64 message_id = 1;
NodeIdProto source = 2;
MessageTargetProto target = 3;
MessageContentProto content = 4;
int64 attempts = 5;
}
message MessageContentProto {
oneof content {
ErrorProto error = 1;
ConnectionInfoRequestProto info_request = 2;
ConnectionInfoResponseProto info_response = 3;
InvocationRequestProto invocation_request = 4;
InvocationResponseProto invocation_response = 5;
InvocationResponseErrorProto invocation_response_error = 6;
}
}
Node Protocol
message NodeInfoProto {
NodeIdProto id = 1;
string url = 2;
uint32 port = 3;
NodeCapabilitiesProto capabilities = 4;
NodeStatusProto status = 5;
optional NodeLeaseProto lease = 6;
}
enum NodeStatusProto {
ACTIVE = 0;
DRAINING = 1;
STOPPED = 2;
}
Transport Layer
Connection Pooling
use orbit_shared::transport::TransportConfig;
let config = TransportConfig {
max_connections_per_endpoint: 10, // Pool size per endpoint
connect_timeout: Duration::from_secs(5),
request_timeout: Duration::from_secs(30),
keep_alive_interval: Some(Duration::from_secs(30)),
keep_alive_timeout: Some(Duration::from_secs(10)),
max_message_size: 16 * 1024 * 1024, // 16MB
retry_attempts: 3,
retry_backoff_initial: Duration::from_millis(100),
retry_backoff_multiplier: 2.0,
tcp_keepalive: Some(Duration::from_secs(10)),
http2_adaptive_window: true,
};
Benefits:
- Eliminates connection establishment overhead
- Reduces TCP handshake latency
- Maintains persistent HTTP/2 connections
- Automatic health-based cleanup
Retry Logic
// Automatic retry with exponential backoff:
// Attempt 1: immediate
// Attempt 2: +100ms
// Attempt 3: +200ms
// Attempt 4: +400ms
Retry Strategy:
- Exponential backoff prevents thundering herd
- Non-retryable errors exit immediately (InvalidArgument, NotFound, PermissionDenied)
- Timeout errors trigger retry
- Network errors trigger retry
Connection Metrics
let stats = pool.get_stats().await;
println!("Total connections: {}", stats.total_connections);
println!("Total requests: {}", stats.total_requests);
println!("Total errors: {}", stats.total_errors);
println!("Average latency: {}ms", stats.average_latency_ms);
Metrics Tracked:
- Connection creation time
- Last used timestamp
- Request count per connection
- Error count per connection
- Average latency (exponential moving average)
Raft Transport
Specialized gRPC transport for Raft consensus protocol.
#[async_trait]
pub trait RaftTransport: Send + Sync {
async fn send_vote_request(
&self,
target: &NodeId,
request: VoteRequest,
) -> OrbitResult<VoteResponse>;
async fn send_append_entries(
&self,
target: &NodeId,
request: AppendEntriesRequest,
) -> OrbitResult<AppendEntriesResponse>;
async fn broadcast_heartbeat(
&self,
nodes: &[NodeId],
request: AppendEntriesRequest,
) -> OrbitResult<Vec<AppendEntriesResponse>>;
}
Hybrid Storage Architecture
Orbit-RS uses a hybrid approach combining actors and direct storage based on protocol requirements.
RESP/Redis Protocol - Actor-Based with Persistence
Architecture:
RESP Command
↓
SimpleLocalRegistry (in-memory actors)
├─ KeyValueActor (cache)
├─ ListActor (cache)
├─ SetActor (cache)
├─ SortedSetActor (cache)
└─ RedisDataProvider (RocksDB persistence)
How it works:
- In-Memory Actors:
SimpleLocalRegistrymaintains in-memory actor instances as a cache - Persistent Backing: All data is persisted to RocksDB via
RocksDbRedisDataProvider - Cache-First: Reads check actors first, then fall back to RocksDB if not in cache
- Write-Through: Writes update both actors (cache) and RocksDB (persistence)
Initialization (from main.rs lines 1046-1074):
// Create RocksDB storage for Redis persistence
let redis_data_path = args.data_dir.join("redis").join("rocksdb");
let redis_provider = RocksDbRedisDataProvider::new(
redis_data_path.to_str().unwrap(),
RedisDataConfig::default(),
)?;
// Create RESP server with BOTH actors and persistence
let redis_server = RespServer::new_with_persistence(
bind_addr,
orbit_client,
Some(Arc::new(redis_provider)) // ← RocksDB persistence enabled
);
Data Structure (from simple_local.rs lines 16-29):
pub struct SimpleLocalRegistry {
/// KeyValue actors (in-memory cache)
keyvalue_actors: Arc<RwLock<HashMap<String, KeyValueActor>>>,
/// Hash actors
hash_actors: Arc<RwLock<HashMap<String, HashActor>>>,
/// List actors
list_actors: Arc<RwLock<HashMap<String, ListActor>>>,
/// Set actors
set_actors: Arc<RwLock<HashMap<String, SetActor>>>,
/// Sorted set actors
sorted_set_actors: Arc<RwLock<HashMap<String, SortedSetActor>>>,
/// Optional persistent storage provider
persistent_storage: Option<Arc<dyn RedisDataProvider>>, // ← RocksDB
}
Write-Through Pattern (from simple_local.rs lines 128-148):
// On SET: Update both cache and persistence
"set_value" => {
let value: String = serde_json::from_value(args[0].clone())?;
actor.set_value(value.clone()); // ← Update actor (in-memory cache)
// Persist to storage if available
if let Some(provider) = &self.persistent_storage {
let redis_value = RedisValue::new(value);
provider.set(key, redis_value).await?; // ← Write to RocksDB
}
Ok(serde_json::to_value(())?)
}
Cache-First Reads (from simple_local.rs lines 92-113):
// On GET: Check persistent storage first, then cache
if method == "get_value" {
if let Some(provider) = &self.persistent_storage {
if let Ok(Some(redis_value)) = provider.get(key).await {
// Update in-memory cache from RocksDB
let mut actors = self.keyvalue_actors.write().await;
let actor = actors.entry(key.to_string()).or_insert_with(KeyValueActor::new);
actor.set_value(redis_value.data.clone());
return Ok(serde_json::to_value(Some(redis_value.data))?);
}
}
}
// Fall back to in-memory actor if not in RocksDB
Startup Data Loading (from main.rs lines 1019-1027):
// Load data from RocksDB into actors on startup
if let Some(provider) = redis_provider.as_ref() {
info!("Loading existing Redis data from RocksDB...");
match provider.load_all_data().await {
Ok(data_map) => {
info!("Loaded {} keys from RocksDB", data_map.len());
// Populate actors with loaded data
}
Err(e) => warn!("Failed to load data from RocksDB: {}", e),
}
}
This hybrid approach provides:
- Fast reads: In-memory actor cache
- Durability: RocksDB persistence
- Crash recovery: Data loaded from RocksDB on startup
- Write-through: Both cache and storage updated on writes
Geospatial Architecture
Status: ✅ Production Ready (November 2025)
Orbit-RS provides comprehensive geospatial data support across all protocols through a unified spatial engine. The architecture enables PostGIS-compatible operations, real-time geofencing, and GPU-accelerated spatial analytics.
Architecture Overview
┌─────────────────────────────────────────────────────────┐
│ Multi-Protocol Clients │
│ PostgreSQL │ Redis │ AQL │ Cypher │ OrbitQL │
└─────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────┐
│ Unified Geospatial Engine │
│ ┌───────────────────────────────────────────────────┐ │
│ │ Shared Spatial Operations & Functions │ │
│ │ • SpatialOperations (8 relationship functions) │ │
│ │ • SpatialFunctions (25+ PostGIS functions) │ │
│ │ • WKT/GeoJSON parsing │ │
│ └───────────────────────────────────────────────────┘ │
│ ┌───────────────────────────────────────────────────┐ │
│ │ Spatial Indexing (R-tree, QuadTree) │ │
│ └───────────────────────────────────────────────────┘ │
│ ┌───────────────────────────────────────────────────┐ │
│ │ Spatial Streaming (Geofencing, Analytics) │ │
│ └───────────────────────────────────────────────────┘ │
│ ┌───────────────────────────────────────────────────┐ │
│ │ GPU Acceleration (CPU fallback) │ │
│ └───────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────┐
│ Orbit-RS Storage Engine │
│ • RocksDB persistence for all protocols │
│ • Spatial data types (Point, LineString, Polygon) │
└─────────────────────────────────────────────────────────┘
Core Components
1. Spatial Operations (orbit/shared/src/spatial/operations.rs)
8 OGC-Compliant Relationship Functions:
within(geom1, geom2)- Tests if geom1 is completely within geom2contains(geom1, geom2)- Tests if geom1 completely contains geom2overlaps(geom1, geom2)- Tests if geometries overlaptouches(geom1, geom2)- Tests if geometries touch at boundariescrosses(geom1, geom2)- Tests if geometries crossdisjoint(geom1, geom2)- Tests if geometries are disjointequals(geom1, geom2)- Tests if geometries are spatially equalintersects(geom1, geom2)- Tests if geometries intersect
Measurement Functions:
distance(geom1, geom2)- Calculate distance between geometriesarea(polygon)- Calculate polygon arealength(linestring)- Calculate linestring lengthperimeter(polygon)- Calculate polygon perimeterbounding_box(geometry)- Calculate minimum bounding rectangle
2. PostGIS-Compatible Functions (orbit/shared/src/spatial/functions.rs)
25+ ST_* Functions:
Construction:
ST_Point(x, y)- Create point geometryST_MakePoint(x, y, [z], [m])- Create point with optional Z/MST_GeomFromText(wkt)- Parse WKT (POINT, LINESTRING, POLYGON)ST_GeomFromGeoJSON(json)- Parse GeoJSON
Measurement:
ST_Distance(geom1, geom2)- Cartesian distanceST_Distance_Sphere(geom1, geom2)- Spherical distance (Haversine)ST_Area(polygon)- Polygon areaST_Length(linestring)- Linestring lengthST_Perimeter(polygon)- Polygon perimeter
Relationships:
ST_Contains,ST_Within,ST_Intersects,ST_OverlapsST_Touches,ST_Crosses,ST_Disjoint,ST_EqualsST_DWithin(geom1, geom2, distance)- Distance-based query
Accessors:
ST_X(point),ST_Y(point),ST_Z(point),ST_M(point)ST_SRID(geometry)- Get spatial reference IDST_Envelope(geometry)- Get bounding box as polygonST_IsEmpty(geometry)- Check if geometry is empty
Transformations:
ST_Transform(geometry, srid)- Transform to different CRSST_SetSRID(geometry, srid)- Set spatial reference ID
Output:
ST_AsText(geometry)- Convert to WKTST_AsGeoJSON(geometry)- Convert to GeoJSON
3. Spatial Indexing
R-tree Implementation (orbit/shared/src/spatial/rtree.rs):
- Quadratic split algorithm for node splitting
- Recursive insertion for leaf and non-leaf nodes
- Bounding box queries - O(log n) range queries
- Nearest neighbor search - K-nearest points
- Tests: 4/4 passing
QuadTree (for high-density points):
- Hierarchical spatial partitioning
- Efficient point-in-region queries
- Automatic subdivision
4. Real-Time Spatial Streaming (orbit/shared/src/spatial/streaming.rs)
Geofencing Engine:
- Add/remove geofences dynamically
- Real-time enter/exit detection
- Entity state tracking
- Event generation on boundary crossings
Analytics:
- Distance calculations
- Speed violation detection
- Entity counting
- Real-time metrics
Performance:
- <10ms latency for geofence checks
- Supports thousands of concurrent entities
- Efficient spatial indexing
5. GPU-Accelerated Operations (orbit/compute/src/spatial_distance.rs)
CPU Fallbacks (Production-Ready):
- All operations work without GPU
- Optimized CPU implementations
- Automatic fallback on GPU unavailable
GPU Backends (Optional, Feature-Gated):
- Metal: Apple Silicon optimization
- CUDA: NVIDIA GPU support (planned)
- Vulkan: Cross-platform GPU (planned)
Operations:
- Batch point-in-polygon tests
- DBSCAN clustering
- K-means clustering
- Spatial distance calculations
Protocol Integration
PostgreSQL Wire Protocol
Full PostGIS Compatibility:
-- Create spatial data
SELECT ST_Point(-122.4194, 37.7749);
-- Spatial relationships
SELECT ST_Within(
ST_Point(-122.4194, 37.7749),
ST_GeomFromText('POLYGON((...))')
);
-- Distance queries
SELECT name, ST_Distance_Sphere(location, ST_Point(lng, lat))
FROM locations
WHERE ST_DWithin(location, ST_Point(lng, lat), 1000);
Implementation:
- All ST_* functions registered in PostgreSQL function registry
- WKT/GeoJSON parsing integrated
- Spatial indexes supported
Redis RESP Protocol
Standard GEO Commands:
GEOADD locations -122.4194 37.7749 "San Francisco"
GEODIST locations "San Francisco" "Oakland"
GEORADIUS locations -122.4194 37.7749 10 km
Extended Spatial Commands:
GEO.POLYGON.ADD locations zone1 "POLYGON((...))"
GEO.WITHIN locations "POLYGON((...))"
GEO.INTERSECTS locations point1 polygon1
GEO.CONTAINS locations polygon1 point1
Implementation:
- Standard Redis GEO commands
- Extended commands for complex geometries
- WKT output for all geometry types
AQL (ArangoDB) Protocol
Spatial Functions:
RETURN GEO_CONTAINS(
GEO_POLYGON([[lng1, lat1], [lng2, lat2], ...]),
GEO_POINT(lng, lat)
)
RETURN GEO_DISTANCE(point1, point2)
RETURN GEO_AREA(polygon)
Implementation:
GEO_POINT,GEO_POLYGON,GEO_LINESTRINGconstructorsGEO_CONTAINS,GEO_WITHIN,GEO_INTERSECTSrelationshipsGEO_DISTANCE,GEO_AREA,GEO_LENGTHmeasurements
The AQL parser also covers LET arithmetic, COLLECT grouping, graph traversal, logical expressions, and object keys that overlap with reserved function names. These parser cases are part of the normal regression suite; graph metrics, full-text indexing, and several extended built-ins still require their backing engine integrations.
Cypher (Neo4j) Protocol
Graph-Based Spatial Queries:
MATCH (n:Location)
WHERE within(n.location, $polygon)
RETURN n
MATCH (a:Place)-[:NEAR]->(b:Place)
WHERE distance(a.location, b.location) < 1000
RETURN a, b
Implementation:
contains(),within(),overlaps()functionsdistance()for spatial measurementsbbox()for bounding box calculations
OrbitQL Native Syntax
Spatial Function Registry:
SELECT * FROM locations
WHERE ST_Within(location, ST_GeomFromText('POLYGON((...))'))
SELECT name, ST_Distance(location, ST_Point(-122, 37))
FROM places
ORDER BY ST_Distance(location, ST_Point(-122, 37))
LIMIT 10
Implementation:
- 8 spatial functions registered in OrbitQL
- Full integration with parser and executor
- Comprehensive documentation
Performance Characteristics
Spatial Operations:
- Point-in-polygon: <1ms
- Distance calculations: <1ms
- Relationship tests: <2ms
Spatial Indexing:
- R-tree queries: O(log n)
- Range queries: <5ms for 1M points
- Nearest neighbor: <10ms
Real-Time Streaming:
- Geofence checks: <10ms latency
- Entity tracking: 1000+ concurrent entities
- Event generation: Real-time
GPU Acceleration (when available):
- Batch operations: 5-50x speedup
- Point-in-polygon: 20-100x speedup
- Clustering: 10-50x speedup
Storage and Persistence
RocksDB Integration:
- Spatial data stored in protocol-specific column families
- Efficient serialization of geometries
- Spatial indexes persisted
Data Types:
Point- 2D/3D points with optional M coordinateLineString- Connected line segmentsPolygon- Closed polygons with holes support- WKT/GeoJSON serialization
Use Cases
- Location-Based Services
- Store and query points of interest
- Radius searches (find nearby)
- Geofencing and alerts
- Logistics and Routing
- Route optimization
- Delivery zone management
- Real-time vehicle tracking
- Real Estate and GIS
- Property boundaries
- Zoning analysis
- Spatial analytics
- IoT and Telemetry
- Device location tracking
- Geofence monitoring
- Spatial event processing
Testing and Quality
Test Coverage:
- Spatial operations: 7/7 tests passing
- PostGIS functions: 10/10 tests passing
- R-tree indexing: 4/4 tests passing
- Spatial streaming: 5/5 tests passing
- Protocol integration: 4/4 tests passing
- Total: 30+ tests passing
Documentation:
- Complete API documentation
- Usage examples for all protocols
- Performance benchmarks
- Migration guides
Future Enhancements
Planned Features:
- Additional geometry types (MultiPoint, MultiLineString, MultiPolygon)
- Spatial joins optimization
- 3D spatial operations
- Topology operations
- Spatial aggregations
GPU Acceleration:
- CUDA backend for NVIDIA GPUs
- Vulkan backend for cross-platform
- Advanced clustering algorithms
See Geospatial Implementation Complete for comprehensive details.
Multi-Protocol Architecture
Specialized gRPC transport for Raft consensus protocol.
#[async_trait]
pub trait RaftTransport: Send + Sync {
async fn send_vote_request(
&self,
target: &NodeId,
request: VoteRequest,
) -> OrbitResult<VoteResponse>;
async fn send_append_entries(
&self,
target: &NodeId,
request: AppendEntriesRequest,
) -> OrbitResult<AppendEntriesResponse>;
async fn broadcast_heartbeat(
&self,
nodes: &[NodeId],
request: AppendEntriesRequest,
) -> OrbitResult<Vec<AppendEntriesResponse>>;
}
Hybrid Storage Architecture
Orbit-RS uses a hybrid approach combining actors and direct storage based on protocol requirements.
RESP/Redis Protocol - Actor-Based with Persistence
Architecture:
RESP Command
↓
SimpleLocalRegistry (in-memory actors)
├─ KeyValueActor (cache)
├─ ListActor (cache)
├─ SetActor (cache)
├─ SortedSetActor (cache)
└─ RedisDataProvider (RocksDB persistence)
How it works:
- In-Memory Actors:
SimpleLocalRegistrymaintains in-memory actor instances as a cache - Persistent Backing: All data is persisted to RocksDB via
RocksDbRedisDataProvider - Cache-First: Reads check actors first, then fall back to RocksDB if not in cache
- Write-Through: Writes update both actors (cache) and RocksDB (persistence)
Initialization (from main.rs lines 1046-1074):
// Create RocksDB storage for Redis persistence
let redis_data_path = args.data_dir.join("redis").join("rocksdb");
let redis_provider = RocksDbRedisDataProvider::new(
redis_data_path.to_str().unwrap(),
RedisDataConfig::default(),
)?;
// Create RESP server with BOTH actors and persistence
let redis_server = RespServer::new_with_persistence(
bind_addr,
orbit_client,
Some(Arc::new(redis_provider)) // ← RocksDB persistence enabled
);
Data Structure (from simple_local.rs lines 16-29):
pub struct SimpleLocalRegistry {
/// KeyValue actors (in-memory cache)
keyvalue_actors: Arc<RwLock<HashMap<String, KeyValueActor>>>,
/// Hash actors
hash_actors: Arc<RwLock<HashMap<String, HashActor>>>,
/// List actors
list_actors: Arc<RwLock<HashMap<String, ListActor>>>,
/// Set actors
set_actors: Arc<RwLock<HashMap<String, SetActor>>>,
/// Sorted set actors
sorted_set_actors: Arc<RwLock<HashMap<String, SortedSetActor>>>,
/// Optional persistent storage provider
persistent_storage: Option<Arc<dyn RedisDataProvider>>, // ← RocksDB
}
Write-Through Pattern (from simple_local.rs lines 128-148):
// On SET: Update both cache and persistence
"set_value" => {
let value: String = serde_json::from_value(args[0].clone())?;
actor.set_value(value.clone()); // ← Update actor (in-memory cache)
// Persist to storage if available
if let Some(provider) = &self.persistent_storage {
let redis_value = RedisValue::new(value);
provider.set(key, redis_value).await?; // ← Write to RocksDB
}
Ok(serde_json::to_value(())?)
}
Cache-First Reads (from simple_local.rs lines 92-113):
// On GET: Check persistent storage first, then cache
if method == "get_value" {
if let Some(provider) = &self.persistent_storage {
if let Ok(Some(redis_value)) = provider.get(key).await {
// Update in-memory cache from RocksDB
let mut actors = self.keyvalue_actors.write().await;
let actor = actors.entry(key.to_string()).or_insert_with(KeyValueActor::new);
actor.set_value(redis_value.data.clone());
return Ok(serde_json::to_value(Some(redis_value.data))?);
}
}
}
// Fall back to in-memory actor if not in RocksDB
Startup Data Loading (from simple_local.rs lines 56-82):
/// Load all keys from persistent storage on startup
pub async fn load_from_persistence(&self) -> OrbitResult<()> {
if let Some(provider) = &self.persistent_storage {
debug!("Loading keys from persistent storage");
let keys = provider.keys("*").await?;
let mut actors = self.keyvalue_actors.write().await;
for key in keys {
if let Some(value) = provider.get(&key).await? {
let mut actor = KeyValueActor::new();
actor.set_value(value.data);
// Restore expiration if set
if let Some(expiration) = value.expiration {
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();
if expiration > now {
actor.set_expiration(expiration - now);
}
}
actors.insert(key, actor);
}
}
debug!("Loaded {} keys from persistent storage", actors.len());
}
Ok(())
}
Why Actors for RESP?
- Redis Semantics: Keys naturally map to actors (each key is an actor instance)
- Distributed Future: Enables distributed actor system integration for Redis cluster mode
- Performance: In-memory cache provides sub-millisecond latency for hot data
- Compatibility: Maintains Redis-like behavior with actor lifecycle management
- Persistence: RocksDB ensures data durability across restarts
PostgreSQL, MySQL, CQL - Direct Storage
Architecture:
SQL Query
↓
TieredTableStorage
└─ RocksDB (direct storage)
How it works:
- No actors: Direct RocksDB storage via
TieredTableStorage - Protocol-specific directories: Each protocol has its own RocksDB instance
- PostgreSQL:
data/postgresql/rocksdb/ - MySQL:
data/mysql/rocksdb/ - CQL:
data/cql/rocksdb/
- PostgreSQL:
Code Example:
// orbit/server/src/main.rs
let postgres_storage = Arc::new(TieredTableStorage::with_data_dir(
postgres_data_dir,
tiered_config.clone(),
));
// No actors - direct storage
Storage Comparison
| Protocol | Storage Type | Uses Actors? | Persistence | Data Directory |
|---|---|---|---|---|
| RESP/Redis | Hybrid (Actors + RocksDB) | ✅ Yes (cache layer) | ✅ RocksDB | data/redis/rocksdb/ |
| PostgreSQL | Direct Storage | ❌ No | ✅ RocksDB | data/postgresql/rocksdb/ |
| MySQL | Direct Storage | ❌ No | ✅ RocksDB | data/mysql/rocksdb/ |
| CQL | Direct Storage | ❌ No | ✅ RocksDB | data/cql/rocksdb/ |
| Cypher | Direct Storage | ❌ No | ✅ RocksDB | data/cypher/rocksdb/ |
| AQL | Direct Storage | ❌ No | ✅ RocksDB | data/aql/rocksdb/ |
| GraphRAG | Direct Storage | ❌ No | ✅ RocksDB | data/graphrag/rocksdb/ |
Why This Architecture?
RESP Uses Actors Because:
- Redis Semantics: Keys naturally map to actors
- Distributed Future: Enables distributed actor system integration
- Performance: In-memory cache for hot data
- Compatibility: Maintains Redis-like behavior
Other Protocols Use Direct Storage Because:
- SQL/Query Semantics: Tables/collections don’t map well to actors
- Performance: Direct storage is more efficient for bulk operations
- Simplicity: No need for actor abstraction layer
- Consistency: All protocols use the same RocksDB persistence pattern
Storage Architecture Details
Three-Tier Hybrid Storage
Orbit-RS implements a sophisticated three-tier storage architecture optimized for different data access patterns:
Hot Tier (0-48 hours)
- Storage: Row-based (RocksDB/TiKV)
- Optimization: OLTP workloads, point queries, writes/updates
- Index: HashMap-based primary key index
- Use Cases: Recent data, transactional operations, real-time queries
Warm Tier (2-30 days)
- Storage: Hybrid columnar batches (in-memory)
- Optimization: Mixed workloads, analytics-ready format
- Features: Columnar layout for efficient scans
- Use Cases: Recent analytics, ad-hoc queries, data exploration
Cold Tier (>30 days)
- Storage: Apache Iceberg on S3/Azure Blob Storage
- Format: Parquet files with Zstd compression
- Optimization: Analytics, time travel, schema evolution
- Features:
- Metadata Pruning: 100-1000x faster query planning
- Time Travel: Query historical snapshots
- Schema Evolution: Non-blocking schema changes
- Multi-Engine Access: Compatible with Spark, Trino, Flink
- Storage Efficiency: 20-40% savings via compression and deduplication
- Use Cases: Long-term analytics, data warehousing, compliance queries
Iceberg Integration Benefits
- Query Performance: Metadata-based pruning eliminates unnecessary file scans
- Storage Efficiency: Parquet compression achieves 2.5x+ compression ratios
- Time Travel: Native support for querying historical data versions
- Schema Evolution: Add/modify columns without rewriting data
- Interoperability: Standard format accessible by multiple query engines
Time Travel SQL Syntax
Orbit-RS supports multiple time travel query syntaxes for accessing historical data in Iceberg cold tier tables:
Snowflake-Compatible Syntax
-- Query by timestamp
SELECT * FROM orders AT(TIMESTAMP => '2025-01-01 00:00:00') WHERE status = 'active';
-- Query by version/snapshot ID
SELECT * FROM orders AT(VERSION => 123456789);
-- Query by snapshot
SELECT * FROM orders AT(SNAPSHOT => 987654321);
-- With table alias and JOINs
SELECT o.*, c.name
FROM orders AT(TIMESTAMP => '2025-01-01') o
JOIN customers c ON o.customer_id = c.id;
SQL:2011 Temporal Syntax
-- FOR SYSTEM_TIME AS OF (standard temporal query)
SELECT * FROM orders FOR SYSTEM_TIME AS OF TIMESTAMP '2025-01-01 00:00:00';
-- Also supports underscore form
SELECT * FROM orders FOR SYSTEM_TIME AS OF '2025-01-01';
UNDROP TABLE (Data Recovery)
-- Restore a recently dropped table from Iceberg snapshots
UNDROP TABLE deleted_orders;
UNDROP TABLE myschema.archived_data;
Implementation Status:
- SQL Parsing: Complete - All syntaxes fully parsed and validated
- Iceberg Storage: Complete -
query_as_of(),query_by_snapshot_id(),list_snapshots()implemented - Executor Integration: Complete - MVCC strategy routes to IcebergColdStore when configured
- Activation: Requires
storage-icebergfeature flag and Iceberg catalog configuration - Key Files:
sql/parser/select.rs,execution/iceberg_cold.rs,engine/storage/iceberg.rs
Cluster Coordination
The cluster layer provides distributed system capabilities:
- Raft Consensus: Leader election and distributed consensus
- Node Membership: Dynamic node discovery and health monitoring
- Replication: Configurable replication factor (default 3x)
- Consistency Levels: Strong, eventual, and quorum-based consistency
- Fault Tolerance: Automatic failover and recovery
- Load Balancing: Intelligent query routing based on node capacity
- Data Partitioning: Hash, range, and round-robin strategies
- Actor-Aware Placement: Optimize data locality for actor relationships
Distributed Storage Features
- Data Partitioning: Automatic sharding across cluster nodes
- Replication: Multi-node data replication for fault tolerance
- Cross-Node Shuffling: Efficient data movement for distributed queries
- Quorum Writes: Ensure data consistency across replicas
- Consistency Management: Configurable consistency levels per operation
- Storage Backends: Multi-cloud support (S3, Azure, local filesystem)
Configuration and Deployment
- Containerized deployment with Docker support
- Kubernetes deployment with Helm charts
- Configuration via application properties
- Support for development with Tiltfile
- Multi-protocol server configuration (ports, authentication)
- Storage tier configuration (migration thresholds, retention policies)
- Iceberg catalog configuration (REST catalog, S3/Azure credentials)
- Cluster configuration (replication factor, consistency levels, partitioning)
- Transaction system configuration (timeouts, batch sizes, pool limits)
- Security configuration (authentication providers, token expiration)
- Metrics configuration (Prometheus endpoints, scrape intervals)
Performance Characteristics
Transaction System:
- 2PC coordination: ~5-10ms overhead per transaction
- Lock acquisition: <1ms in uncontended scenarios
- Deadlock detection: O(N) where N = number of waiting transactions
- Batch processing: Up to 10x throughput improvement for write-heavy workloads
Resource Usage:
- Connection pooling: Reduces connection overhead by 80-90%
- Memory management: Configurable limits prevent OOM scenarios
- Metrics: Minimal overhead (<1% CPU) for metric collection
Protocol Performance:
- RESP (Redis): Sub-millisecond latency for key-value operations
- PostgreSQL: Full protocol compliance with prepared statement caching
- REST API: Async request handling with WebSocket support for real-time updates
- Multi-protocol: Concurrent protocol handling with minimal overhead
Protocol Integration Benefits
The multi-protocol architecture provides several key advantages:
- Seamless Migration: Existing applications can connect using familiar protocols without code changes
- Production-Ready: Redis (RESP), PostgreSQL, MySQL, CQL, Cypher/Bolt, AQL, OrbitQL, REST API, gRPC
- Experimental: MCP (AI agent integration)
- Tool Compatibility: Standard database tools work out of the box
- redis-cli: Full compatibility with 50+ Redis commands
- psql: Complete PostgreSQL wire protocol support
- pgAdmin, DataGrip: Standard PostgreSQL clients supported
- MySQL clients: Full MySQL wire protocol support
- Neo4j clients: Complete Bolt v4.4 protocol with Cypher support
- Ecosystem Integration: Leverage existing drivers and libraries from various ecosystems
- Redis ecosystem: All Redis client libraries (redis-py, node-redis, etc.)
- PostgreSQL ecosystem: All PostgreSQL drivers (psycopg2, JDBC, etc.)
- Graph ecosystem: Neo4j drivers (Python, Java, .NET, JavaScript) and ArangoDB clients
- Flexible Access: Choose the protocol that best fits your use case
- SQL (PostgreSQL/OrbitQL): Complex queries, analytics, ACID transactions
- RESP (Redis): Caching, session storage, pub/sub messaging
- REST API: Web applications, microservices, API integration
- gRPC: High-performance inter-service communication
- MCP: AI agent integration and natural language queries
- Unified Backend: All protocols access the same distributed actor system and storage layer
- Consistent Data Model: All protocols operate on the same actor-based data
- Multi-Model Support: Graph, document, time-series, and relational data
- Distributed Architecture: Automatic load balancing and fault tolerance
- Transaction Support: ACID transactions across all protocols
- Production Readiness: Five protocols are production-ready with comprehensive testing
- High Test Coverage: Production protocols have extensive integration tests
- Client Compatibility: Validated with standard client tools
- Performance Optimized: Each protocol optimized for its specific use case
- Enterprise Features: Authentication, authorization, monitoring, and observability
This architecture provides a solid foundation for building distributed, fault-tolerant, and scalable applications using the virtual actor model with production-ready transaction support and comprehensive multi-protocol access.