๐พ Kawa Storage - High-Performance Event Storage Engine
kawa-storage is the core high-performance storage engine of the Kawa project. It implements Write-Ahead Log (WAL) and segmented persistence, along with event sourcing patterns.
๐ฏ Design Goals
- โก High Performance: 274K+ writes/sec, 1.2M+ reads/sec
- ๐ Consistency: Data integrity guarantee through CRC32 checksums
- ๐ Scalability: Efficient data management through segmentation
- ๐ก๏ธ Reliability: Fault tolerance and data recovery capabilities
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Kawa Storage Engine โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ค Public API โ
โ โโโ StorageEngine โ
โ โโโ append_event() / read_events() โ
โ โโโ get_latest_offset() โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ Write-Ahead Log (WAL) โ
โ โโโ Per-partition offset management โ
โ โโโ Automatic segment rotation โ
โ โโโ Asynchronous write & read โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ฆ Segment Management โ
โ โโโ Fixed-size segments (1GB default) โ
โ โโโ Memory-mapped I/O โ
โ โโโ CRC32 integrity checks โ
โ โโโ Concurrent access control โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ Event Management โ
โ โโโ EventId (UUID v4) โ
โ โโโ Event metadata โ
โ โโโ JSON & binary data support โ
โ โโโ Timestamp management โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Quick Start
Basic Usage
use ;
async
Performance Optimization
// Efficient writing of large data
for i in 0..10000
// Batch reading
let events = storage.read_events.await?;
๐ Performance Characteristics
Benchmark Results
| Operation | Performance | Conditions |
|---|---|---|
| Write | 274,816 events/sec | Release build, 1000 events |
| Read | 1,190,890 events/sec | Release build, 1000 events |
| Startup Time | < 100ms | Empty data directory |
| Memory Usage | < 50MB | Basic operations |
Scalability
- Maximum Segment Size: No limit (1GB recommended)
- Maximum Partitions: No limit
- Maximum Topics: No limit
- Concurrent Access: Fully supported
๐ง Configuration Options
use StorageConfig;
let config = StorageConfig ;
๐๏ธ Data Structures
Event
EventData
// Usage examples
let json_data = from_json;
let binary_data = from_bytes;
let text_data = from_text;
๐งช Testing
Run Tests
# Run all tests
# Integration tests
# Benchmarks
# Coverage
Test Configuration
- Unit Tests: Basic functionality of each module
- Integration Tests: End-to-end scenarios
- Benchmark Tests: Performance measurement
- Property Tests: Random data validation
๐ง Future Features
v0.2.0
- Compression Support: LZ4/Snappy compression
- Index Building: Fast search functionality
- Memory Pool: Allocation optimization
- Batch API: Bulk event processing
v0.3.0
- Replication: Multi-node support
- Encryption: Encryption at rest
- Schema Validation: Event structure validation
- Automatic Compaction: Old segment cleanup
โ ๏ธ Limitations
- Transactions: Currently not supported
- Delete Operations: Event deletion not supported
- Distributed Storage: Single node only
- Schema Evolution: Currently not supported
๐ Related Documentation
๐ Error Handling
use ;
match storage.append_event.await
kawa-storage - High-performance event storage implemented in Rust ๐