The Definitive Guide to Building High-Performance Embedded Storage Systems
Introduction
Chapter 1: What Is RocksDB and Why It Matters
- The Key-Value Store That Powers Modern Infrastructure
- From LevelDB to RocksDB: A History of Evolution
- LSM-Trees: The Core Innovation Behind Performance
- Where RocksDB Lives Today: Ecosystem and Adoption
- When to Choose RocksDB (and When Not To)
Chapter 2: Getting Started with RocksDB
- Building and Installing RocksDB from Source
- Your First Database: Opening, Writing, Reading, Closing
- Understanding the Basic C++ API Surface
- Integrating RocksDB into Modern C++ Projects
- Quick Start with Alternative Language Bindings
Chapter 3: Core Architecture and Data Flow
- The Write Path: From Application Call to Disk
- MemTables and Immutable MemTables
- SST Files and the Level Hierarchy
- The Read Path: Lookup, Bloom Filters, and Caching
- Write-Ahead Log and Crash Recovery
Chapter 4: Data Models and Column Families
- Keys, Values, and Encoding Strategies
- Column Families: Isolation, Configuration, and Use Cases
- Designing Key Spaces for Performance
- Prefixes, Ranges, and Secondary Index Patterns
- Versioning and Multi-Tenancy with Column Families
Chapter 5: Advanced Write Operations
- Write Batches: Atomicity and Performance
- Merge Operators: Semantics and Implementation
- Conditional Writes and Compare-and-Swap Patterns
- Single-Delete vs Delete: Handling Tombstones Correctly
- Optimizing Write Throughput in Production Workloads
Chapter 6: Reading Data: Iterators, Snapshots, and Transactions
- Point Lookups and Read Options
- Iterators: Range Scans, Prefix Seeks, and Performance
- Snapshots: Consistent Views Without Locking
- Optimistic Transactions in RocksDB
- Isolation Levels and Concurrency Semantics
Chapter 7: Compaction: The Heart of RocksDB
- Why Compaction Exists: Trade-offs Explained
- Level-Based Compaction (LEVEL)
- Universal Compaction: FIFO, Size-Tiered, and Windowed
- FIFO Compaction for Log-Like Workloads
- Choosing and Tuning Compaction for Your Workload
Chapter 8: Memory Management and Caching
- The Cache Hierarchy: Block Cache, Table Cache, and More
- MemTable Memory Budgeting and Auto-Tuning
- Shared vs Per-Instance Caches
- Subcompaction and Parallelism Controls
- Diagnosing and Fixing Memory Pressure Issues
Chapter 9: Compression, Bloom Filters, and SST File Format
- The SST File Format: Anatomy of a Table
- Compression Algorithms: Choosing the Right One
- Bloom Filters: Standard, Partitioned, and Full
- Prefix Bloom Filters for Range Queries
- Tuning Block Size and Filter Policies Together
Chapter 10: Configuration and Options Reference
- DatabaseOptions: Global Configuration
- ColumnFamilyOptions: Per-Column Tuning
- Env and IO Control: Managing System Resources
- Runtime Options vs Build-Time Options
- A Practical Configuration Checklist for Production
Chapter 11: Performance Tuning and Benchmarking
- Understanding RocksDB Benchmarks and Metrics
- Using the Built-in rocksdbtool and ldb Utilities
- Profiling Hot Paths: CPU, IO, and Lock Contention
- Tuning for Read-Heavy Workloads
- Tuning for Write-Heavy and Mixed Workloads
Chapter 12: Monitoring, Debugging, and Operations
- Runtime Stats, Histograms, and Property API
- Integrating with Prometheus and Grafana
- Reading and Interpreting ROCKSDB_LOG_LEVEL Output
- Debugging Slow Queries and Stalls
- Handling Corruption: Detection and Recovery
Chapter 13: Backup, Restore, and Checkpoints
- Full Backups with BackupEngine
- Incremental Backups and Log Shipping Patterns
- Checkpoints for Instant Snapshots and Migration
- Point-in-Time Recovery Strategies
- Cross-Machine Restore and Version Compatibility
Chapter 14: Concurrency, Replication, and Distributed Patterns
- Concurrent Access Patterns and Thread Safety
- Using Multiple Instances Safely on One Machine
- Replication Patterns Built on Top of RocksDB
- Integrating with Raft, Paxos, and Distributed Consensus
- RocksDB in Microservices and Cloud-Native Architectures
Chapter 15: Real-World Production Use Cases
- Time-Series Data and Metrics Storage
- Blockchain and Ledger Systems
- Caching Layers and Edge Databases
- IoT Device Storage and Embedded Analytics
- Lessons Learned from Production Deployments
Chapter 16: Comparisons, Alternatives, and Migration
- RocksDB vs LevelDB: What Changed and Why It Matters
- RocksDB vs WiredTiger: MongoDB’s Choice
- RocksDB vs SQLite: Different Problems, Different Tools
- RocksDB in the LSM Family: Cassandra, ScyllaDB, Badger
- Migrating to RocksDB: Strategies and Pitfalls
Chapter 17: Security, Limitations, and Future Directions
- Security Considerations: Encryption, Access Control, Sandboxing
- Known Limitations and Anti-Patterns to Avoid
- The RocksDB Roadmap and Upcoming Features
- When to Look Beyond RocksDB
- Final Recommendations for Production Systems