Docs

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

OptionTypeDefaultDescription
max_concurrent_streamsdata_directoryenvironmentString"development"Deployment environment (development, production, test)
hostString"127.0.0.1"Bind address for the server
db_portu1643121Port for the database protocol
webui_portu1643120Port for the web UI
max_connectionsusize10000Maximum concurrent client connections
broadcast_capacityusize4096Capacity of the real-time broadcast channel

Storage Configuration

OptionTypeDefaultDescription
data_directoryString"./data"Directory for storing database files
max_segment_size_mbusize10Maximum size of segment files before rollover
sync_modeString"always"Durability mode: "always", "interval", or "never"
sync_interval_msu64100Sync interval when using interval mode (milliseconds)

Limits Configuration

OptionTypeDefaultDescription
max_concurrent_streamsusize32Maximum number of concurrent data streams
max_open_file_descriptorsusize64File descriptor cache size for segment files
max_index_ram_mbusizeautoRAM budget for in-memory index (auto-detected by default)
max_segment_size_mbusize16Maximum segment file size in the limits section
max_scan_resultsusize100000Maximum records returned from full scan operations

Security Configuration

OptionTypeDefaultDescription
modeStringautoSecurity mode: "auth_key", "none", or auto-detected
auth_key.system_streamString"auth_keys"Stream name for storing authentication keys
auth_key.allow_local_auto_generationbooltrueAllow automatic key generation in development
master_keyStringauto-generatedMaster 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 = 43121
webui_port = 43120
max_connections = 10000
broadcast_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 = 32
max_open_file_descriptors = 64
max_index_ram_mb = 256
max_segment_size_mb = 16
max_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 resources
max_concurrent_streams = 16
max_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 = 64
max_open_file_descriptors = 128
max_index_ram_mb = 512 # Explicit override for production
max_scan_results = 500000

Edge/Embedded Profile

Resource-constrained environments like IoT devices:

[limits]
max_concurrent_streams = 8
max_open_file_descriptors = 16
max_index_ram_mb = 32 # Override auto-detect for small devices
max_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_mb setting

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
Note: Configuration changes typically require a server restart to take effect. Always test configuration changes in a development environment before applying to production.