Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Deploying and Configuring Redis on Windows

Tech 1

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

FilePurpose
redis-server.exeLaunches the Redis database server.
redis-cli.exeCommand-line interface for interacting with the server.
redis-benchmark.exeUtility for evaluating server performance.
redis-check-aof.exeTool for validating and repairing Append-Only Files.
redis-check-dump.exeTool for verifying RDB snapshot files.
redis.windows.confPrimary 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-start

To halt and remove the service, use:

redis-server.exe --service-stop
redis-server.exe --service-uninstall

Configuration 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
PONG

Retrieve comprehensive server statistics and configuration details:

127.0.0.1:6379> info

This 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 second

Common 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 --csv

Data File Validation

To validate an Append-Only File and optionally repair it:

redis-check-aof.exe appendonly.aof --fix

To inspect an RDB snapshot file for integrity and size metrics:

redis-check-dump.exe dump.rdb
Tags: Redis

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.