
Valkey: how the key–value store works and where to use it
An introduction to Valkey, shared state, caching, performance and migration from Redis.
What Valkey does
Valkey is a networked data store that primarily keeps data in memory. Applications use it for caches, sessions, counters and queues, especially when several application servers need shared state. It supports strings, hashes, lists, sets, sorted sets and streams, along with key expiration.
Valkey began in 2024 as a fork after Redis changed its licensing model. The Linux Foundation project uses the permissive BSD-3-Clause license. The first Valkey 7.2 release matched Redis 7.2.4 protocol, API and data file formats; the projects have since evolved independently, so newer capabilities require version-specific compatibility checks. [1]
Shared state in practice
Imagine three API servers handling requests for the same service. If sessions live only in each server’s local memory, a request reaching another server may not find its session. A shared Valkey instance makes that state accessible to each server. Shared counters can similarly coordinate rate limits.
INCR atomically increments a counter without a client-side read and write. If the counter also needs a TTL, combine creation and expiry atomically, for example in a Lua script. Replication, Sentinel and cluster configurations address different availability needs; none replaces backups.
Example: a temporary cart
In valkey-cli, store a value for 30 minutes:
SET cart:session:abc123 "product:42,quantity:2" EX 1800
GET cart:session:abc123
TTL cart:session:abc123This demonstrates commands rather than a complete cart design. A real application needs serialization, protected session identifiers, concurrent-update handling and a decision on acceptable data loss. Configure persistence and test recovery where the state must survive failure.
For a cache, cache-aside reads the primary database on a miss and writes the result with a TTL. Plan invalidation when the source changes: expiry limits staleness but does not eliminate every race.
What happens during an outage?
If Valkey only holds a catalog cache, the application might fall back to the primary database. A sudden flood of requests can overload that database, so test timeouts, limits and failure behavior in advance. If Valkey holds sessions or queue state, a failure can affect login or background processing. Decide which values can be reconstructed and which require tested recovery.
Performance and a local test
In a Lavik benchmark dated 21 October 2026, Valkey 9.1.2 reached about 914,000 GET/s and 794,000 SET/s with 1,280 connections. The 16-vCPU VM held ten million 1-KiB values; pipeline was 1, AOF and scheduled snapshots were off, and the chosen I/O thread counts were 16 for GET and 8 for SET. GET p99.9 was 7.743 ms. These are a competing vendor’s measurements for one configuration, not our own results. [2]
Try a synthetic baseline on an isolated instance:
valkey-benchmark -h 127.0.0.1 -p 6379 -t get,set -n 100000 -c 50 -d 1024 -P 1Pipeline 1 means the client does not batch commands in the way a larger pipeline does. Pipelining can improve throughput by reducing round trips; compare tests with this setting in mind. Reproduce your own data, network, persistence and command mix, and measure tail latency as well as throughput. [3]
Operating and migrating
Set a memory budget and eviction policy based on the consequences of losing a key. Isolate access, authenticate clients and use TLS where appropriate. For a Redis migration, test the actual client, commands, modules, configuration, backups, replication and rollback with your versions.
A disposable cache may be migrated by starting empty and warming it gradually, but this adds load to the primary database. Sessions and queues need a plan for writes during cutover and for potential loss. Valkey is worth considering when its features meet the workload and a permissive license matters.
Typical Valkey workloads
A catalog or API cache can key a response by query parameters and language, fetch the database on a miss and write the result with a TTL. Include the user’s authorization scope in keys for personalized responses, and invalidate affected entries when source data changes.
Shared sessions let any API instance look up an opaque session ID. Short-lived one-time state requires an atomic check-and-consume operation, expiry and careful handling of secrets. A shared rate counter also needs atomic increment and expiry. Sorted sets maintain leaderboards as scores change. For each use case, decide whether losing a key is acceptable and what happens when memory is full.
A request and its failure path
Request → API → Valkey
├─ hit → cached response
├─ miss → database → cache → response
└─ unavailable → service-specific fallbackFalling back to the database can overload it when all traffic switches at once. Test timeouts, concurrency limits and capacity. A sensitive login limiter may fail closed, while a low-risk read may use a local fallback. Replicas can improve availability but asynchronous lag can lose recent writes during failover; configure persistence and test recovery according to the value of the data.
A request and its failure path
Section valkey-failure-flow screenshotSources
Related Articles

Redis vs Valkey: performance, trade-offs and choosing for your project
Compare Redis and Valkey by benchmarks, licensing, features and migration costs.

Redis: how it works and when it makes an application faster
Learn how Redis works through caching examples, data structures, benchmarks and practical trade-offs.