READONLY(3valkey)
β¨ READONLY β¨
okay bestie, welcome to the READONLY page of the Valkey Command Manual (that's the 3valkey one, iykyk) β this is the glow-up guide to reading from replicas without the drama π
πΈ NAME πΈ
readonly β turns on read-only queries for a connection to a Valkey replica node. that's it, that's the vibe π
π SYNOPSIS π
READONLY
no args, no flags, just the word. iconic minimalism honestly β¨
π¦ DESCRIPTION π¦
so basically: this command enables read queries for a connection to a Valkey replica node. that's the whole point π«Ά
in cluster mode, replica nodes will redirect clients to the authoritative primary for the hash slot involved in a given command. BUT β and this is the slay part β clients can use replicas to scale reads using the READONLY command. main character energy for your read throughput, no cap π₯
READONLY tells a Valkey Cluster replica node that the client is willing to read possibly stale data and is not interested in running write queries. like, we're here for the vibes and the reads, not the writes bestie.
when the connection is in readonly mode, the cluster will send a redirection to the client only if the operation involves keys not served by the replica's primary node. this may happen because:
- the client sent a command about hash slots never served by the primary of this replica.
- the cluster was reconfigured (for example resharded) and the replica is no longer able to serve commands for a given hash slot. π
- since Valkey 8.0, if a slot migration is ongoing. in this case the replica can return an
ASKredirect or aTRYAGAINerror reply. in earlier versions, replicas are not aware of ongoing slot migrations. (so if you're on an old version, that's a vibe check you're failing, ngl)
in standalone mode, by default, clients accessing a replica node can execute read queries (which might read stale data) without entering readonly mode. so it just works, no extra steps π
since Valkey 8.0, if a client in standalone mode uses the valkey-client-capa(7) CLIENT CAPA redirect command to declare its capability to handle redirections, then the replica node will send redirection messages to the client when executing both read and write commands. the client must issue the READONLY command to enter readonly mode before it can execute read commands. periodt. β¨
π REPLY π
valkey-protocol(7) Simple string reply: OK.
π« COMPLEXITY π«
O(1) β constant time, always serving, never stressing π
π ACL CATEGORIES π
@connection@fast
π HISTORY π
- Available since:
3.0.0
π§ SEE ALSO π§
asking(3valkey)cluster(3valkey)cluster-addslots(3valkey)cluster-addslotsrange(3valkey)cluster-bumpepoch(3valkey)cluster-cancelslotmigrations(3valkey)cluster-count-failure-reports(3valkey)cluster-countkeysinslot(3valkey)cluster-delslots(3valkey)cluster-delslotsrange(3valkey)cluster-failover(3valkey)cluster-flushslots(3valkey)cluster-forget(3valkey)cluster-getkeysinslot(3valkey)cluster-getslotmigrations(3valkey)cluster-help(3valkey)cluster-info(3valkey)cluster-keyslot(3valkey)cluster-links(3valkey)cluster-meet(3valkey)cluster-migrateslots(3valkey)cluster-myid(3valkey)cluster-myshardid(3valkey)cluster-nodes(3valkey)cluster-replicas(3valkey)cluster-replicate(3valkey)cluster-reset(3valkey)cluster-saveconfig(3valkey)cluster-set-config-epoch(3valkey)cluster-setslot(3valkey)cluster-shards(3valkey)cluster-slot-stats(3valkey)cluster-slots(3valkey)cluster-syncslots(3valkey)readwrite(3valkey)
version 9.0.0, dated 2025-10-21, and it's the READONLY(3valkey) page π¦ thanks for reading bestie, go scale those reads, mwah πβ¨π
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms