skip to content

Operational Tooling

INFO and MONITOR show what a server is doing, redis-benchmark loads it, and redis.conf and CONFIG change it. Operations interviews ask which tool to reach for and what each costs a live instance.

part ofRedisread it →
on this pageshow

explore

questions

12

In Redis, what does `CONFIG SET` change, what happens to that change at restart, and what does `CONFIG REWRITE` add?

level: juniorimportance: must knowfreq 45%

answer

  1. running server versus file on disk
  2. takes effect on the next command
  3. a restart reads the old file
  4. minimal edits, comments kept

basics

~10 s

CONFIG SET changes a setting on the running Redis server from the next command onward but leaves redis.conf alone, so a restart reverts it. CONFIG REWRITE writes the running values back into that file.

solid answer

~50 s

`CONFIG SET` changes a parameter on the running server, and the new value applies from the next command with no restart. It does not touch `redis.conf`, and it acts only on the server you sent it to, so the next restart loads the old value again. To keep the change, edit the file by hand or run `CONFIG REWRITE`, which updates the file the server was started with so that it matches the current values, keeping comments and changing as little as it can. An option already in the file is rewritten on its own line, a non-default option not in the file is appended, and an option at its default is not added. `CONFIG GET` reads the effective values and accepts glob patterns. A server started with no config file answers `CONFIG REWRITE` with an error.

code

plaintext · 7 lines
plaintext
127.0.0.1:6379> CONFIG GET loglevel
1) "loglevel"
2) "notice"
127.0.0.1:6379> CONFIG SET loglevel verbose
OK
127.0.0.1:6379> CONFIG REWRITE
OK

go deeper

for a junior

Recall the three commands and what each touches: GET reads, SET changes the running server, REWRITE writes the file. Say clearly that a restart loses an unsaved change.

for a middle

Explain how the rewrite treats an option: rewritten in place when present, appended when non-default and absent, skipped when default and absent. Mention that the change does not reach replicas.

for a senior

Show the operating habit: verify with CONFIG GET, persist on every node, and treat config files as drifting from live values unless something checks them after an incident.

for a principal

Decide who owns the truth. If configuration management owns the file, a live change plus CONFIG REWRITE is overwritten at the next run, so a team needs a rule for feeding incident changes back.

## Two copies of every setting A Redis server has a **configuration file**, usually called `redis.conf`, and a set of **effective values** held by the running process. At startup the server reads the file into those values. After that the two can drift apart, and most of this topic is about managing that drift. Three commands work on the running values and the file: - `CONFIG GET` reads effective values. - `CONFIG SET` changes effective values. - `CONFIG REWRITE` copies effective values into the file. ## Reading with CONFIG GET `CONFIG GET` takes one or more parameter names or glob-style patterns and replies with name and value pairs. `CONFIG GET *` lists the settings at once, and `CONFIG GET *max-*-entries* maxmemory` mixes a pattern with an exact name. A name that matches nothing simply adds nothing to the reply; it is not an error. Because it reports what the server is really using, `CONFIG GET` is the check to run after any change. Reading the file tells you what the next restart will do, not what the server is doing now. ## Changing with CONFIG SET `CONFIG SET parameter value [parameter value ...]` replies `OK`, or an error if the value was not set. The Redis documentation says a value set this way is loaded immediately and takes effect starting with the next command. Most settings work this way, so a routine change needs no restart. Since Redis 7.0 one call can carry several pairs. Some settings do more than flip a value. `CONFIG SET appendonly yes` starts a background process that writes the initial append-only file. The command still replies at once, but the work it started takes time. Three limits matter in practice: - **It leaves the file alone.** The documentation says plainly that at the next restart the old configuration is used. - **It acts on one server.** `CONFIG SET` is not a write command and is not replicated, so a replica keeps its own value until you change it there too. - **Not every setting accepts it.** Some can only change through the file and a restart. ## Persisting with CONFIG REWRITE `CONFIG REWRITE` updates the file the server was started with. `INFO server` shows that path in its `config_file` field. The rewrite is deliberately conservative: 1. Comments and the overall structure of the file are preserved as far as possible. 2. An option already in the file is rewritten on the same line. 3. An option not in the file, at its default value, is not added. 4. An option not in the file, at a non-default value, is appended at the end. The first appended line follows a `# Generated by CONFIG REWRITE` marker. 5. Lines no longer in use are blanked, for example surplus `save` lines after snapshots were turned off. Rule 2 has a useful consequence: an option already in the file stays there even when set back to its default, so its line records the value you meant. A line the rewrite cannot parse, or one naming a setting this binary does not know, is kept as a comment starting `# ???`. ## When the rewrite fails A server started with no configuration file replies `The server is running without a config file`. If the file existed at startup and has since vanished, the command can rebuild it from scratch. The 8.10 source writes a temporary file beside the original, syncs it, then renames it over the original, so a crash leaves either the old file or the new one. That means the server needs write access to the directory, not just the file. Otherwise the reply is an error that begins `Rewriting config file:` followed by the reason. ## The usual habit 1. Check the current value with `CONFIG GET`. 2. Apply the change with `CONFIG SET` and watch the effect. 3. If it was right, run `CONFIG REWRITE` or update the source of truth for the file. 4. Repeat on every other node that should hold the value, replicas included. The failure this prevents is a quiet one. A setting tuned live during an incident works for months, then disappears at the next restart, and nobody connects the two events because the restart happened long after the change.

  • You ran CONFIG SET on a Redis primary. Does its replica pick up the new value?
    No. `CONFIG SET` is not a write command, so it is not replicated, and each node keeps its own value. Run it, and `CONFIG REWRITE`, on every node. Cluster-aware client libraries may send it to all nodes because the command's routing tip says `all_nodes`, but that is the client's doing, not the server's.
  • What can CONFIG REWRITE do to the config file that you might not expect?
    It persists every non-default effective value, not only the one you just changed, so an option passed as `--port 7000` on the command line lands in the file. In 8.10 it also replaces the file through a temp-and-rename and sets mode 0644 less the server's umask, so a tighter mode on a file holding a password is not kept.

A thermostat's manual override changes the temperature right now, but after a power cut it returns to its stored program. CONFIG SET is the override, redis.conf is the stored program, and CONFIG REWRITE saves the override into the program.

  • CONFIG SET saves the new value into redis.conf automatically.
  • CONFIG REWRITE dumps every setting into a new file and loses the comments.
  • You must restart Redis before any CONFIG SET change takes effect.
  • CONFIG SET on a primary is replicated to its replicas.
  • A server started with no config file can create one with CONFIG REWRITE.
open as a page

On an unfamiliar production Redis instance, what does the INFO command report, and which sections would you read first?

level: juniorimportance: must knowfreq 48%

basics

~10 s

INFO returns one server's state and counters as field:value lines grouped into sections. Read server, replication, clients and stats first for version, role, load and refusals; plain INFO omits commandstats, so name it.

open as a page

You must move a production Redis primary with one replica from 7.2 to 8.10 without downtime: which steps, commands and checks make up the upgrade?

level: seniorimportance: must knowfreq 45%

basics

~20 s

Upgrade the replica to 8.10, let it sync and compare key counts, pause writes on the 7.2 primary with CLIENT PAUSE WRITE, match offsets, promote with REPLICAOF NO ONE, run CONFIG REWRITE, repoint clients, then upgrade the old node.

open as a page

How does Redis resolve a directive set twice across `redis.conf` and `include` files, and how does `CONFIG REWRITE` treat those files?

level: middleimportance: should knowfreq 30%

basics

~10 s

Redis processes config lines in order, expanding each include where it appears, so the last line for a single-value directive wins. CONFIG REWRITE edits only the startup file, and never the included ones.

open as a page

Which Redis settings refuse `CONFIG SET`, what reply do you get, and how do you change one on a production primary with a replica?

level: middleimportance: should knowfreq 40%

basics

~20 s

Immutable settings such as io-threads and databases reply can't set immutable config; dir and dbfilename reply can't set protected config. Edit the file, restart the replica, move the primary role to it, then restart the old primary.

open as a page

In Redis, connected_clients has climbed close to maxclients; how do you use CLIENT LIST to find out who holds those connections?

level: middleimportance: should knowfreq 36%

basics

~20 s

CLIENT LIST prints one line per connection with its address, name, age, idle time, flags and last command. Group the lines by host or name, then use age, idle and flags to separate a leaking pool, connection churn and blocked clients.

open as a page

In Redis, what do INFO commandstats and INFO errorstats report, and how do you read calls, usec, rejected_calls and failed_calls correctly?

level: middleimportance: should knowfreq 42%

basics

~20 s

Commandstats gives each command's calls, time and rejected and failed counts; errorstats counts error replies by prefix. Both are cumulative, so subtract two snapshots. Rejected commands never ran; failed ones ran and are also in calls.

open as a page

In a rolling Redis upgrade under Sentinel or Redis Cluster, which nodes go first, and how does the primary role move between them?

level: seniorimportance: should knowfreq 38%

basics

~20 s

Upgrade replicas one at a time, then demote the primary with SENTINEL FAILOVER, or CLUSTER FAILOVER sent to one of its replicas. Upgrade the demoted node last, and repeat per shard in a cluster, checking health before each next node.

open as a page

A redis-benchmark run on the Redis server's own host reports 1.5 million SET requests per second; which flags shaped that figure, and what did it actually measure?

level: seniorimportance: should knowfreq 31%

basics

~20 s

A figure like that normally comes from -P. With other defaults it measured pipelined SETs of a 3-byte value on one key over loopback, client and server sharing a machine: true of that shape, not of production traffic.

open as a page

A teammate wants to leave the Redis MONITOR command running on a production primary to watch traffic; what does that cost, and what do you do instead?

level: seniorimportance: should knowfreq 45%

basics

~20 s

MONITOR makes the main thread format and send every command to each watcher; the docs' example lost over half its throughput on most tests. A slow reader's output buffer has no default cap. Prefer commandstats, or a short supervised capture.

open as a page

As the lead for a Redis fleet, what upgrade policy do you set: how far behind may nodes run, and how do you prove a rollback works?

level: principalimportance: should knowfreq 28%

basics

~20 s

Stay on a release line Redis still patches, set deadlines by release-note urgency, and rehearse each jump. Treat rollback as restoring a backup with data loss, proved by a timed drill on the old binary: no downgrade is documented.

open as a page

Before a launch, a team wants to use a redis-benchmark result as its Redis capacity number; what may that result decide, and who signs off on capacity?

level: principalimportance: should knowfreq 20%

basics

~20 s

A redis-benchmark result can decide comparisons on one harness and rule out Redis as an obvious limit, but it is not production capacity. The lead whose team runs the instance signs a statement of its conditions and expiry.

open as a page