Configuration
Configure Echo DB to suit your needs
Echo DB can be configured using a YAML configuration file. Create a config.yaml file in the configs/ directory or in the current working directory.
Configuration File Structure
# EchoDB configs
# server related configs
server:
host: "0.0.0.0"
port: 6380
# persistence related configs
persistence:
enabled: false
data_dir: "./data"
aof:
enabled: true
file: "echo.aof"
sync_mode: "periodic"
flush_interval: "5s"Server Configuration
server.host
The network interface to bind to.
- Type:
string - Default:
"0.0.0.0" - Description: IP address or hostname to listen on. Use
0.0.0.0to listen on all interfaces, or127.0.0.1to listen only on localhost.
Example:
server:
host: "0.0.0.0" # Listen on all interfaces
# host: "127.0.0.1" # Listen only on localhostserver.port
The port number to listen on.
- Type:
integer - Default:
6380 - Description: TCP port for client connections.
Example:
server:
port: 6380 # Default portPersistence Configuration
persistence.enabled
Enable or disable persistence.
- Type:
boolean - Default:
false - Description: When set to
false, no data is persisted and all data is lost on server restart.
Example:
persistence:
enabled: true # Enable persistence
# enabled: false # Disable persistencepersistence.data_dir
Directory for storing persistence files.
- Type:
string - Default:
"./data" - Description: Path to directory where AOF files are stored. Can be relative or absolute.
Example:
persistence:
data_dir: "./data" # Relative path
# data_dir: "/var/lib/echodb" # Absolute pathpersistence.aof.enabled
Enable or disable AOF persistence.
- Type:
boolean - Default:
true - Description: When set to
false, AOF logging is turned off even if persistence is enabled.
Example:
persistence:
aof:
enabled: truepersistence.aof.file
AOF filename.
- Type:
string - Default:
"echo.aof" - Description: Name of the AOF file. The file is stored in the
data_dirdirectory.
Example:
persistence:
aof:
file: "echo.aof" # Default filenamepersistence.aof.sync_mode
AOF sync mode.
- Type:
string - Default:
"periodic" - Valid Values:
"always","periodic","no" - Description: Controls when data is synced to disk.
Options:
always: Sync after every write operation. Maximum durability, lower performance.periodic: Sync at configured intervals. Balanced approach (recommended).no: No automatic syncing. Maximum performance, higher risk of data loss.
Example:
persistence:
aof:
sync_mode: "periodic" # Recommended
# sync_mode: "always" # Maximum durability
# sync_mode: "no" # Maximum performancepersistence.aof.flush_interval
Flush interval for periodic sync mode.
- Type:
duration(string) - Default:
"5s" - Description: How often to sync to disk when using
periodicsync mode. Format: number followed by unit (s for seconds, m for minutes, h for hours).
Example:
persistence:
aof:
sync_mode: "periodic"
flush_interval: "5s" # Sync every 5 seconds
# flush_interval: "1s" # Sync every second
# flush_interval: "30s" # Sync every 30 secondsConfiguration File Locations
Echo DB searches for configuration files in the following order:
./configs/config.yaml./config.yaml/etc/echo-db/config.yaml
Environment Variables
You can also override configuration using environment variables with the ECHO_DB prefix:
export ECHO_DB_SERVER_HOST=0.0.0.0
export ECHO_DB_SERVER_PORT=6380
export ECHO_DB_PERSISTENCE_ENABLED=true
export ECHO_DB_PERSISTENCE_AOF_SYNC_MODE=periodicExample Configurations
Development
server:
host: "127.0.0.1"
port: 6380
persistence:
enabled: true
data_dir: "./data"
aof:
enabled: true
file: "dev.aof"
sync_mode: "no" # Fast for developmentProduction
server:
host: "0.0.0.0"
port: 6380
persistence:
enabled: true
data_dir: "/var/lib/echodb"
aof:
enabled: true
file: "echo.aof"
sync_mode: "periodic"
flush_interval: "5s"Next Steps
- Commands - Learn available commands
- Connecting to Echo DB - Connect to your instance