Home / Blog

Redis 6: A high-speed database, cache, and message broker

Jason Li
Sr. Software Development Engineer
Skilled Angular and .NET developer, team leader for a healthcare insurance company.
July 04, 2020

The thought of Redis as only a cache is out of the picture with the launch of Redis 6. Redis is a BSD licensed open source and functions as a database, cache, message broker, and as an in-memory data structure store that can endure on disk. Redis is a fusion of powerful factors such as high-speed, adaptability, and flexibility. The latest version of Redis features these factors more efficiently.

Redis has replication, Lua scripting, transactions, LRU eviction, and similar levels of on-disk diligence. This feature enables high availability with Redis Sentinel and automated partitioning with the help of Redis Cluster. The key-value database is the core data model supported by Redis. Other data structures supported by Redis are strings, sets, lists, streams, sorted sets with range queries, HyperLogLogs, Hashes, and Bitmaps. It also supports geospatial indexing with streams and queries.

For an open-source Redis, Redis Enterprise enables features that utilize high-speed, reliability, adaptability, and flexibility at the same time it functions as a cloud database as a service. Redis Enterprise escalates directly to a rate of hundreds of millions of operations per second, has an active worldwide distribution with local abeyance, offers services of Redis on Flash to provide support to large datasets within the infrastructure cost of the disk-based database. It also offers optimal (99.999%) uptime that is based on durability that is in-built and with failover time in single-digit-seconds. In addition to that Redis Enterprise broadens the functionality of Redis to provide support any data modeling via modules such as RediSearch, RedisJSON, RedisTimeseries, RedisGraph, And RedisAI. It also the execution of operations within and across core and modules. All these functions with database latency below one millisecond.

Core features and use cases of Redis

The new version of Redis could multifunction as a database, cache, and a message broker.

Cache: Cache is the fundamental and classic purpose of Redis. The basic function of Redis is to save queries and results of a disk-based database. Redis Cache is overlooked first for stored results and questions the disk-based database for results that are currently not available in the cache. This is a massive achievement as an application performance as Redis provides a sub-millisecond response. Other cache features like expiration timers and least recently used (LRU) booting helps to maintain the cache current and to utilize the memory efficiently.

Session store: The session store is one of the most important sectors of modern-day web applications. It is an ideal place to store data associated with the user and her interactions with the application. Using a disk-based database for the session store eliminates the necessity to bind the session to a single web server, but initiate an extra source of latency. Using Redis as a session store often lands in low-latency and high-throughput web application framework.

Message broker: Using three types of mechanisms, Redis could function as a message broker. One of the major use cases for Redis function as a message broker is to function as an adhesive between microservices. Redis possess a low-overhead to subscribe/publish notification mechanism that aids fire-and-forget messages. This will not work while the destination service is not listening to the notification. Redis uses streams that are time-stamp ordered key-value pairs in a single key for a persistent and Kafka-like message queue. It also supports doubly-linked lists of elements that are stored at a single-key, these are useful as a FIFO queue.

The replication feature allows Redis to escalate without utilizing the cluster technology of Redis Enterprise. Redis replication uses a master-slave or leader-follower model that is asynchronous by default. Redis also has a server-side Lua scripting that allows programmers to expand the database without writing client-side code or C modules. Redis holds various levels of on-disk persistence that could be chosen by the user. One could use both RDB and AOP for maximizing the data safety.

Redis Sentinel alone provides high availability for Redis by monitoring master and replica instances, notifications, and failovers. Redis Cluster offers methods to function Redis installation where data is shared automatically across multiple nodes. One of the simplest and common uses of Redis is using the integer values as counters. It is a safe multi-client environment.

Redis Enterprise enhancements

Redis Enterprise delivers infinite linear scaling using a shared-nothing cluster architecture. Redis performs this without imposing any non-linear overheads in a scale-out architecture. With five nines (99.999%) uptime the Enterprise has demonstrated scaling to hundreds of millions of operations per second. Redis do rebalancing and automatic re-sharing while maintaining high throughput and low latency for transactional loads. To take full advantage of multi-core computer architecture, you can now deploy multiple Redis instances on a single cluster node.

Enabling simultaneous write and read operations on the same dataset across multiple geo-locations, Redis Enterprise offers efficient active-active deployment for globally distributed databases. Redis Enterprise can use conflict-free replicated data types (CRDTs) to make functioning more effective. Moreover, it uses CRDTs to maintain the availability and consistency of data. The NoSQL databases of Azure Cosmos DB and Riak also support CRDTs.

Using a mathematically derived set of rules, CRDTs can resolve inconsistencies without intervention. Further, they can use geographically dispersed servers to reduce latency for users and are valuable for high-volume data that require a shared state. One of the main differences between Redis Enterprise and Redis is that Redis Enterprise decouples the data path from cluster management. Multi-threaded proxies reside on each of the cluster nodes and mask the underlying complexity of the system. The data path of Redis Enterprise is based on multiple zero-latency.

The governing function of the cluster manager provides capabilities such as rack-awareness, rebalancing, resharing, resource management, database provisioning, backup, data persistence configuration, auto-failover, and recovery. However, changes to its software components do not affect the data path components since the cluster manager is entirely decoupled from the data path components.

The Redis Enterprise feature of Redis on Flash drastically reduces the cost of hardware for Redis. Frequently accessed hot data can be placed in memory and the colder values in persistent or Flash memory using Redis on Flash. Also, this eliminates the need to restrict the size of your Redis datasets and pay through the nose for terabytes of RAM. Redis Enterprise modules include RedisBloom, RedisGears, RedisGraph, RediSearch, RedisTimeSeries, and RedisJSON. All these modules work with open source Redis.

Redis 6

Major New Features of Redis 6

Both for the Redis Enterprise commercial version and the open-source version, Redis 6 is a big release. Redis 6 gets a 2x improvement in speed over Redis 5 with the use of threaded I/O. Moreover, the addition of access control lists (ACLs) provides Redis 6 with the concept of users and permits the developers to write more secure code. To offer role-based access control (RBAC), Redis Enterprise 6 builds on ACLs. Building on ACLs is more convenient for the DBAs and the programmers. The latest features in Redis 6 includes the following:

Redis Enterprise 6.0

• Hyper Loglog

• Extending active-active

• Streams

• Role-based access control (RBAC)

Redis 6.0 open source

• Improved evictions

• Access control lists (ACLs)

• RESP3 protocol

• Threaded I/O

In active-active databases, Redis Enterprise 6.0 adds support for the Streams data type. That allows both low latency and high availability while concurrently writing and reading to and from a real-time stream in multiple data centers in different geographic locations. The dynamic framework of RedisGears allows the developers to execute and write functions that implement data flow in Redis.

The model serving engine of RedisAI runs inside Redis. This performs inference with TensorFlow, PyTorch, and ONNX models. Besides, it can run on GPUs and CPUs and enables use cases such as personalization, anomaly detection, and fraud detection.

How to Install Redis

Installation of Redis can be done by pulling a Docker image from the Docker Hub or by compiling and downloading a source tarball. macOS, Linux, NetBSD, OpenBSD, and FreeBSD can compile Redis. You can find the source code repository for this on GitHub. You can run Redis on Windows either under Windows Subsystem for Linux (WSL) or in a Docker container.

Moreover, you can install Redis Enterprise in Docker containers or on Linux. These downloads on Linux come in the form of binary packages and Bash shell scripts for a cluster installation. The packages can be either RPM or DEB depending on the flavor of Linux. 15 GB of RAM and four cores are required for the installation of the scripts.

Redis Enterprise Cloud

Running Redis Enterprise in the Redis Enterprise Cloud is the fastest way to install it. The advantages of Redis Enterprise include the following:

• Widely supported among programming languages

• Modules support many data models and functionality extensions

• Enterprise version implements Conflict-free Replicated Data Types (CRDTs)

• Enterprise version improves speed and eases clustering

• The free open-source version has many features

• Enterprise version supports Redis on Flash

To conclude, Redis 6 is an in-memory database structure session store with persistent storage. It functions efficiently as a database, cache, and message broker. Redis on Flash (Redis Enterprise feature) expands RAM with flash memory for cost-worthy support of large databases.