Architecting Reliable Data Systems with the World’s Most Deployed Database
Introduction: Why SQLite in Production?
- The Scale You Already Know
- When SQLite Is the Right Choice (and When It Is Not)
- What This Book Will Teach You
- How to Read This Book
Chapter 1: First Principles: Architecture and Design Philosophy
- The Single-Process Server Model
- File-Based Storage and ACID Guarantees
- WAL vs Journaling Modes: Core Trade-offs
- Write-Ahead Logging in Depth
- The SQLite Process Lifecycle
- Thread Safety and Serialization Modes
Chapter 2: Storage Engine Internals
- Page Structure and File Format
- B-Tree Implementation Details
- Record Format and Varints
- The Database File Header
- Free Pages and Vacuums
- Overflow Pages and Large Objects
- WITHOUT ROWID Tables: Index-Organized Storage
- Page Cache Architecture: PCache1
Chapter 3: Concurrency, Locking, and Transactions
- Shared and Exclusive Locks
- The Locking Protocol Step by Step
- Write Conflicts and Busy Handlers
- Savepoints and Nested Transactions
- Deadlock Avoidance Patterns
- Connection Pooling Strategies for SQLite
Chapter 4: Indexing and Query Optimization
- B-Tree Index Anatomy
- Covering Indexes and Index-Only Scans
- The Query Planner and EXPLAIN
- Composite Indexes and Column Ordering
- Partial Indexes and Generated Columns
- When NOT to Index
- Advanced EXPLAIN QUERY PLAN Analysis
Chapter 5: Advanced Schema Design
- Foreign Keys and Referential Integrity
- Generated (Computed) Columns
- Triggers for Business Logic
- Virtual Tables: The fts5 Extension
- Virtual Tables: The json1 Extension
- Using Custom Collations and Functions
Chapter 6: JSON, Full-Text Search, and Modern Data Types
- Native JSON Storage and Indexing
- JSON Functions and Operators
- FTS5 Full-Text Search Engine
- Combining JSON and FTS5 in Production
- Alternatives to Document Stores
Chapter 7: Performance Tuning and Benchmarking
- Critical Pragmas for Production
- Synchronous Modes and Durability Trade-offs
- Cache Size and Memory Management
- Batch Inserts and Bulk Operations
- Benchmarking Methodologies That Work
- Profiling Slow Queries in Production
- Observability: Metrics, Tracing, and Alerting
Chapter 8: Backup, Recovery, and High Availability
- Online Backup API and Tools
- Filesystem-Level Backups with WAL
- Point-in-Time Recovery Strategies
- Replication Architectures (litestream, rqlite)
- Disaster Recovery Runbooks
- Testing Your Backup Strategy
Chapter 9: Security and Hardening
- Filesystem Permissions and Ownership
- SQL Injection Prevention Patterns
- SQLite Encryption Extensions (SEE) and Alternatives
- Sandboxing with PRAGMA
- Secure Configuration Checklists
- Auditing and Logging Strategies
Chapter 10: Containerized and Cloud Deployments
- SQLite in Docker Containers
- Ephemeral Storage and Persistence Patterns
- Serverless and Edge Runtime Integration
- Cloud Filesystems (EFS, NFS) and SQLite
- Shared Nothing vs Shared Disk Architectures
- Cold Start Optimization Strategies
Chapter 11: Integrations and Ecosystem
- Language Bindings and Driver Patterns
- ORM Integration (SQLAlchemy, Prisma, GORM)
- Migration Strategies and Tools
- The sqlite-utils Ecosystem
- Building Custom Extensions in C
- Real-Time Change Feeds with Triggers
Chapter 12: Production Case Studies and Architecture Patterns
- Mobile-First Architectures (React Native, Flutter)
- Serverless Backend Patterns (Vercel, Cloudflare Workers)
- Edge Computing and Offline-First Design
- SQLite as a Message Queue or Event Store
- Hybrid Architectures with Client-Server Sync
- Lessons from Production Incidents
Conclusion: The Future of SQLite in Production
- Where SQLite Is Winning (and Losing)
- Emerging Patterns and Tooling
- The Next Five Years
- Final Recommendations