Pausing Clients

Difficulty: Advanced

Question

What does CLIENT PAUSE do, what is the difference between ALL and WRITE mode, and when would you use it in production?

Answer

CLIENT PAUSE <timeout-ms> [WRITE | ALL] tells Redis to stop processing commands from normal clients for the given number of milliseconds. Commands are not rejected; they wait and run once the pause ends. Its main purpose is to freeze the dataset briefly so a replica can fully catch up before a controlled failover or migration.

ALL vs WRITE mode

ModeWhat is held backTypical use
ALL (default)Every command from normal clientsHard freeze for a very short switchover
WRITE (6.2+)Write commands, plus commands that may write such as EVAL/EVALSHA, PUBLISH and PFCOUNTFailover while reads keep working

In WRITE mode, Redis also stops expiring and evicting keys during the pause, so the dataset truly does not change. Replication continues: the primary keeps streaming already-applied writes to replicas, which is exactly what lets them catch up.

CLIENT UNPAUSE (6.2+) ends a pause early.

A manual switchover using CLIENT PAUSE

  1. On the old primary: CLIENT PAUSE 10000 WRITE.
  2. Compare master_repl_offset on the primary with the replica's offset (from INFO replication), or use WAIT 1 5000 to confirm replication.
  3. On the replica: REPLICAOF NO ONE to promote it.
  4. Point clients at the new primary (DNS, proxy or Sentinel config).
  5. Turn the old primary into a replica of the new one and unpause.

Because no writes were accepted during steps 2 to 4, no data is lost in the handover. Redis automates this flow: CLUSTER FAILOVER in Cluster and the FAILOVER command for standalone replication (6.2+) both pause writes internally while the replica catches up.

Gotchas

  • Clients wait, they do not fail. Requests pile up in client buffers and your application's latency jumps by up to the pause length. Make sure client timeouts are longer than the pause, or users see errors.
  • Keep it short. Seconds, not minutes. An ALL pause stalls health checks too, and orchestrators may decide the node is dead.
  • Replication and admin traffic still flow. Pause targets normal clients; replicas are not paused.
  • Permissions. CLIENT PAUSE is an admin command; application ACL users should not have it.

Other uses

  • Taking a consistent view while switching a proxy (like Envoy or Twemproxy) to new backends.
  • Rolling a configuration change that needs a quiet moment.
  • Testing how your services behave when Redis stops responding, since a pause is a realistic stall without killing the process.
Zero-loss switchover with CLIENT PAUSE WRITE. Writes are held so the replica can reach the exact same offset before promotion.
  1. Pause writes on the primary: CLIENT PAUSE 10000 WRITE; reads still work.
  2. Wait for replica to catch up: Replica offset equals master_repl_offset.
  3. Promote the replica: REPLICAOF NO ONE.
  4. Repoint clients: Update DNS, proxy or Sentinel.
  5. Demote old primary and unpause: REPLICAOF new-host 6379, then CLIENT UNPAUSE.

Code examples

Pausing writes during a manual failover

# On the current primary (redis-a)
CLIENT PAUSE 10000 WRITE
INFO replication          # note master_repl_offset

# On the replica (redis-b): check it has the same offset
INFO replication          # compare slave_repl_offset / master_repl_offset
REPLICAOF NO ONE          # promote

# Back on redis-a, after clients point to redis-b
REPLICAOF redis-b 6379
CLIENT UNPAUSE

# Or let Redis do it (6.2+, run on the primary)
# FAILOVER TO redis-b 6379 TIMEOUT 10000

The pause guarantees no new writes land on redis-a while the replica catches up. The built-in FAILOVER command performs the same choreography automatically.

Key points

  • CLIENT PAUSE delays commands for a timeout in milliseconds; clients wait instead of getting errors
  • WRITE mode (6.2+) blocks only writes and may-write commands; reads continue
  • Expiry and eviction are suspended during a WRITE pause; replication keeps flowing
  • CLIENT UNPAUSE (6.2+) ends a pause early
  • CLUSTER FAILOVER and FAILOVER use the same mechanism internally

Common follow-up questions

  • How do you verify a replica has caught up before promoting it?
  • What does the WAIT command guarantee and what does it not?
  • How does Sentinel perform failover and can it lose writes?
  • How would your application behave during a 5-second pause?

Interview tips

  • Explain the purpose (freeze writes so the replica catches up), not just the definition
  • Mention WRITE mode and that reads keep working; it shows you know the 6.2 improvements
  • Talk about client timeouts; interviewers like candidates who think about the application side

Concepts covered

CLIENT PAUSE, WRITE mode, CLIENT UNPAUSE, Failover, Replication offset

More Redis & Caching questions