Disabling Replies

Difficulty: Advanced

Question

What does CLIENT REPLY OFF do, how is it different from SKIP, and when is it actually a good idea?

Answer

CLIENT REPLY OFF tells Redis to stop sending any replies to the current connection; commands still execute, but the client gets no response, not even errors. CLIENT REPLY SKIP suppresses the reply for only the next command, and CLIENT REPLY ON restores normal behaviour. It exists for fire-and-forget workloads where the client will never look at the results and wants to save the server and network the work of sending them.

The three modes

ModeEffectReply to the CLIENT REPLY command itself
ONNormal: one reply per commandOK
OFFNo replies until ONNone
SKIPNext command's reply is droppedNone

The command has been available since Redis 3.2.

Why it is rarely used directly

Almost every client library matches replies to requests in order: the third reply belongs to the third command. If replies stop arriving, the library waits forever or pairs the wrong reply with the wrong request. So CLIENT REPLY OFF is mainly useful when you control the raw RESP stream yourself, for example a custom loader or log shipper writing directly to a socket.

In most real systems, pipelining gives most of the same benefit safely: send many commands without waiting, read all replies at the end. You keep error reporting and libraries support it out of the box.

Trade-offs

  • You lose errors. A WRONGTYPE error or a NOPERM from ACLs is silently discarded. You will not know a write failed.
  • No back-pressure signal. Without replies the client has no idea how far behind the server is.
  • Smaller output buffers. The server does not accumulate replies for a client that is not reading them, which protects against output buffer growth during a large blind write.
  • Network savings are modest. Replies like +OK are tiny. The win is mostly avoiding reply processing and buffering.

Reasonable use cases

  • High-volume metrics or event counters where losing an occasional increment does not matter, sent over a raw connection.
  • Bulk loading tools that write millions of SET or HSET commands, then turn replies back on and send a final PING to know everything before it has been processed.
  • SKIP for a single noisy command in the middle of an otherwise normal raw session.

For bulk imports, the documented approach is redis-cli --pipe, which streams raw protocol and reports the error and reply counts at the end, so check that before reaching for CLIENT REPLY OFF.

Code examples

Fire-and-forget counters over a raw socket (Python)

import socket

s = socket.create_connection(("localhost", 6379))

cmds = [b"CLIENT REPLY OFF"]
cmds += [f"INCR hits:page:{i % 10}".encode() for i in range(10_000)]
cmds += [b"CLIENT REPLY ON", b"PING"]  # turn replies back on, then a marker

# Inline commands, one per line
s.sendall(b"\r\n".join(cmds) + b"\r\n")

# Only the replies to CLIENT REPLY ON and PING come back
print(s.recv(64))
s.close()

The 10,000 INCR replies are never sent. Receiving PONG proves the server processed everything before it, but any error from an INCR is lost.

The usual safer alternative: pipelining

import Redis from 'ioredis';
const redis = new Redis();

const pipe = redis.pipeline();
for (let i = 0; i < 10000; i++) pipe.incr(`hits:page:${i % 10}`);
const results = await pipe.exec(); // [[err, value], ...]
const failed = results.filter(([err]) => err).length;
console.log({ failed });

Pipelining also avoids a round trip per command but keeps per-command errors, which is why it is preferred in application code.

Key points

  • CLIENT REPLY OFF stops all replies, SKIP drops only the next one, ON restores them
  • Commands still execute; errors are silently discarded
  • Client libraries expect one reply per command, so use it only on raw connections
  • Pipelining usually gives the performance benefit while keeping errors
  • Send CLIENT REPLY ON plus PING as a completion marker

Common follow-up questions

  • How does pipelining differ from MULTI/EXEC?
  • What are client output buffer limits and why do they matter?
  • How does redis-cli --pipe do mass insertion?
  • How would you detect that a fire-and-forget write failed?

Interview tips

  • Explain why libraries break with replies off; it shows protocol-level understanding
  • Compare with pipelining and recommend it for normal application code
  • Call out the loss of error reporting as the main risk

Concepts covered

CLIENT REPLY, Fire and forget, Pipelining, Mass insertion, RESP protocol

More Redis & Caching questions