Configuration
Configure LivenDB for optimal performance and security in your deployment environment.
LivenDB provides flexible configuration options to adapt to different deployment scenarios, from development environments to production servers. Configuration can be specified through configuration files, environment variables, or programmatically when using the embedded API.
Configuration Structure
LivenDB configuration is organized into several sections:
- Server Configuration — Network and connection settings
- Storage Configuration — Data directory and persistence settings
- Limits Configuration — Resource and performance limits
- Security Configuration — Authentication and encryption settings
Server Configuration
| Option | Type | Default | Description |
|---|---|---|---|
max_concurrent_streamsdata_directoryenvironment | String | "development" | Deployment environment (development, production, test) |
host | String | "127.0.0.1" | Bind address for the server |
db_port | u16 | 43121 | Port for the database protocol |
webui_port | u16 | 43120 | Port for the web UI |
max_connections | usize | 10000 | Maximum concurrent client connections |
broadcast_capacity | usize | 4096 | Capacity of the real-time broadcast channel |
Storage Configuration
| Option | Type | Default | Description |
|---|---|---|---|
data_directory | String | "./data" | Directory for storing database files |
max_segment_size_mb | usize | 10 | Maximum size of segment files before rollover |
sync_mode | String | "always" | Durability mode: "always", "interval", or "never" |
sync_interval_ms | u64 | 100 | Sync interval when using interval mode (milliseconds) |
Limits Configuration
| Option | Type | Default | Description |
|---|---|---|---|
max_concurrent_streams | usize | 32 | Maximum number of concurrent data streams |
max_open_file_descriptors | usize | 64 | File descriptor cache size for segment files |
max_index_ram_mb | usize | auto | RAM budget for in-memory index (auto-detected by default) |
max_segment_size_mb | usize | 16 | Maximum segment file size in the limits section |
max_scan_results | usize | 100000 | Maximum records returned from full scan operations |
Security Configuration
| Option | Type | Default | Description |
|---|---|---|---|
mode | String | auto | Security mode: "auth_key", "none", or auto-detected |
auth_key.system_stream | String | "auth_keys" | Stream name for storing authentication keys |
auth_key.allow_local_auto_generation | bool | true | Allow automatic key generation in development |
master_key | String | auto-generated | Master encryption key (auto-generated if not provided) |
Example Configuration File
Here's a complete example configuration file with common settings:
[server]environment = "production"host = "0.0.0.0"db_port = 43121webui_port = 43120max_connections = 10000broadcast_capacity = 4096[security]mode = "auth_key"[security.auth_key]system_stream = "auth_keys"allow_local_auto_generation = false[storage]data_directory = "/var/lib/liven"max_segment_size_mb = 16[limits]max_concurrent_streams = 32max_open_file_descriptors = 64max_index_ram_mb = 256max_segment_size_mb = 16max_scan_results = 100000
Configuration Profiles
Development Profile
Optimized for local development with relaxed security and auto-detection:
[server]environment = "development"host = "127.0.0.1"[security]mode = "none" # Auto-disabled for development[limits]# Auto-detect index RAM based on system resourcesmax_concurrent_streams = 16max_open_file_descriptors = 32
Production Profile
Secure configuration for production deployments:
[server]environment = "production"host = "0.0.0.0"[security]mode = "auth_key"[security.auth_key]allow_local_auto_generation = false[limits]max_concurrent_streams = 64max_open_file_descriptors = 128max_index_ram_mb = 512 # Explicit override for productionmax_scan_results = 500000
Edge/Embedded Profile
Resource-constrained environments like IoT devices:
[limits]max_concurrent_streams = 8max_open_file_descriptors = 16max_index_ram_mb = 32 # Override auto-detect for small devicesmax_scan_results = 10000
Environment-Specific Configuration
LivenDB automatically adjusts security settings based on the environment:
- Development/Test — Authentication automatically disabled for easier local development
- Production — Authentication automatically enabled with secure defaults
- Custom — Explicit configuration overrides auto-detection
Index RAM Auto-Detection
LivenDB automatically detects system RAM and allocates an appropriate index budget:
- Auto-allocates 25% of system RAM (maximum 4GB)
- Formula: ~84 bytes per unique key
- Examples: 16MB ≈ 190K keys, 256MB ≈ 3M keys, 1GB ≈ 12M keys
- Override with explicit
max_index_ram_mbsetting
Best Practices
Security
- Use environment variables for secrets — Set
LIVEN_SECURITY_MASTER_KEYinstead of storing in configuration files - Disable auto-generation in production — Set
allow_local_auto_generation = false - Use secure file permissions — Ensure configuration and key files have restricted access
Performance
- Monitor index RAM usage — Use
status()query to track utilization - Adjust segment sizes — Larger segments reduce I/O overhead for high-write workloads
- Tune file descriptor cache — Increase for workloads with many concurrent streams
Production
- Explicit configuration — Avoid relying on auto-detection for critical settings
- Regular backups — Implement backup procedures for the data directory
- Monitor metrics — Track connection counts, memory usage, and query performance