LoginSignup
46
15

More than 5 years have passed since last update.

Redis 5.0 Update解説

Last updated at Posted at 2018-10-18

Redis 5.0 stable リリース

ついに本日(2018/10/18 JST)、redis 5.0のstableがリリースされました。
今までのredisと何が変わったのか?というのを、軽くまとめたいと思います。
間違いなどありましたら、指摘いただけると幸いです。

前回の記事

Redis 4.0の目玉機能解説 - Qiita

Release Notes

一部抜粋すると

The most important user facing improvement is without doubts the introduction of the new general urpose data type after years: the streams.

数年後には新たな一般的なデータ型となるstreamの追加が最も大きな更新とのこと。

Note that we worked to improve and fix streams till a few hours ago, so while we are not aware of critical bugs in this release, surely there is to handle it with some care for the first weeks.

ただ、数時間前まで、stream型の修正を取り込んでいたので、最初の数週間はstream型は気をつけて利用して欲しいとのこと。
バグレポート待ってるよ、といつもの感じですね。

People not using the streams can have probably a better production-ready experience with Redis 5, also because many internals are shared with Redis 4 so the jump is not as big as it was between 3.2 and 4 in terms of how things internally work.

stream型を使わないなら、production readyな体験/改善をredis5は既に提供出来ている。
内部の多くはredis4と変わっておらず、redis3.2からredis4への変更と比較すると大きくない。

とのことなので、stream型で攻めない限りは、redis4 userはアップデートしても大丈夫そうですね。

Update目録

さて、主に取り上げたいUpdateをいくつか抜粋します。
ひとつずつ見ていきます。

  1. The new Stream data type. https://redis.io/topics/streams-intro
  2. New Redis modules APIs: Timers, Cluster and Dictionary APIs.
  3. RDB now store LFU and LRU information.
  4. The cluster manager was ported from Ruby (redis-trib.rb) to C code inside redis-cli. Check redis-cli --cluster help for more info.
  5. New sorted set commands: ZPOPMIN/MAX and blocking variants.
  6. Active defragmentation version 2.
  7. Improvemenets in HyperLogLog implementations.
  8. Better memory reporting capabilities.
  9. Better performances when clients connect and disconnect often.
  10. CLIENT UNBLOCK and CLIENT ID.
  11. The LOLWUT command was added. http://antirez.com/news/123
  12. We no longer use the "slave" word if not for API backward compatibility.
  13. Lua improvements:
    1. Better propagation of Lua scripts to replicas / AOF.
    2. Lua scripts can now timeout and get in -BUSY state in the replica as well.
  14. Big pipelining performances improved significantly
  15. Slaves now ignore maxmemory by default
  16. Add year in log. (WARNING: may be incompatible with log scraping tools)

The new Stream data type.

Redis4リリース前?から騒がれていたstream型がついに入りました。
詳細な説明は下記を参照ください。
https://redis.io/topics/streams-intro
Redisストリームを使ったリアルタイムのチャット - Qiita

また、kafkaとの差別化ですが、下記によると、kafkaはスケーラビリティが高く素晴らしい設計だが、多くの解決したい課題に対して、kafka自体が複雑すぎるという点があり、
そこまで大規模である必要がないのであれば、redis程度のシンプルさで実現出来た方が嬉しい、ということのようですね。
https://hackernoon.com/introduction-to-redis-streams-133f1c375cd3

New Redis modules APIs: Timers, Cluster and Dictionary APIs.

Redis ModuleのためのAPIが増えました。
今後もModuleで実現出来る機能が増えていきそうです。
https://redis.io/topics/modules-api-ref
https://redis.io/modules

少し話題がそれますが、一部のRedis Moduleのライセンスが8月に変更になりました。
https://redislabs.com/blog/redis-license-bsd-will-remain-bsd/

クラウドプロバイダに対する制限を目的としているもので、今後AWSやGCPなどでRedis Moduleを利用した拡張機能は提供されないかもしれません。
※もちろんAWSやGCPがModuleを開発すれば可能です

RDB now store LFU and LRU information.

データをフルダンプするファイル永続化のRDBに、LFUやLRUの情報も含まれるようになりました。
LFUやLRUは、メモリが溢れた際にどのデータから追い出すか?といったevictionに利用されるもので
これがRDBに含まれたことによって、永続化ファイルから復元された直後から、正確にevictionによる判定が行われることが期待されます。

一方追記型でデータを保存するAOFでは含まれていないので、RDB vs AOFの判断基準がまた増えてしまったことになりますね。
https://redis.io/topics/persistence

The cluster manager was ported from Ruby (redis-trib.rb) to C code inside redis-cli. Check redis-cli --cluster help for more info.

Redis Clusterを構築したり、オペレーションのために利用されていた公式Rubyスクリプトがついにredis-cliに取り込まれました。
また、redis-trib.rbはパスワード付きのRedis Clusterに対応してませんでしたが、
redis-cli --clusterは対応しているようです。
今までredis-trib.rbにパッチを当ててパスワード付きに対応していたので嬉しいです。

New sorted set commands: ZPOPMIN/MAX and blocking variants.

ついにソート済みセット型に、maxとminをpopするコマンドが増えました。
https://redis.io/commands/zpopmin
https://redis.io/commands/zpopmax

以前にLINEのエンジニアブログで紹介されたsorted setを利用したqueue実装にも役立ちそうな気がしますね。
RedisのSorted Setsで簡易的な遅延実行Queueを作って迅速にLINE LIVEのPC配信対応をリリースした話 : LINE Engineering Blog

Active defragmentation version 2.

Redis4でexperimentalとしてリリースされた機能がはやくも、version 2となったようです。

Improvemenets in HyperLogLog implementations.

異なり数を少メモリでカウント出来るHyperLogLogが改良されました。
リアルタイムなUU数などを見るのに使えるやつですね。

下記のアルゴリズムに変更されたようです。気になる方はご確認ください。
https://arxiv.org/abs/1702.01284

Better memory reporting capabilities.

Redis4から入った、Memoryのレポート機能が改善されたようです。
https://redis.io/commands/memory-doctor
https://redis.io/commands/memory-malloc-stats
https://redis.io/commands/memory-purge
https://redis.io/commands/memory-stats
https://redis.io/commands/memory-usage

Better performances when clients connect and disconnect often.

クライアントからのConnectionの接続/切断のパフォーマンスが上がったとのこと。
これはFaaSなどで都度接続をしているようなケースでは大きな改善かもしれません。

CLIENT UNBLOCK and CLIENT ID.

CLIENT UNBLOCK コマンドが増え、またそのコマンドを利用するためにCLIENT IDコマンドも増えました。
https://redis.io/commands/client-id
https://redis.io/commands/client-unblock

今回追加されたstream型のXREADや、以前からあったWAITやBRPOPなど、Clientをブロックする類のコネクションを、別のコネクションからUNBLOCKすることで開放できるようになりました。

The LOLWUT command was added.

お茶目なjoke機能が入りました。コンピューターアートです。
ぜひ、下記antirezの記事をご覧ください。

http://antirez.com/news/123 から引用

LOLWUT is also going to be a tradition starting from Redis 5. At each new major version of Redis what the command does will change completely, only a set of rules will be fixed:

  1. It can’t do anything technologically useful.
  2. It should be fast at doing what it does, so that it is safe to call LOLWUT on production instances.
  3. The output should be entertaining in some way.

redis5から始まる伝統となる。
何も技術的に役に立つことはない。
productionで実行しても高速で安全である。
出力は面白く。

We no longer use the "slave" word if not for API backward compatibility

slave(奴隷)という単語をAPI互換性で問題ない部分では使わなくなったとのこと。
時代を感じます。

Lua improvements

  1. Better propagation of Lua scripts to replicas / AOF.
  2. Lua scripts can now timeout and get in -BUSY state in the replica as well.

今までlua scriptingは、そのスクリプト実行のコマンド自体をレプリカに伝搬し、AOFファイル永続化にもwriteしていました。
これはつまり、luaスクリプトがslaveやAOFから復元されたRedisでも実行され、結果が異なることがあり得ました。

Redis5からは、masterでluaスクリプトが実行された際のその副作用が伝搬されるようになります。
つまりmasterと結果が異なることがなくなりました。

Big pipelining performances improved significantly

元々高速化のためにある機能ですが、pipeliningを使った際のパフォーマンスが大きく向上したとのことです。

Slaves now ignore maxmemory by default

BREAKING CHANGEです。
今までは各redis instanceに設定されていたmaxmemoryに応じて、evictimなどのアルゴリズムが発動していました。
これはつまり、slaveを含むすべてのmaxmemory設定を同じにしないと、異なるタイミングでメモリ溢れが発生していたということになります。

Redis5からは、masterのmaxmemory設定がslaveに伝搬されて上書きされるようになります。
そのため、slaveでのmaxmemory設定の値は無視されます。

Add year in log.

WARNING: may be incompatible with log scraping tools
Redisのlogフォーマットが若干変わります。
logフォーマットで正規表現をかけて監視などをしていた場合は修正が必要になるかもしれません。


以上、良きRedisライフを。

46
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
46
15