{
  "id": "wait",
  "title": "Use the WAIT command to improve data safety and durability",
  "url": "https://redis.io/docs/latest/operate/rs/7.8/clusters/optimize/wait/",
  "summary": "Use the wait command to take full advantage of Redis Enterprise Software's replication-based durability.",
  "content": "Redis Enterprise Software comes with the ability to replicate data\nto another replica for high availability and persist in-memory data on\ndisk permanently for durability. With the [`WAIT`]() command, you can\ncontrol the consistency and durability guarantees for the replicated and\npersisted database.\n\n## Non-blocking Redis write operation\n\nAny updates that are issued to the database are typically performed with the following flow:\n\n1. Application issues a write.\n1. Proxy communicates with the correct primary shard in the system that contains the given key.\n1. The acknowledgment is sent to proxy after the write operation completes.\n1. The proxy sends the acknowledgment back to the application.\n\nIndependently, the write is communicated from the primary shard to the replica, and\nreplication acknowledges the write back to the primary shard. These are steps 5 and 6.\n\nIndependently, the write to a replica is also persisted to disk and\nacknowledged within the replica. These are steps 7 and 8.\n\n\n\n## Blocking write operation on replication\n\nWith the [`WAIT`]() or [`WAITAOF`]() commands, applications can ask to wait for\nacknowledgments only after replication or persistence is confirmed on\nthe replica. The flow of a write operation with `WAIT` or `WAITAOF` is:\n\n1. The application issues a write.\n1. The proxy communicates with the correct primary shard in the system that contains the given key.\n1. Replication communicates the update to the replica shard.\n1. If using `WAITAOF` and the AOF every write setting, the replica persists the update to disk before sending the acknowledgment.\n1. The acknowledgment is sent back from the replica all the way to the proxy with steps 5 to 8.\n\nThe application only gets the acknowledgment from the write after durability is achieved with replication to the replica for `WAIT` or `WAITAOF` and to the persistent storage for `WAITAOF` only.\n\n\n\nThe `WAIT` command always returns the number of replicas that acknowledged the write commands sent by the current client before the `WAIT` command, both in the case where the specified number of replicas are reached, or when the timeout is reached. In Redis Enterprise Software, the number of replicas is always 1 for databases with high availability enabled.\n\nSee the [`WAITAOF`]() command for details for enhanced data safety and durability capabilities introduced with Redis 7.2.\n",
  "tags": ["docs","operate","rs"],
  "last_updated": "2026-04-01T08:10:08-05:00"
}

