Redis 6.0 正式版终于发布了!除了多线程还有什么新功能?
這是我的第 56 篇原創(chuàng)文章
Redis 6.0.1 于 2020 年 5 月 2 日正式發(fā)布了,如 Redis 作者 antirez 所說,這是迄今為止最“企業(yè)”化的版本,也是有史以來改動(dòng)最大的一個(gè) Redis 版本,同時(shí)也是參與開發(fā)人數(shù)最多的一個(gè)版本。
所以在使用此版本之前,建議各位開發(fā)者先進(jìn)行深入的測(cè)試再考慮投產(chǎn),畢竟生產(chǎn)壞境無小事。好了,回到本文的重點(diǎn),接下來我們來重點(diǎn)看下 Redis 6.0.1 給我們帶來了那些新功能。
Redis新功能介紹
Redis 6 的更新日志,主要包含以下五部分的內(nèi)容:
Redis 6.0-RC1 版新功能介紹;
Redis 6.0-RC2 版新功能介紹;
Redis 6.0-RC3 版新功能介紹;
Redis 6.0-RC4 版新功能介紹;
Redis 6.0.0 GA 版新功能介紹。
除了以上這些版本的更新日志外,還有 6.0.1 正式版的更新日志,不過這個(gè)正式版的發(fā)布時(shí)間只比 Redis 6.0.0 GA 晚了兩天,因此只修復(fù)了一些 bug,所以我們只需要看以上五個(gè)日志即可。
1.Redis 6.0-rc1 更新日志
官方更新日志如下:
Redis 6 improves Redis in a number of key areas and is one of the largest Redis releases in the history of the project, so here we'll list only the biggest features in this release:
The modules system now has a number of new APIs that allow module authors ? to make things otherwise not possible in the past. It is possible to ? store arbitrary module private data in RDB files, to hook on different ? server events, capture and rewrite commands executions, block clients on ? keys, and so forth.
The Redis active expire cycle was rewritten for much faster eviction of keys ? that are already expired. Now the effort is tunable.
Redis now supports SSL on all channels.
ACL support, you can define users that can run only certain commands and/or ? can only access only certain keys patterns.
Redis now supports a new protocol called RESP3, which returns more ? semantical replies: new clients using this protocol can understand just ? from the reply what type to return to the calling program.
There is server-side support for client-side caching of key values. This ? feature is still experimental and will get more changes during the next ? release candidates, but you can already test it and read about it here: ? https://redis.io/topics/client-side-caching
Redis can now optionally use threads to handle I/O, allowing to serve ? 2 times as much operations per second in a single instance when ? pipelining cannot be used.
Diskless replication is now supported even on replicas: a replica is now ? able, under certain conditions the user can configure, to load the RDB ? in the first synchronization directly from the socket to the memory.
Redis-benchmark now supports a Redis Cluster mode.
SRANDMEMBER and similar commands have a better distribution.
Redis-cli improvements.
Systemd support rewritten.
A Redis Cluster proxy was released here: ? https://github.com/artix75/redis-cluster-proxy
A Disque module for Redis was released here: ? https://github.com/antirez/disque-module
此版本新增的內(nèi)容最大,如下列表所示:
眾多新模塊(modules)API
更好的過期循環(huán)(expire cycle)
SSL
ACLs 權(quán)限控制
RESP3 協(xié)議
客戶端緩存(Client side caching)
多線程 IO(Threaded I/O)
無盤復(fù)制副本(Diskless replication on replicas)
Redis-benchmark 的集群支持和 redis-cli 優(yōu)化
重寫 Systemd 支持(Systemd support rewrite)
Redis 集群代理與 Redis 6 一同發(fā)布(但在不同的 repo)
Disque 模塊與 Redis 6 一同發(fā)布
2.Redis 6.0-rc2 更新日志
Hi Redis users, Redis 6 is approaching and will be released 30th of April. New release candidates will be released at the end of March, then another one mid April, to finally reach the GA at the end of April.
Redis 6 RC2 brings many fixes and new things, especially in the area of client side caching. This is the list of big changes in this release. As usually you can find the full list of commits at the end:
New features and improvements:
ACL LOG: log denied commands, keys accesses and authentications.
Client side caching redesigned. Now we use keys not caching slots.
Client side caching: Broadcasting mode implemented.
Client side caching: OPTIN/OPTOUT modes implemented.
Remove RDB files used for replication in persistence-less instances (option).
Fixes (only selected ones, see commits for all the fixes):
Different fixes to streams in edge cases.
Fix duplicated CLIENT SETNAME reply because of RESP3 changes.
Fix crash due to new active expire division by zero.
Avoid sentinel changes promoted_slave to be its own replica.
Fix bug on KEYS command where pattern starts with * followed by \x00.
Threaded I/O: now the main thread is used as well to do I/O.
Many fixes to modules APIs, and more to come in the next RCs.
ld2string should fail if string contains \0 in the middle.
Make the Redis test more reliable.
Fix SPOP returning nil (see #4709). WARNING: API change.
Redis 6 RC2 帶來了許多修復(fù)和新功能,尤其是客戶端的緩存功能,此版本的重大更改如下列表。
ACL LOG:記錄拒絕的命令,密鑰訪問和身份驗(yàn)證。
重新設(shè)計(jì)了客戶端緩存。現(xiàn)在,我們使用密鑰而不是緩存插槽。
客戶端緩存:已實(shí)現(xiàn)廣播模式。
客戶端緩存:已實(shí)現(xiàn) OPTIN/OPTOUT 模式。
刪除用于在非持久性實(shí)例中進(jìn)行復(fù)制的 RDB 文件(可選)。
修復(fù)程序(僅選定的修復(fù)程序,請(qǐng)參閱所有修復(fù)程序的提交):
在邊緣情況下對(duì)流的不同修復(fù)。
修正由于 RESP3 更改而導(dǎo)致重復(fù)的 CLIENT SETNAME 答復(fù)。
修正因新的有效到期除以零而導(dǎo)致的崩潰。
避免將哨兵更改提升為自己的副本。
修復(fù)了 KEYS 命令中以 * 開頭,后跟 \x00 的錯(cuò)誤。
線程 I/O:現(xiàn)在也使用主線程來執(zhí)行 I/O。
對(duì)模塊API進(jìn)行了許多修復(fù),而在下一個(gè)RC中還會(huì)有更多修復(fù)。
如果字符串中間包含 \0,則 ld2string 應(yīng)該失敗。
使 Redis 測(cè)試更可靠。
3.Redis 6.0-rc3 更新日志
Dear users, this is a list of the major changes in this release, please check? the list of commits for detail:
Fix crash due to refactoring for SSL, for the connection code.
Precise timeouts for blocking commands. Now the timeouts have HZ ? resolution regardless of the number of connected clinets. New timeouts ? are stored in a radix tree and sorted by expire time.
Fix rare crash when resizing the event loop because of CONFIG maxclients.
Fix systemd readiness after successful partial resync.
Redis-cli ask password mode to be prompted at startup (for additional safety).
Keyspace notifications added to MIGRATE / RESTORE.
Threaded I/O bugs fixed.
Implement new ACL style AUTH in Sentinel.
Make 'requirepass' more backward compatible with Redis <= 5.
ACL: Handle default user as disabled if it's off regardless of "nopass".
Fix a potential inconsistency when upgrading an instance in Redis Cluster ? and restarting it. The instance will act as a replica but will actually be ? set as a master immediately. However the choice of what to do with already ? expired keys, on loading, was made from the POV of replicas.
Abort transactions after -READONLY error.
Many different fixes to module APIs.
BITFIELD_RO added to call the command on read only replicas.
PSYNC2: meaningful offset implementation. Allow the disconnected master ? that is still sending PINGs to replicas, to be able to successfully ? PSYNC incrementally to new slaves, discarding the last part of the ? replication backlog consisting only of PINGs.
Fix pipelined MULTI/EXEC during Lua scripts are in BUSY state.
Re-fix propagation API in modules, broken again after other changes.
這個(gè)版本主要是修復(fù)了一些 bug,如下列表所示:
修復(fù)了由于重構(gòu) SSL 而導(dǎo)致的連接代碼崩潰。
用于阻止命令的精確超時(shí)。現(xiàn)在超時(shí)已達(dá)到 HZ 分辨率,無論連接的 clinet 數(shù)量如何。新超時(shí)存儲(chǔ)在基數(shù)樹中并按到期時(shí)間排序。
修復(fù)了由于 CONFIG maxclients 而調(diào)整事件循環(huán)大小時(shí)發(fā)生的罕見崩潰。
修正部分重新同步成功后的 systemd 準(zhǔn)備情況。
Redis-cli 詢問密碼模式將在啟動(dòng)時(shí)提示(以提高安全性)。
鍵空間通知已添加到 MIGRATE/RESTORE。
修復(fù)了線程 I/O 錯(cuò)誤。
在 Sentinel 中實(shí)現(xiàn)新的 ACL 樣式 AUTH。
使 'requirepass' 與 Redis<=5 更向后兼容。
ACL:如果默認(rèn)用戶關(guān)閉,則將其視為禁用狀態(tài),而不管其是否為“ nopass”。
修復(fù)了在 Redis 群集中升級(jí)實(shí)例時(shí)可能出現(xiàn)的不一致問題
-READONLY 錯(cuò)誤后中止事務(wù)。
對(duì)模塊 API 的許多不同修復(fù)。
添加了 BITFIELD_RO 以在只讀副本上調(diào)用該命令。
PSYNC2:有意義的偏移量實(shí)現(xiàn)。允許斷開連接的主機(jī)仍在向副本發(fā)送 PING,以便能夠成功 PSYNC 以增量方式傳遞給新的從站,從而丟棄了僅由 PING 組成的復(fù)制積壓。
修正 Lua 腳本處于繁忙狀態(tài)時(shí)流水線的 MULTI/EXEC。
重新修復(fù)模塊中的傳播 API,在其他更改后再次中斷。
4.Redis 6.0-rc4 更新日志
Hi all, this the latest release candidate of Redis 6. This is likely to be very similar to what you'll see in Redis 6 GA. Please test it and report any issue :-)
Main changes in this release:
* Big INFO speedup when using a lot of of clients. ? ? * Big speedup on all the blocking commands: now blocking ? ? ? on the same key is O(1) instead of being O(N). ? ? * Stale replicas now allow MULTI/EXEC. ? ? * New command: LCS (Longest Common Subsequence). ? ? * Add a new configuration to make DEL like UNLINK. ? ? * RDB loading speedup. ? ? * Many bugs fixed (see the commit messages at the end of this node)
此版本主要新增的內(nèi)容如下:
提高了大量客戶端連接時(shí)使用 INFO 命令的查詢速度。
在所有阻止命令上都大大加快了速度:現(xiàn)在可以阻止在同一鍵上是 O(1)而不是 O(N)。
陳舊的副本現(xiàn)在允許 MULTI/EXEC。
新命令:LCS(最長公共子序列)。
添加新配置以使 DEL 像 UNLINK。
RDB 加載加速。
修復(fù)了許多錯(cuò)誤。
5.Redis 6.0.0 GA 更新日志
Upgrade urgency CRITICAL: many bugs fixed compared to the last release ? ? ? ? ? ? ? ? ? ? ? ? ? candidate. Better to upgrade if you see things ? ? ? ? ? ? ? ? ? ? ? ? ? affecting your environment in the changelog.
Hi all, finally we have Redis 6.0.0 GA! Enjoy this new Redis release. Most of the documentation was updated today so that you can likely find what you are looking for about the new features at redis.io. This is the list of what changed compared to the previoius release candidate:
XCLAIM AOF/replicas propagation fixed.
Client side caching: new NOLOOP option to avoid getting notified about ? changes performed by ourselves.
ACL GENPASS now uses HMAC-SHA256 and have an optional "bits" argument. ? It means you can use it as a general purpose "secure random strings" ? primitive!
Cluster "SLOTS" subcommand memory optimization.
The LCS command is now a subcommand of STRALGO.
Meaningful offset for replicas as well. More successful partial ? resynchronizations.
Optimize memory usage of deferred replies.
Faster CRC64 algorithm for faster RDB loading.
XINFO STREAM FULL, a new subcommand to get the whole stream state.
CLIENT KILL USER.
MIGRATE AUTH2 option, for ACL style authentication support.
Other random bugfixes.
此日志更新的主要內(nèi)容如下:
XCLAIM AOF/replicas 傳播已修復(fù)。
客戶端緩存:新的 NOLOOP 選項(xiàng)以避免收到有關(guān)自己執(zhí)行的更改。
ACL GENPASS 現(xiàn)在使用 HMAC-SHA256,并具有一個(gè)可選的“位”參數(shù)。這意味著您可以將其用作通用的“安全隨機(jī)字符串”原始!
群集“SLOTS”子命令的內(nèi)存優(yōu)化。
LCS 命令現(xiàn)在是 STRALGO 的子命令。
副本的有意義的偏移量。更成功的部分重新同步。
優(yōu)化延遲回復(fù)的內(nèi)存使用。
更快的 CRC64 法可更快地加載 RDB。
XINFO STREAM FULL,一個(gè)新的子命令,用于獲取整個(gè)流狀態(tài)。
CLIENT KILL USER <用戶名>。
MIGRATE AUTH2 選項(xiàng),用于 ACL 樣式身份驗(yàn)證支持。
修正了一些其他錯(cuò)誤。
Redis 6.0.1 正式版的下載地址為:https://redis.io/
官方的更新日志(英文):https://raw.githubusercontent.com/antirez/redis/6.0/00-RELEASENOTES
總結(jié)
綜合以上所有版本的更新日志,我們發(fā)現(xiàn)這次 Redis 6.0 帶來的主要功能是:
提供了眾多的新模塊(modules)API
提供了客戶端緩存功能
多線程 I/O 能力
提升了 RDB 日志的加載速度
修改了若干個(gè) bug 和一些優(yōu)化
其中多線程 I/O 是我們最關(guān)注的功能了,有人用它和單線程的版本做了一個(gè)性能測(cè)試,如下圖所示:
(注:圖片來源于 iTushou.com)
從以上結(jié)果可以看到 GET/SET 命令在多線程版本中的性能相比單線程已經(jīng)翻倍了。
總體來說,此次 Redis 6.0 帶給我們的功能還是很多且比較實(shí)用的,只是版本改動(dòng)很大,因此我們需要一定的時(shí)間和大量的測(cè)試驗(yàn)證之后才建議上線。
最后的話
原創(chuàng)不易,如果覺得本文對(duì)你有用,請(qǐng)隨手點(diǎn)擊一個(gè)「在看」,這是對(duì)作者最大的支持與鼓勵(lì),謝謝你。
參考 & 鳴謝
Redis 官方文檔
別再問我 new 字符串創(chuàng)建了幾個(gè)對(duì)象了!我來證明給你看!
String性能提升10倍的幾個(gè)方法!(源碼+原理分析)
關(guān)注公眾號(hào)發(fā)送”進(jìn)群“,老王拉你進(jìn)讀者群。
總結(jié)
以上是生活随笔為你收集整理的Redis 6.0 正式版终于发布了!除了多线程还有什么新功能?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 集合使用与内部实现原理
- 下一篇: 一个多月的时间,终于把这件事做完了!