Valkey

On this page 7

Valkey is an open-source, in-memory key-value data store that keeps data structures such as strings, hashes, lists, sets and sorted sets in RAM and serves them over a simple network protocol with sub-millisecond latency. Among database systems in the field of databases, it belongs to the family of NoSQL key-value stores and is most often deployed as a cache, session store, message broker or real-time counter engine in front of a durable primary database.

Valkey began in March 2024 as a community fork of Redis 7.2.4, created after Redis changed its license away from the permissive BSD terms. The project is hosted by the Linux Foundation, remains under the BSD 3-Clause license, and is supported by several cloud providers and long-time Redis contributors. It stays wire-compatible with the Redis protocol, so most existing clients and commands work without modification.

How Valkey stores and serves data

Valkey serves every request from main memory, which is the main reason it answers reads and writes in tens to hundreds of microseconds. Clients connect over TCP or Unix sockets and speak RESP (REdis Serialization Protocol), a compact text-and-binary framing that keeps parsing overhead low.

Command execution runs on a single main thread, which makes each command atomic without locks: no two commands ever interleave on the same key. Since version 8.0, Valkey offloads network reading, writing and parsing to I/O threads, so the main thread spends most of its time executing commands. This design keeps the simple consistency model of classic Redis while using more CPU cores for networking.

Because RAM is volatile, Valkey offers two persistence mechanisms that can run separately or together. The table below summarizes them.

MechanismHow it worksTypical data loss on crashMain cost
RDB snapshotsForked child writes a point-in-time fileMinutes, depending on scheduleFork memory overhead
AOF (append-only file)Logs every write commandAbout one second with everysecLarger files, rewrite cycles
RDB plus AOFSnapshot base with command logAbout one secondHighest disk usage
No persistenceData lives only in RAMAll dataNone; pure cache use
Persistence options in Valkey

Data structures and core features

Valkey is often called a data structure server because values are typed structures with dedicated server-side operations, not opaque blobs. Moving logic such as ranking, counting or set intersection to the server reduces round trips and keeps operations atomic.

Data typeExample commandsTypical use
StringGET, SET, INCRCache entries, counters, locks
HashHSET, HGETALLUser profiles, object fields
ListLPUSH, BRPOPSimple job queues
SetSADD, SINTERTags, unique visitors
Sorted setZADD, ZRANGELeaderboards, rate limits
StreamXADD, XREADGROUPEvent logs with consumer groups
Bitmap and HyperLogLogSETBIT, PFCOUNTCompact flags, approximate cardinality
Main Valkey data types and typical uses

Other core features include key expiration (TTL), publish/subscribe messaging, transactions with MULTI and EXEC, and server-side Lua scripting and functions. Recent releases added per-field expiration in hashes, a redesigned internal hash table that lowers memory overhead per key, and a module system used for extensions such as JSON documents, Bloom filters and vector search.

Replication, high availability and clustering

Valkey scales and survives failures through asynchronous primary-replica replication. A replica receives a full snapshot first and then a continuous stream of write commands; because acknowledgment is asynchronous, a failover can lose the most recent writes that had not yet reached a replica.

  • Sentinel monitors a primary and its replicas, elects a new primary on failure and tells clients the new address.
  • Valkey Cluster shards data across nodes using 16,384 hash slots, with each key mapped by a CRC16 hash of its name.
  • Multi-key commands in cluster mode work only when keys share a slot, which developers enforce with hash tags such as {user:42}.
  • Newer versions support atomic slot migration and multiple logical databases in cluster mode, which earlier Redis clusters did not allow.

How Valkey compares with Redis and Memcached

Valkey is functionally close to Redis because both share the same code base up to version 7.2.4, yet the projects have diverged since 2024 in governance, licensing and new features. Memcached, another in-memory store in the same Topic, is simpler and multithreaded but offers only plain string values.

AspectValkeyRedis (8.x)Memcached
LicenseBSD 3-ClauseRSALv2, SSPLv1 or AGPLv3BSD 3-Clause
GovernanceLinux Foundation projectSingle companyCommunity project
Data typesRich structures and streamsRich structures plus bundled modulesStrings only
PersistenceRDB and AOFRDB and AOFNone
Replication and clusteringBuilt inBuilt inClient-side sharding only
Threading modelSingle executor, threaded I/OSingle executor, threaded I/OFully multithreaded
Valkey compared with related in-memory stores

For most applications, migration from Redis 7.2 or earlier to Valkey is a drop-in replacement: data files, replication and the client protocol remain compatible. Compatibility is not guaranteed for features added to Redis after the fork, so teams using newer Redis-only commands or modules should test before switching.

When to use Valkey and what to watch

Valkey fits workloads where speed matters more than storage volume and where the data either has a durable copy elsewhere or can tolerate small losses. The decision table below maps common needs to a recommended approach.

SituationRecommended setupReason
Read-heavy web cacheStandalone with replicas, no persistenceCache can be rebuilt from the database
Session storagePrimary and replica with AOF everysecLimits logouts after a crash
Dataset larger than one nodeValkey Cluster with shardingSpreads memory and throughput
Financial ledgerUse a relational database insteadAsynchronous replication can lose writes
Choosing a Valkey deployment pattern

The most common mistakes are operational. Memory limits must be set with maxmemory and a suitable eviction policy such as allkeys-lru, or the server rejects writes or is killed by the operating system. Commands such as KEYS on large datasets block the single executor thread and stall every client, so SCAN should be used instead. Instances must never be exposed to the internet without authentication, ACLs and TLS, because unprotected instances are a frequent target of automated attacks.

The simple explanation

Valkey is like a very fast notepad kept in a computer’s memory instead of on its disk. Applications write small pieces of information there, such as who is logged in or which products are popular, and read them back almost instantly.

It started as a copy of the popular Redis software when that project changed its rules for use. Valkey keeps the free, open license, works the same way for most programs, and is maintained by a broad community. The key idea: Valkey makes applications faster by keeping frequently used data close at hand.

How it is used in practice

An online retailer runs its product catalog in PostgreSQL. During seasonal sales, product pages receive about 40,000 requests per second, and the database struggles with repeated identical queries. The engineering team places a three-node Valkey deployment in front of the database: one primary and two replicas managed by Sentinel.

Each product page is cached as a hash with a TTL of five minutes, and shopping carts are stored as hashes with AOF persistence set to everysec. A sorted set tracks the best-selling items in real time. The team sets maxmemory to 70 percent of available RAM with the allkeys-lru eviction policy.

After the change, more than 95 percent of catalog reads are served from Valkey, median page latency drops from roughly 120 ms to under 20 ms, and database CPU load falls enough to postpone a planned hardware upgrade. Because the team had previously run Redis 7.2, the switch required only new container images, not code changes.