Redis Logo

New in Redis 5.0

 

New: The Stream Data Type

Redis Streams offer an elegant solution to hard messaging problems. Initially sparked by request from an IRC user, and conceptually inspired by Apache™ Kafka, they are a log-like structure designed for storing append-only semi-structured data. Streams combine innovation and the best properties of existing data structures, delivered with the trademark Redis simplicity and performance.

Much like Lists, Streams are an ordered collection of elements called messages. Unlike Lists, however, messages are added exclusively to the end of the Stream, have an internal Hash-like structure for storing the data and a unique sub-second timestamp-based identifier. Streams allow for efficient iteration and paging of their contents, similar to but more efficiently than Sorted Sets, while keeping the order of messages immutable. Blocking read from a stream provides Pub/Sub-like functionality that allows efficient fan-out scaling, while message persistence enables handling transport errors and consumer failures. Time-consuming message processing can be parallelized to scale with Consumer Groups.

For more see https://redis.io/topics/streams-intro

New: The ZPOP Commands Family

As of Redis 5, Sorted Sets support a set of popping operations, that are parallels to those of the List data type. The new `ZPOPMIN` command removes and returns the lowest-ranking member in a Sorted Set, whereas `ZPOPMAX` does the same for the highest. Both commands also have blocking variants, `BZPOPMIN` and `BZPOPMAX` respectively, that are useful for implementing priority queue patterns.

For more see this video from RedisConf 18

New: Cluster, Timers and Dictionary APIs for Modules

After introducing the Redis Modules API in v4, Redis 5 extends it with powerful new capabilities. Developers can use the APIs to build dynamically-loaded libraries that run natively inside Redis to extend it in any imaginable way.

The Cluster API is a foundation for building distributed systems by providing a cluster bus for modules to communicate over. Task scheduling is now much easier with millisecond-resolution timers. The optimized internal Dictionary data structure simplifies development for many modules that rely on external dependencies due to the lack that basic type in ANSI-C.

You can learn more about Redis Labs’ modules here.

New: The LOLWUT Command

Redis introduces a new type of command that answers the question “is it worthwhile to do work that does not produce any technological result?”. In version 5, it outputs works of art in the style of Schotter by Georg Nees’ (https://en.wikipedia.org/wiki/Georg_Nees) using the Braille character set.

Continue reading about LOLWUT at http://antirez.com/news/123.

Changes, Improvements, and Fixes

Performance and Stability

Redis 5’s core was refactored and improved in many ways, to increase its stability and performance. Among these are improvements to the networking layer and client connection handling, a better HyperLogLog implementation contributed by Otmar Ertl, a mathematician from Austria and author of this paper, and faster execution of some commands such as`INFO` and `ZADD`.

A new configuration directive, ‘dynamic-hz`, has been added to provide a better balance between idle CPU usage and responsiveness of the server. The new directive is enabled by default.

Memory Management

Version 5 upgrades its default memory allocator, Jemalloc, to version 5.1. It also includes version 2 of Active Defragmentation that is more efficient and effective. In addition, memory reports of the `INFO` and `MEMORY` commands have been improved and made more accurate.

Persistence

The new version provides better performance when recovering the dataset from persistence. In addition, key-level usage statistics are now also persisted and allow eviction policy consistency in cache use cases.

Replication

Several issues with Redis’ partial replication protocol, PSYNC2, have been resolved, and a new `replica-ignore-maxmemory` configuration directive (enabled by default) has been added. The new directive ensures consistency between master and replicas when eviction is employed and triggered.

As of version 5, the term ‘replica’ is used to refer to the target a replication stream. Adoption of the new term is a long-term effort, and the relevant APIs still support the older term for backward compatibility.

Lua

As of v5, Redis uses script effects replication (introduced in v3.2) by default, obsoleting the need to call `redis.replicate_commands()`. The original mode of script replication is expected to be deprecated in the next version.

In addition, several vulnerabilities in the Lua scripting engine have been addressed and backported, and replicas now respond when in a -BUSY state. Lastly, `INFO`’s output has been augmented to account the RAM usage of the scripts cache.

Sentinel

On top of various issues fixed, Sentinel now supports config rewriting as well as commands that were renamed on Redis instances.

Cluster Administration

The Ruby-based cluster management logic was ported into redis-cli, deprecating the original script (redis-trib.rb). Use it with the new `–cluster` switch, and call `redis-cli –cluster help` for more information.

Connection Administration

The `CLIENT` command has been added with two new subcommands, `UNBLOCK` and `ID`, and its `LIST` subcommand now supports the optional `TYPE` subcommand. These improvements allow greater visibility into connections and more administrative flexibility.

User Experience

Many of Redis commands that support subcommands now provide an integrated `HELP` subcommand, that is especially handy when working with redis-cli.

Community

Version 5 of Open Source Redis has been made possible because of the community that supports it. Other than Redis Labs and its employees, this version, more than ever before, includes many contributions from members and companies that use the project.

Compatibility and Upgrade Considerations

Upgrading from the previous version is straightforward. Version 5 is mostly backward compatible, excluding the following:

  • A new format prevents older Redis versions from reading RDB files
  • Replicas ignore the `maxmemory` setting by default
  • Script effects replication is the default
  • Log entries format have been changed to include a year and have been altered to use new terms

Sunsetting Redis version 3

The release of Redis version 5 marks the beginning of version 3’s sunset. Version 3 will only receive fixes to critical issues and will end its life with the release of version 6 that’s expected in 12-18 months.

Redis Labs plug? If you are looking to upgrade to Redis 5 to take advantage of all the new features please contact our support (support@redislabs.com) for assistance. with upgrading your Redis?