Keydb.cfg
For production, bind to specific internal IPs, enable keepalive, and set a reasonable timeout. 4. Threading Model (KeyDB-Specific) This is the core differentiator from Redis.
These settings balance memory vs. CPU. Larger values = less memory but slower access. | Directive | Default | Description | |-----------|---------|-------------| | tls-port | 0 | TLS port (enable by setting >0). | | tls-cert-file | (none) | Server certificate. | | tls-key-file | (none) | Private key. | | tls-ca-cert-file | (none) | CA certificate for client auth. | | tls-auth-clients | yes | Require client certificates. | | tls-protocols | "TLSv1.2 TLSv1.3" | Allowed protocols. | | tls-ciphers | (default) | Cipher suite. | 16. Sample Production Configuration # Network bind 10.0.0.10 port 6379 tcp-keepalive 300 timeout 300 Threading (16-core machine) server-threads 8 server-thread-affinity 0-7 io-threads 4 Security requirepass your_strong_password rename-command FLUSHALL "" rename-command FLUSHDB "" Persistence save 900 1 save 300 10 appendonly yes appendfsync everysec auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 128mb Memory maxmemory 8gb maxmemory-policy allkeys-lru maxmemory-samples 10 Replication (replica) replicaof 10.0.0.11 6379 masterauth your_strong_password Misc daemonize yes loglevel notice logfile /var/log/keydb/keydb.log slowlog-log-slower-than 10000 17. Common Misconfigurations & Pitfalls | Issue | Symptom | Fix | |-------|---------|-----| | bind 127.0.0.1 in Docker | Containers can’t connect | Bind to 0.0.0.0 or use --network host . | | protected-mode yes + no password + public IP | Remote connections rejected | Set requirepass or bind to internal IP. | | server-threads > cores | Context switching overhead | Set ≤ physical cores. | | maxmemory not set | OOM killer may kill KeyDB | Always set maxmemory . | | appendfsync always | Poor write performance | Use everysec unless absolutely necessary. | | replicaof with active-replica | Data inconsistency | Understand conflict resolution first. | 18. Monitoring & Validation Commands After configuring keydb.cfg , use: keydb.cfg
Do not use rename-command to obfuscate commands — use ACLs. Always set a requirepass in production. 8. Memory Management | Directive | Default | Description | |-----------|---------|-------------| | maxmemory | 0 | Max memory in bytes. 0 = unlimited. | | maxmemory-policy | noeviction | Eviction policy: volatile-lru , allkeys-lru , volatile-random , allkeys-random , volatile-ttl , noeviction . | | maxmemory-samples | 5 | Number of keys to sample for LRU/TTL. | | active-defrag | no | Enable online defragmentation. | | active-defrag-threshold-lower | 10 | Fragmentation % to start. | | active-defrag-threshold-upper | 100 | Fragmentation % to force. | | active-defrag-cycle-min | 5 | Minimum CPU % for defrag. | | active-defrag-cycle-max | 75 | Maximum CPU % for defrag. | For production, bind to specific internal IPs, enable
Use both RDB (for backups) and AOF (for durability). Set appendfsync everysec for balance. 7. Security Directives | Directive | Default | Description | |-----------|---------|-------------| | requirepass | (empty) | Password for AUTH command. | | masterauth | (empty) | Password for replica → master auth. | | rename-command | (none) | Disable or rename dangerous commands (e.g., FLUSHALL ). | | aclfile | (none) | External ACL configuration file (KeyDB 6+). | These settings balance memory vs