Deploying and Configuring Redis on Windows
Acquiring Windows Binaries
Since the official Redis project does not supply Windows executables, Windows-compatible builds can be sourced from community-maintained repositories. Extract the downloaded archive to your preferred directory.
Executable Components
| File | Purpose |
|---|---|
| redis-server.exe | Launches the Redis database server. |
| redis-cli.exe | Command-line interface for interacting with the server. |
| redis-benchmark.exe | Utility for evaluating server performance. |
| redis-check-aof.exe | Tool for validating and repairing Append-Only Files. |
| redis-check-dump.exe | Tool for verifying RDB snapshot files. |
| redis.windows.conf | Primary configuration file for the Windows environment. |
Service Management
To run Redis as a background service, execute the installation command followed by the start command from your terminal:
redis-server.exe --service-install redis.windows.conf --loglevel verbose
redis-server.exe --service-startTo halt and remove the service, use:
redis-server.exe --service-stop
redis-server.exe --service-uninstallConfiguration Parameters
Settings are defined within redis.windows.conf. Ensure the file is saved with UTF-8 encoding if it contains non-ASCII characters.
- daemonize: Operates as a background daemon (set to yes or no).
- pidfile: Path to store the process ID file. Unique paths are required for multiple instances.
- port: Listening port (default 6379). A value of 0 disables TCP listening.
- bind: Restricts connections to specific IP addresses (e.g., 127.0.0.1). Unset by default, accepting all interfaces.
- timeout: Client connection idle timeout in seconds (0 disables timeout).
- loglevel: Logging verbosity. Options: debug, verbose, notice, warning.
- logfile: Path for log output. Defaults to stdout.
- databases: Total number of logical databases (default 16).
- save <seconds> <changes>: Triggers an RDB snapshot after specified write operations within a timeframe.
- rdbcompression: Enables LZF compression for snapshot files.
- dbfilename: Name of the RDB file.
- dir: Directory path for snapshot storage.
- requirepass: Forces clients to authenticate using the specified password.
- maxclients: Maximum concurrent client connections.
- maxmemory: Hard limit on memory usage. Reaching this limit triggers the eviction policy.
- maxmemory-policy: Key eviction strategy when memory limits are hit (e.g., volatile-lru, allkeys-lru, noeviction).
Replication Settings
- slaveof <masterip> <masterport>: Configures the instance as a replica of a primary node.
- masterauth: Password for authenticating with the primary node.
- slave-serve-stale-data: Determines if replicas serve stale data when disconnected from the primary.
- repl-ping-slave-period: Interval in seconds for replica heartbeats (default 10).
- repl-timeout: Timeout for bulk data I/O and pings (default 60). Must exceed repl-ping-slave-period.
Append-Only File (AOF) Settings
- appendonly: Enables AOF persistence for greater durability.
- appendfilename: Name of the AOF file (default appendonly.aof).
- appendfsync: Disk synchronization frequency. Options: always, everysec, no.
- no-appendfsync-on-rewrite: Prevents fsync calls during BGREWRITEAOF to reduce blocking.
- auto-aof-rewrite-percentage: Triggers AOF rewrite if file size grows by this percentage.
- auto-aof-rewrite-min-size: Minimum AOF size to trigger a rewrite.
Slow Log and Advanced Settings
- slowlog-log-slower-than: Threshold in microseconds for logging slow commands. Negative values disable it.
- slowlog-max-len: Maximum number of slow log entries.
- hash-max-ziplist-entries / hash-max-ziplist-value: Limits for memory-efficient hash encoding.
- list-max-ziplist-entries / list-max-ziplist-value: Limits for memory-efficient list encoding.
- set-max-intset-entries: Maximum entries for integer set encoding.
- zset-max-ziplist-entries / zset-max-ziplist-value: Limits for memory-efficient sorted set encoding.
- activerehashing: Actively rehashes the main dictionary to reclaim memory.
Virtual Memory (VM) configurations were deprecated in Redis 2.4 and should be ignored.
Client Interaction
Launch redis-cli.exe to connect to the local server. Verify the connection:
127.0.0.1:6379> ping
PONGRetrieve comprehensive server statistics and configuration details:
127.0.0.1:6379> infoThis command outputs blocks of data covering Server, Clients, Memory, Persistence, Stats, Replication, CPU, and Keyspace metrics.
Performance Benchmarking
The redis-benchmark.exe utility simulates load. Executing it without arguments runs default tests.
Example output:
====== SET ======
200000 requests completed in 1.32 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.98% <= 2 milliseconds
151515.15 requests per secondCommon parameters:
-h: Target host (default 127.0.0.1)-p: Target port (default 6379)-c: Concurrent client connections (default 50)-n: Total number of requests (default 100000)-d: Data size in bytes for SET/GET (default 2)-t: Run specific tests (e.g., set,get)-q: Quiet mode, shows only requests/sec--csv: Outputs results in CSV format-r: Inserts random keys using the specified range
Execution examples:
redis-benchmark -h 10.0.0.5 -p 6380 -n 200000 -c 25
redis-benchmark -t set -n 500000 -r 50000000
redis-benchmark -t ping,set,get -n 150000 --csvData File Validation
To validate an Append-Only File and optionally repair it:
redis-check-aof.exe appendonly.aof --fixTo inspect an RDB snapshot file for integrity and size metrics:
redis-check-dump.exe dump.rdb