Over the last decade, Redis has become a popular, widely used in-memory cache. Unlike most distributed caches, it offers a compelling set of built-in data structures that enhance its capabilities beyond just storing serialized objects.
Created in 2009 as a single-server store to assist in the design of a web server, Redis gives applications numerous useful options for organizing and retrieving stored data, including sets, lists, hashes, and sorted sets. A few years later, it later added cluster support to scale throughput and add data replication for high availability. However, Redis’s cluster implementation introduced specialized concepts, like hashslots and master/replica shards, that system administrators must understand and manage. Along with Redis’ use of eventual rather than full consistency, these concepts have created complexity that makes cluster management more challenging while reducing flexibility and reliability.
In contrast, ScaleOut StateServer®, an enterprise-focused distributed cache for serialized objects first released in 2005, was designed from the ground up to run on a server cluster with the specific design goals of high performance and reliable data storage while maximizing ease of use. It automates load-balancing, data replication, and recovery and stores data with full consistency (i.e., sequential consistency) across replicas. It also executes client requests using all available processing cores for maximum throughput. These features dramatically simplify cluster management, improve flexibility, and lower TCO, especially for enterprise users. For example, unlike Redis, ScaleOut server clusters can seamlessly grow from a single server to multiple servers, and system administrators do not need to manage hashslots or primary/replica shards.
The Challenge: Integrating Redis Command Processing into a New Clustering Architecture
ScaleOut Software recognized that running Redis commands on a ScaleOut StateServer cluster would offer Redis users the best of both worlds: familiar and rich data structures combined with significantly simpler cluster management and full data consistency. However, the ideal implementation would need to use actual Redis open-source code to execute Redis commands so that client commands would behave identically to open-source Redis clusters. The challenge was then to integrate Redis code into ScaleOut StateServer’s execution platform and take advantage of its highly automated clustering features while eliminating the single-threaded constraints of Redis’s event-loop architecture.
The company recently accomplished this integration and, in ScaleOut StateServer version 5.11, released a community preview that introduces support for the most popular Redis data structures (strings, sets, lists, hashes, and sorted sets) plus publish/subscribe commands, transactions, and various utility commands (such as FLUSHDB and EXPIRE) on both Windows and Linux. It uses open-source Redis version 6.2.5 code within the servers to process Redis commands.
Automated Cluster Operations, Scalable Throughput and Full Data Consistency
With this integration, Redis clients can connect to a ScaleOut StateServer cluster of one or more servers using the standard Redis RESP protocol. Redis client libraries obtain the mapping of hashslots to servers by internally calling either the CLUSTER SLOTS or CLUSTER NODES commands and then directing Redis access requests to the appropriate ScaleOut server. When the cluster membership changes, Redis clients automatically use the RESP protocol to redirect commands to the correct servers.
To maximize throughput, each ScaleOut server processes incoming Redis commands on multiple threads using all available processor cores. There is no need to deploy multiple shards on each server to scale performance or provide data replication; these functions are implemented within one process on each server.
As the need for additional throughput grows, system administrators can simply join new servers to the cluster. ScaleOut StateServer automatically rebalances the hashslots across the cluster as servers are added or removed. It also delays the execution of Redis commands during load-balancing (and recovery) to maintain a consistent picture of hashslot placement and avoid client exceptions. After a hashslot has fully migrated to a remote server, client requests return a -MOVED indication so that they can be redirected to the new server.
Additionally, ScaleOut StateServer automatically creates replicas for all hashslots. There is no need to manually create primary and replica shards or move them from server to server during membership changes and recovery. ScaleOut StateServer automatically places replica hashslots on different servers from their corresponding primary hashslots and migrates them as necessary during membership changes to ensure optimal load-balancing. If a server fails or has a network outage, ScaleOut StateServer “self-heals” by promoting replicas to primaries and creating new replicas as necessary.
Redis uses an eventual consistency model for updating replicas. Although this model is fast, it is susceptible to serving stale data to clients if a server fails or a network outage occurs. To avoid this problem, ScaleOut StateServer implements fully consistent updates to stored objects using a patented quorum algorithm. When a server receives a Redis command, it completes execution of the command on a quorum containing the primary hashslot and its replicas prior to returning to the client. Transactions are processed in the same manner.
Summing Up: New Capabilities for Redis Users
ScaleOut Software’s innovative integration of Redis open-source code into its cluster architecture will bring powerful new capabilities to Redis users while ensuring native-Redis behavior for client applications. Enterprise users now have a simpler way to manage Redis clusters with automated cluster management and built-in throughput scaling, and they benefit from fully consistent updates to stored data performed by Redis commands. They also can gain access to ScaleOut StateServer’s native APIs, which incorporate advanced features not available on open-source Redis clusters, including data-parallel computing, streaming analytics, and coherent, wide-area data replication.
Editor’s note: This article is in association with ScaleOut Software.