When it comes to selecting a fast, scalable, and reliable key-value store solution, Redis has long been the go-to choice for many. However, a new player has entered the scene, offering a compelling alternative - cachegrand. Both Redis and cachegrand are open-source solutions compatible with the Redis protocol, thus ensuring seamless integration with various applications and frameworks. This article aims to highlight the comparisons between Redis and cachegrand, emphasizing how cachegrand could potentially serve as a superior alternative for your business.
Key-Value Stores: unraveling the basics
Before delving into the comparison of Redis and cachegrand, it is essential to understand what a key-value store is. A key-value store, also known as a key-value database or key-value storage, is a type of non-relational database that uses a simple key-value method to store data.
In a key-value store, each data item is stored as an attribute name, or key, together with its value. This offers a highly efficient method for storing, retrieving, and managing unstructured data. The structure of a key-value store makes it highly scalable and quick for read/write operations, especially for large volumes of data.
Key-value stores are flexible and are often used for caching, session management, and serving real-time data. They can handle large amounts of data and heavy load with ease. However, they lack the complex querying capabilities of relational databases, making them unsuitable for some types of applications.
Key-value stores have become increasingly popular due to the rise of big data and the need for more flexible, scalable, and performance-oriented solutions. Redis and cachegrand are two examples of key-value stores, each with its own strengths and unique features.
Redis: the established player
Redis enjoys immense popularity in the realm of key-value stores. It boasts an extensive and active community of developers and users, and provides a comprehensive suite of data structures, including strings, lists, sets, hashes, bitmaps, and streams. Redis supports multiple functionalities, such as transactions, replication, clustering, pub/sub messaging, Lua scripting, and modules for extending its capabilities.
Designed to operate in memory, Redis delivers swift responsiveness. However, this design choice also introduces limitations regarding data size and persistence. While Redis can persist data to disk using snapshots or append-only files (AOF), this can potentially impact its performance and reliability. Furthermore, Redis's data storage is bound by the available memory on the server, which can be restrictive and costly for large-scale applications.
cachegrand: the effective alternative
Enter cachegrand, a robust key-value store designed to leverage modern hardware capabilities, particularly flash memories, multi-core processorsm etc.. Offering compatibility with the Redis protocol, cachegrand promises enhanced performance, scalability, and efficiency, thereby emerging as a promising alternative to Redis.
cachegrand's modular architecture supports various protocols and platforms, such as Redis and Prometheus with Memcache, AWS S3, and more planned to be added. Its time-series database feature ensures rapid data writes and retrievals, making it suitable for a wide range of use-cases typically addressed by Redis. It also employs a lock-free and wait-free hashtable implementation for the database index, capable of processing billions of index queries per second with minimal latency.
A key advantage of cachegrand lies in its design to run on flash memories, enabling it to store more data at a lower cost compared to Redis. cachegrand's ability to harness the high IOPS of modern NVMe drives and SSDs contributes to high throughput and low latency, while its log-structured append-only sharded database approach for data persistence boosts space efficiency and minimizes write amplification.
While cachegrand currently doesn't support all the Redis commands, it's under active development to incorporate full compatibility. Nonetheless, it already supports many of the most commonly used commands, making it suitable for a range of applications.
cachegrand vs Redis: the benchmark
Benchmark tests using an AMD EPYC 7502P processor with 2 x 25Gbit network links and Ubuntu 22.04 reveal significant performance improvements of cachegrand over Redis. Tests conducted with memtier_benchmark involving 10M different keys, 128 bytes of payload, and 3200 clients emulated (50 clients per thread, 32 threads) yielded the following results:
Clearly, cachegrand surpasses Redis in both GET and SET operations, demonstrating its ability to handle greater load and deliver faster responses. Importantly, cachegrand exhibits almost linear scalability with the number of cores, a significant advantage over Redis.
The disparity between Redis and Cachegrand becomes even more pronounced when utilizing pipelining. By batching commands, Cachegrand effectively minimizes the latency introduced by the network stack to an absolute minimum, facilitating improved outcomes.
The table below presents the comparison using pipelining:
These results clearly indicate that Cachegrand, when leveraging pipelining, outperforms Redis by a considerable margin in both GET and SET operations.
Cachegrand also shines when it comes to latency. Impressively, Cachegrand can reduce latencies to as low as 0.35ms at P99 for both GET and SET operations, on the other hand, Redis is at 0.6ms at P99.
Again, these distinctions emphasize Cachegrand's exceptional ability to manage high-volume loads and provide quicker responses across a variety of applications. These features solidify its position as a compelling alternative in the realm of key-value store solutions.
Choosing between Redis and cachegrand
The choice between Redis and cachegrand hinges on your specific needs and use-cases. While Redis offers proven solutions with a rich feature set, cachegrand, now production-ready, emerges as an innovative and efficient alternative that promises better performance and scalability.
One of cachegrand's key advantages is its compatibility with the Redis protocol. This means that applications currently utilizing Redis can switch to cachegrand without requiring any modifications, if they are using supported commands, making the transition effortless. Not only does this compatibility make cachegrand a direct drop-in replacement for Redis, but it also extends its utility to encompass all use-cases that Redis is traditionally known for.
Moreover, cachegrand's support for flash memories offers a more cost-effective solution than Redis, especially for large-scale applications. Businesses can now store more data without incurring the high costs associated with expanding RAM, as is the case with Redis, which provides flash disks support only through its paid solution, Redis Enterprise.
In conclusion, while Redis remains a reliable and well-established player in the key-value store domain, cachegrand, with its advanced features, compatibility, and superior performance, has emerged as a compelling alternative. Ultimately, the choice between Redis and cachegrand will depend on your specific needs and objectives. However, cachegrand's potential as a highly capable, efficient, and cost-effective solution makes it a strong contender for the key-value store of choice for businesses of all scales.
Give cachegrand a try!
If you're intrigued by Cachegrand's capabilities and are interested in testing it out, it's as simple as running a Docker command. Thanks to Docker, you can easily run Cachegrand in a containerized environment, allowing you to evaluate its features without affecting your existing setup. To give Cachegrand a spin, simply execute the following Docker command:
docker run \ --ulimit memlock=-1:-1 \ --ulimit nofile=262144:262144 \ -p 6379:6379 \ -p 6380:6380 \ -p 9090:9090 \ -it \ --rm \ cachegrand/cachegrand-server:latest
This command will pull the latest Cachegrand server image and run it in a Docker container, binding the necessary ports and setting the appropriate ulimits. With this, you're all set to explore Cachegrand and see how it could be a game-changer for your data storage needs.
More information available on the cachegrand repository on github.