Redis, Valkey, and DragonflyDB: A Modern Guide to In-Memory Databases
In-memory databases are everywhere now. Caches, lightweight queues, session stores, time-series engines, and increasingly the backbone for vector search. Most teams reach for one without thinking twice.
Then Redis changed its license in 2024, and two serious alternatives walked through the open door: Valkey and DragonflyDB. Both speak the Redis protocol. They disagree on performance strategy, licensing, and how to use modern hardware.
Here is how they differ, and how to use any of them in Spring Boot without changing your code.
Redis: the industry standard
Redis has been the default in-memory database for over a decade. Small side projects, high-traffic platforms, everything in between.
Its core processing engine is still single-threaded, which keeps operations simple and atomic. Recent versions added background and I/O threads to offload blocking work without changing that model.
Redis 8.0 now ships with what used to be called Redis Stack built in: JSON support, time series, and vector search via Vector Sets. No separate modules to install.
The license changed, though. Redis now uses a triple model: RSALv2, SSPLv1, or AGPLv3. It is no longer OSI-approved open source. If you ship a commercial product or run a managed service, read the terms carefully before committing.
Redis is the right call when you need a mature ecosystem with clients for essentially every language, official enterprise support, or the advanced modules that have been battle-tested for years.
Valkey: community successor and truly open source
Valkey is a fork of the last BSD-licensed Redis version, 7.2.4. The Linux Foundation backs it. AWS and Google support it.
The goal is straightforward: a fully open, Redis-compatible engine that keeps command and protocol compatibility while improving what sits underneath.
It stays under a BSD-style license, which means it is real OSI-approved open source. No asterisks.
Under the hood, Valkey redesigned its internal hash table to be more CPU cache-friendly. The result is roughly 20 bytes saved per key-value pair. At scale, that adds up fast. Valkey 9.0 also introduced Atomic Slot Migration, which lets you rebalance clusters up to 9x faster with no client-visible errors.
Valkey is the natural pick if you are migrating from Redis and want near drop-in compatibility, if your organization requires 100% open source software, or if memory cost per gigabyte matters to your cloud bill.
DragonflyDB: built for the cloud era
DragonflyDB is not a Redis fork. It is a new engine built from scratch to use modern multi-core hardware.
The architecture is shared-nothing. Each thread owns its own shard of data. No global locks, no bottlenecks. This lets you scale vertically on a single machine in ways Redis and Valkey simply cannot.
Its Dashtable structure can save between 30% and 60% of memory compared to Redis, depending on your key patterns. For heavy read/write workloads, DragonflyDB reports up to 25x higher throughput than a classic Redis deployment.
The license is BSL, Business Source License. Free to use in many scenarios, but not OSI-approved, and it restricts competing services.
DragonflyDB is compelling when you manage terabytes of in-memory data, when you need millions of operations per second on a single node, or when you want to cut the number of instances required to handle peak load.
Practical comparison
All three are Redis-compatible, but they make very different tradeoffs.
Redis has the most mature ecosystem, the widest tooling support, and enterprise backing. Its threading model is single-threaded at the core with multi-threaded I/O layered on top. Memory usage is efficient but constrained by the original design. It is the safest bet for critical apps that need enterprise support and advanced modules, but the non-OSI license is a real consideration.
Valkey is the fastest-growing option and highly compatible with existing Redis tooling. It keeps the single-threaded core model but improved async I/O, and it saves about 20 bytes per key-value pair. BSD-licensed, true open source. It is the right choice for Redis migrations where open source compliance and cost optimization matter.
DragonflyDB is younger and focused on high-performance use cases. It is the only one with true multi-threading and a shared-nothing design. It delivers 30 to 60% memory savings versus Redis in many scenarios. BSL-licensed, free with restrictions. It targets massive workloads, terabytes of data and millions of ops per second, on a single node.
Spring Boot integration
Here is the good part. All three engines speak the Redis protocol, so from Spring Boot the integration is almost identical.
In your pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>In application.properties (or application.yml), just point to the right host:
# Works the same for Redis, Valkey, and DragonflyDB
spring.data.redis.host=localhost
spring.data.redis.port=6379A cache service looks identical for all three:
@Service
public class CacheService {
@Autowired
private StringRedisTemplate redisTemplate;
public void saveData(String key, String value) {
// Atomic operation in Redis, Valkey, and DragonflyDB
redisTemplate.opsForValue().set(key, value);
}
}As long as your client uses the Redis protocol, switching from Redis to Valkey or DragonflyDB is usually a matter of changing the connection URL and tuning deployment parameters like memory, CPU, and persistence.
How to choose for your project
Start with licensing. If your organization requires OSI-approved open source, Valkey is the obvious choice. If you already have commercial agreements or support with Redis, staying put may be simpler. If you want maximum performance and can accept BSL, DragonflyDB is hard to beat.
Then look at your workload. Moderate loads with a stable ecosystem? Redis is more than enough. Cost per GB in memory is the bottleneck? Valkey and DragonflyDB both lower the bill. Extreme loads on a single node? DragonflyDB is usually the answer.
Finally, check your cloud strategy. See what managed services your provider offers for each engine. Factor in instances, support, storage, and network traffic when you calculate total cost.
The restaurant metaphor
Think of them as restaurants. Redis is the fine-dining spot with 15 years of prestige, the most complete menu, and universal name recognition. Sometimes there is a wait because a single head chef, the main thread, has to coordinate the key dishes.
Valkey is a cooperative started by the original cooks. Same recipes, kitchen redesigned for efficiency, and the door stays free and open.
DragonflyDB is an industrial kitchen with multiple independent stations running in parallel. Built to feed a city from a single building.
Match the restaurant to your budget, your crowd size, and the kind of service you need. The choice between Redis, Valkey, and DragonflyDB gets a lot easier from there.