# Redis Configuration for Trackeep # # This configuration is optimized for a self-hosted productivity application # with moderate concurrent user load (< 1000 users). # ============================================================================= # NETWORK # ============================================================================= # Accept connections on all interfaces (safe when behind Docker network) bind 0.0.0.0 # Default port port 6379 # TCP listen() backlog # Increase if Redis is slow to accept connections under high load tcp-backlog 511 # Unix socket (alternative to TCP, not used in Docker) # unixsocket /tmp/redis.sock # unixsocketperm 700 # Close connection after N seconds of idle time (0 = disabled) timeout 0 # TCP keepalive # Useful for detecting dead peers tcp-keepalive 300 # ============================================================================= # SECURITY # ============================================================================= # Require password for connections # Set via environment variable: requirepass ${REDIS_PASSWORD} # requirepass changeme # ACL configuration (Redis 6+) # user default on >password ~* &* +@all # Disable dangerous commands in production rename-command FLUSHDB "" rename-command FLUSHALL "" rename-command CONFIG "CONFIG_9f8a2b3c" rename-command DEBUG "" rename-command SHUTDOWN "SHUTDOWN_7d4e1f9a" # ============================================================================= # MEMORY MANAGEMENT # ============================================================================= # Maximum memory limit (256MB suitable for small-medium deployments) # Adjust based on available RAM and usage patterns maxmemory 256mb # Eviction policy when maxmemory is reached # allkeys-lru: Remove less recently used keys first (recommended for caching) # volatile-lru: Remove less recently used keys with expire set # allkeys-random: Random key removal # volatile-random: Random key removal from expired set # allkeys-lfu: Remove least frequently used keys # volatile-lfu: Remove least frequently used keys with expire set # volatile-ttl: Remove keys with shortest TTL # noeviction: Return errors on write operations maxmemory-policy allkeys-lru # Samples for LRU/LFU eviction # Higher = more accurate but slower maxmemory-samples 5 # Replica ignore maxmemory (don't evict on replicas) replica-ignore-maxmemory yes # ============================================================================= # PERSISTENCE (RDB) # ============================================================================= # Save to disk after N seconds if at least M keys changed # Save every 15 minutes if at least 1 key changed save 900 1 # Save every 5 minutes if at least 10 keys changed save 300 10 # Save every minute if at least 10000 keys changed save 60 10000 # Stop writes if RDB save fails stop-writes-on-bgsave-error yes # Compress RDB files rdbcompression yes # Checksum RDB files rdbchecksum yes # RDB file name dbfilename dump.rdb # Working directory for RDB/AOF dir /data # ============================================================================= # PERSISTENCE (AOF) # ============================================================================= # Enable AOF persistence (recommended for session durability) appendonly yes # AOF file name appendfilename "appendonly.aof" # Sync strategy: # always: Sync every write (safest, slowest) # everysec: Sync once per second (recommended balance) # no: Let OS decide when to sync (fastest, less safe) appendfsync everysec # Don't fsync if a bg save is in progress no-appendfsync-on-rewrite no # Auto-rewrite AOF when it grows by X% auto-aof-rewrite-percentage 100 # Minimum size before auto-rewrite auto-aof-rewrite-min-size 64mb # Load truncated AOF on startup aof-load-truncated yes # Use RDB preamble in AOF for faster rewrites aof-use-rdb-preamble yes # ============================================================================= # REPLICATION (for future Sentinel/Cluster setup) # ============================================================================= # Replica of another Redis instance # replicaof # Master authentication # masterauth # Replica read-only (default yes) replica-read-only yes # Diskless replication repl-diskless-sync no repl-diskless-sync-delay 5 # Replica priority (lower = preferred for failover) replica-priority 100 # ============================================================================= # CLIENTS # ============================================================================= # Maximum number of client connections # Increase if you have many concurrent users maxclients 10000 # ============================================================================= # PERFORMANCE TUNING # ============================================================================= # Number of databases (default 16) databases 16 # Disable THP (Transparent Huge Pages) # This should be done at OS level, but Redis warns about it # Latency monitoring latency-monitor-threshold 100 # Slow log (log queries taking > N microseconds) slowlog-log-slower-than 10000 # Slow log max length slowlog-max-len 128 # Event notification (for cache invalidation patterns) # Enable keyspace notifications for specific events notify-keyspace-events Ex # ============================================================================= # LOGGING # ============================================================================= # Log level: debug, verbose, notice, warning loglevel notice # Log file (empty = stdout, good for Docker) logfile "" # Syslog (disabled for Docker) # syslog-enabled no # ============================================================================= # LAZY FREEING # ============================================================================= # Use lazy freeing for better performance lazyfree-lazy-eviction yes lazyfree-lazy-expire yes lazyfree-lazy-server-del yes replica-lazy-flush yes # ============================================================================= # KERNEL OOM CONTROL # ============================================================================= # Control OOM killer behavior oom-score-adj no oom-score-adj-values 0 200 800 # ============================================================================= # I/O THREADING (Redis 6+) # ============================================================================= # Enable I/O threads for better multi-core utilization # Only useful with very high load # io-threads 4 # io-threads-do-reads yes # ============================================================================= # APPEND ONLY (Docker-specific) # ============================================================================= # Disable THP warning in container environment # (Transparent Huge Pages should be disabled at host level)