Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

sierradb

> 编程语言
Open source

SierraDB: The immutable database for events

328 stars0 likes0 views
WebsiteGitHub

About

SierraDB: The immutable database for events

SierraDB

A high-performance, distributed event store designed for scalable event sourcing applications

SierraDB is a modern, horizontally-scalable database specifically built for event sourcing workloads. It combines the simplicity of Redis protocol compatibility with the distributed architecture principles of Cassandra/ScyllaDB, providing developers with a powerful foundation for building event-driven systems.

Learn More

Want to understand how SierraDB works under the hood? Read the detailed blog post: Building SierraDB: A Distributed Event Store Built in Rust

The post covers the architecture decisions, watermark system for consistency, distributed consensus, and the journey of building an event store from scratch.

Try it in 30 seconds

Get SierraDB running with Docker and start storing events immediately:

…

That's it! You're now running a distributed event store and can append/read events using any Redis client.

Quick Start

Using Docker (Recommended)

bash
# Run with persistent data
docker run -p 9090:9090 -v ./data:/app/data tqwewe/sierradb

Install with Cargo

bash
cargo install sierradb-server
sierradb --dir ./data --client-address 0.0.0.0:9090

Basic Event Operations

bash
# Connect with any Redis client
redis-cli -p 9090

# Append events to streams
EAPPEND order-456 OrderCreated EXPECTED_VERSION empty PAYLOAD '{"total":99.99,"items":["laptop"]}'

# Read events back
ESCAN orders - + COUNT 100

# Subscribe to real-time events
ESUB orders FROM LATEST

Using with Redis Clients

Since SierraDB uses the RESP3 protocol, you can also connect with any Redis-compatible client:

python
import redis

# Connect to SierraDB
client = redis.Redis(host='localhost', port=9090, protocol=3)

# Append an event (use 'empty' for new streams, or a version number for existing ones)
result = client.execute_command('EAPPEND', 'user-123', 'UserCreated',
                               'EXPECTED_VERSION', 'empty',
                               'PAYLOAD', '{"name":"John","email":"[email protected]"}')

# Read events from stream
events = client.execute_command('ESCAN', 'user-123', '-', '+', 'COUNT', '100')

Key Features

  • Redis Protocol Compatible - Uses RESP3 protocol, making it compatible with existing Redis clients and tools
  • Horizontally Scalable - Distributed architecture that scales across multiple nodes with configurable replication
  • High Performance - Optimized for event sourcing with consistent write performance regardless of database size
  • Real-time Subscriptions - Seamless transition from historical events to live streaming for projections and event handlers
  • Event Sourcing Optimized - Purpose-built for append-only event patterns with strong ordering guarantees
  • Data Integrity - CRC32C checksums ensure corruption detection with automatic recovery capabilities
  • Actively Developed - Under active development with extensive testing and stability improvements

Architecture Overview

SierraDB organizes data using a three-tier hierarchy designed for optimal performance and scalability:

Buckets and Partitions

  • Default Configuration: 4 buckets containing 32 partitions (8 partitions per bucket)
  • Scalability: Can be scaled up across many nodes for virtually unlimited horizontal performance
  • Distribution: Events are distributed across partitions using consistent hashing of partition keys

Segmented Storage

  • Segment Files: Events are written to segment files that are sealed at 256MB (configurable)
  • Consistent Performance: New segments ensure write performance remains constant regardless of database size
  • Parallel Processing: Writes within a partition are sequential, but parallel across different partitions

Event Ordering Guarantees

  • Partition Sequences: Gapless monotonic sequence numbers within each partition
  • Stream Versions: Gapless monotonic version numbers within each stream
  • Consistency: Events within the same partition maintain strict ordering while allowing parallelism across partitions

Performance Characteristics

SierraDB is optimized for three primary read patterns:

  1. Event Lookup by ID - Fast UUID-based event retrieval using event indexes
  2. Stream Scanning - Efficient sequential reading of events within a stream using stream indexes
  3. Partition Scanning - High-throughput scanning of events within a partition using partition indexes

Each segment file is accompanied by specialized index files and bloom filters for maximum query performance.

Distributed Architecture

SierraDB operates as a distributed cluster similar to Cassandra/ScyllaDB:

  • Cluster Coordination - Automatic node discovery and coordination using libp2p and optional mDNS
  • Replication Factor - Configurable data replication (defaults to min(node_count, 3))
  • Fault Tolerance - Automatic failover and data recovery across cluster nodes
  • Consistent Hashing - Automatic data distribution and rebalancing

Real-time Subscriptions

One of SierraDB's most powerful features is its subscription system, designed specifically for event sourcing projections:

  • Historical + Live: Subscriptions start from any point in history and automatically transition to live events
  • Guaranteed Delivery: Events are delivered in order with acknowledgment tracking
  • Multiple Stream Types: Subscribe to individual streams, partitions, or combinations
  • Backpressure Handling: Configurable windowing prevents overwhelmed consumers

Perfect for building:

  • Event sourcing projections that need to catch up from the beginning
  • Real-time event handlers that process new events as they arrive
  • Read models that require both historical rebuild and live updates

Configuration

SierraDB offers extensive configuration options. Key settings include:

…

See crates/sierradb-server/src/config.rs for the complete configuration reference.

Supported Operations

SierraDB implements a comprehensive set of RESP3 commands for event operations:

Core Event Operations

EAPPEND - Append Event to Stream

Append an event to a stream with expected version control.

Note: By default, EXPECTED_VERSION must be empty (for new streams) or a specific version number. To allow any or exists, set append.strict_versioning = false in your configuration.

Syntax:

EAPPEND   [EVENT_ID ] [PARTITION_KEY ] [EXPECTED_VERSION ] [TIMESTAMP ] [PAYLOAD ] [METADATA ]

Parameters:

  • stream_id - Stream identifier to append the event to
  • event_name - Name/type of the event
  • event_id (optional) - UUID for the event (auto-generated if not provided)
  • partition_key (optional) - UUID to determine event partitioning
  • expected_version - Expected stream version (empty for new streams, or version number)
  • timestamp (optional) - Event timestamp in milliseconds
  • payload (optional) - Event payload data
  • metadata (optional) - Event metadata

Examples:

EAPPEND my-stream UserCreated EXPECTED_VERSION empty PAYLOAD '{"name":"john"}' METADATA '{"source":"api"}'
EAPPEND orders OrderPlaced EXPECTED_VERSION 5 PAYLOAD '{"order_id":"12345"}'

EMAPPEND - Multi-Stream Transactional Append

Append multiple events across different streams within the same partition atomically.

Syntax:

EMAPPEND    [EVENT_ID ] [EXPECTED_VERSION ] [TIMESTAMP ] [PAYLOAD ] [METADATA ] [  ...]

Parameters:

  • partition_key - UUID that determines which partition all events will be written to
  • For each event: stream_id, event_name, and optional EVENT_ID, EXPECTED_VERSION, TIMESTAMP, PAYLOAD, METADATA

Examples:

EMAPPEND 550e8400-e29b-41d4-a716-446655440000 stream1 EventA EXPECTED_VERSION empty PAYLOAD '{"data":"value1"}' stream2 EventB EXPECTED_VERSION 3 PAYLOAD '{"data":"value2"}'

Note: All events succeed or fail together as a single atomic transaction.

EGET - Get Event by ID

Retrieve an event by its unique identifier.

Syntax:

EGET 

Parameters:

  • event_id - UUID of the event to retrieve

Examples:

EGET 550e8400-e29b-41d4-a716-446655440000

ESCAN - Scan Stream Events

Scan events in a stream by version range.

Syntax:

ESCAN    [PARTITION_KEY ] [COUNT ]

Parameters:

  • stream_id - Stream identifier to scan
  • start_version - Starting version number (use "-" for beginning)
  • end_version - Ending version number (use "+" for end, or specific number)
  • partition_key (optional) - UUID to scan specific partition
  • count (optional) - Maximum number of events to return

Examples:

ESCAN my-stream 0 100 COUNT 50
ESCAN my-stream - + PARTITION_KEY 550e8400-e29b-41d4-a716-446655440000

Stream Operations

ESVER - Get Stream Version

Get the current version number for a stream.

Syntax:

ESVER  [PARTITION_KEY ]

Parameters:

  • stream_id - Stream identifier to get version for
  • partition_key (optional) - UUID to check specific partition

Examples:

ESVER my-stream
ESVER my-stream PARTITION_KEY 550e8400-e29b-41d4-a716-446655440000

ESUB - Subscribe to Stream Events

Subscribe to events from one or more streams with real-time delivery.

Syntax:

# Single stream
ESUB  [PARTITION_KEY ] [FROM ] [WINDOW ]

# Multiple streams  
ESUB  [PARTITION_KEY ]  [PARTITION_KEY ] ... [FROM LATEST | FROM  | FROM MAP =...] [WINDOW ]

Parameters:

  • stream_id - Stream identifier(s) to subscribe to
  • partition_key (optional) - UUID for specific partition
  • FROM (optional) - Starting position (LATEST, version number, or MAP for per-stream positions)
  • WINDOW (optional) - Maximum number of unacknowledged events

Examples:

ESUB user-123                                         # Single stream, latest, no window
ESUB user-123 WINDOW 100                              # Single stream, latest, window 100  
ESUB user-123 FROM 50 WINDOW 100                      # Single stream, from version 50
ESUB user-1 user-2 user-3 FROM MAP user-1=10 user-2=20 user-3=30 WINDOW 50

Note: Establishes a persistent connection for real-time event delivery.

Partition Operations

EPSCAN - Scan Partition Events

Scan events in a partition by sequence number range.

Syntax:

EPSCAN    [COUNT ]

Parameters:

  • partition - Partition selector (partition ID 0-65535 or UUID key)
  • start_sequence - Starting sequence number (use "-" for beginning)
  • end_sequence - Ending sequence number (use "+" for end, or specific number)
  • count (optional) - Maximum number of events to return

Examples:

EPSCAN 42 100 200 COUNT 50
EPSCAN 550e8400-e29b-41d4-a716-446655440000 - + COUNT 100

EPSEQ - Get Partition Sequence

Get the current sequence number for a partition.

Syntax:

EPSEQ 

Parameters:

  • partition - Partition selector (partition ID 0-65535 or UUID key)

Examples:

EPSEQ 42
EPSEQ 550e8400-e29b-41d4-a716-446655440000

EPSUB - Subscribe to Partition Events

Subscribe to events from one or more partitions with real-time delivery.

Syntax:

# All partitions
EPSUB * [FROM LATEST | FROM  | FROM MAP = =... [DEFAULT ]] [WINDOW ]

# Single partition
EPSUB  [FROM ] [WINDOW ]

# Multiple partitions
EPSUB ,, [FROM LATEST | FROM  | FROM MAP = =... [DEFAULT ]] [WINDOW ]

Parameters:

  • partition_id - Partition identifier(s) (* for all, comma-separated list for multiple)
  • FROM (optional) - Starting position (LATEST, sequence number, or MAP for per-partition positions)
  • WINDOW (optional) - Maximum number of unacknowledged events

Examples:

EPSUB *                                               # All partitions, latest
EPSUB * WINDOW 100                                    # All partitions, latest, window 100
EPSUB * FROM 1000 WINDOW 100

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言