Architecture Overview
Understanding Solidis's internal structure and SOLID design principles.
System Architecture
Overview of how Solidis components work together to provide a robust Redis client
┌─────────────────────────────────────────────────┐
│ SolidisClient │
│ │
│ Creates & coordinates all components │
│ │
│ ┌────────────────────────────────────┐ │
│ │ Debug Memory │ │
│ └───────┬───────────────────┬────────┘ │
│ ▼ ▼ │
│ ┌────────────────┐ ┌────────────────┐ │
│ │ Connection │─►│ Requester │─┐ │
│ └────────────────┘ └────────────────┘ │ │
│ ┌────────────────┐ │ │
│ │ Parser │◄┤ │
│ └────────────────┘ │ │
│ ┌────────────────┐ │ │
│ │ PubSub │◄┘ │
│ └────────────────┘ │
│ │
└─────────────────────────────────────────────────┘
┌──────────────┴─────────────┐
▼ ▼
┌─────────────────┐ ┌───────────────────────┐
│ SolidisClient │ │ SolidisFeaturedClient │
│ (needs extend) │ │ (all commands) │
└─────────────────┘ └───────────────────────┘
Core Components
SolidisClient
Core entry point that creates and coordinates all components
Key Responsibilities:
- •Component initialization and lifecycle management
- •Configuration management
- •Event coordination between components
- •Extension system for custom commands
Connection
Manages TCP/TLS socket connections
Key Responsibilities:
- •Socket connection establishment
- •Automatic reconnection with exponential backoff
- •TLS/SSL support
- •Connection state management
- •Auto-recovery for database selection and subscriptions
Requester
Handles command pipelining and request states
Key Responsibilities:
- •Command queue management
- •Pipeline optimization
- •Request/response correlation
- •Command timeout handling
- •Transaction (MULTI/EXEC) coordination
Parser
Processes RESP2/RESP3 protocol with optimized buffer handling
Key Responsibilities:
- •RESP protocol parsing (RESP2 and RESP3)
- •Zero-copy buffer operations
- •Efficient memory management
- •Multi-byte character support
- •Binary-safe data handling
PubSub
Maintains subscription state for pub/sub functionality
Key Responsibilities:
- •Channel subscription management
- •Pattern subscription support
- •Message routing to event handlers
- •Subscription state recovery after reconnection
Debug Memory
Centralized debug logging system
Key Responsibilities:
- •Debug event collection
- •Circular buffer for memory efficiency
- •Debug event filtering
- •Performance metrics tracking
SOLID Principles in Action
Solidis is built following SOLID design principles, ensuring maintainability, testability, and extensibility.
SSingle Responsibility
Each component has a single, well-defined responsibility
Example: Parser only handles RESP protocol parsing, not connection management
OOpen/Closed
Open for extension, closed for modification via the extension system
Example: Add custom commands without modifying core client code
LLiskov Substitution
Components can be replaced with alternative implementations
Example: Different parser implementations for RESP2 vs RESP3
IInterface Segregation
Minimal, focused interfaces between components
Example: PubSub exposes only subscription-related methods
DDependency Inversion
Components depend on abstractions, not concrete implementations
Example: Client depends on parser interface, not specific parser implementation
Command Execution Flow
How commands flow through the Solidis architecture
1
Client receives command
User calls a command method (e.g.,
client.set('key', 'value'))2
Requester queues command
Command is added to the pipeline queue for batch processing
3
Connection sends data
Command is serialized to RESP protocol and sent through the TCP socket
4
Parser processes response
Parser reads and parses RESP response from Redis using zero-copy operations
5
Requester resolves promise
Parsed response is matched to the original command and the promise is resolved
6
Result returned to user
The parsed result is returned to the user's await statement
Performance Optimizations
Key architectural decisions that make Solidis fast
Zero-Copy Operations
The parser uses buffer slicing instead of copying data, reducing memory allocations and improving throughput for large payloads.
Pipeline Batching
Commands are automatically batched in pipelines to reduce network round trips, configurable via maxCommandsPerPipeline.
Efficient Buffer Management
Smart buffer allocation and reuse strategies minimize garbage collection pressure and memory overhead.
Lazy Connections
Optional lazy connection mode delays connection establishment until needed, reducing resource usage for idle clients.
