轉眼間Redis已經走過了十個年頭,久到它的作者Antires已經棄坑不再維護Redis源代碼了。在我們查看Redis6.0新特性前先來回顧下Redis歷史版本的歷程。
由於篇幅問題,下圖僅列舉了部分我認為比較重要的特性(注:Codis2和Codis3分別基於2.8、3.2,並不屬於Redis特性)
特性的詳細細節在此不贅述,我們來看Redis6.0,。Redis6.0版本特性大約可以分為四類,如下表
新特性
|
內核優化
|
應用優化
|
其他
|
ACL權限管控(包括ACL LOG)
|
過期Key回收優化,新增主動配置參數
|
新的module API
|
全面支持SSL協議、並新增TSL協議
|
客戶端緩沖(Client side caching)
|
Resp3協議,兼容Resp2並更加簡單、高效
|
disque消息隊列模塊(module)
|
Redis-benchmark支持集群模式
|
多線程 IO(Threaded I/O)
|
優化了INFO命令,使之執行更快
|
新增配置使Del命令如unlink執行
|
重寫 Systemd 支持
|
Redis集群代理
|
優化了所有的阻塞命令,復雜度從O(n)到O(1)
|
XINFO STREAM FULL流命令
|
新增配置參數來刪除用於在非持久性實例中進行復制的RDB文件
|
支持linux/bsd系統的CPU和線程(包括子線程如aof\rdb\IO線程)親和力綁定
|
RDB加載速度優化
|
CLIENT KILL USER username命令
|
無磁盤復制副本(Diskless replication on replicas),從測試版優化,目前無磁盤復制在load rdb仍是測試版。
|
|
集群Slots命令優化
|
|
|
|
Psync2優化,修復了5.0的鏈式復制不一致問題。
|
|
|
|
defrag優化,從試驗版到正式版
|
|
|
詳細的版本細節我簡略的翻譯了些,原文可查看GitHub文檔。
6.0.4
* PSYNC2 tests improved.
* Fix a rare active defrag edge case bug leading to stagnation
* Fix Redis 6 asserting at startup in 32 bit systems.
* Redis 6 32 bit is now added back to our testing environments.
* Fix server crash for STRALGO command,
* Implement sendfile for RDB transfer.
* TLS fixes.
* Make replication more resistant by disconnecting the master if we
detect a protocol error. Basically we no longer accept inline protocol
from the master.
* Other improvements in the tests.
1、PSYNC2測試得到了改進。
2、修復了一個罕見的活躍的碎片整理邊緣情況導致停滯的錯誤
3、修復32位系統啟動時的redis6斷言。
4、Redis6 32位現在添加回我們的測試環境。
5、修復服務器崩潰STRALGO命令,
6、實現RDB數據傳輸。
7、TLS修復。
8、如果檢測協議錯誤,將通過斷開主服務器來增強復制的抵抗力。基本上我們不再接受內聯協議從主。
9、測試的其他改進。
6.0.2
* XPENDING should not update consumer's seen-time
* optimize memory usage of deferred replies - fixed
* Fix CRC64 initialization outside the Redis server itself.
* stringmatchlen() should not expect null terminated strings.
* Cluster nodes availability checks improved when there is
high Pub/Sub load on the cluster bus.
* Redis Benchmark: Fix coredump because of double free
* Tracking: send eviction messages when evicting entries.
* rax.c updated from upstream antirez/rax.
* fix redis 6.0 not freeing closed connections during loading.
New features:
* Support setcpuaffinity on linux/bsd
* Client Side Caching: Add Tracking Prefix Number Stats in Server Info
* Add --user argument to redis-benchmark.c (ACL)
1、修復了XPENDING不應該更新用戶的查看時間bug
2、優化延遲回復的內存使用
3、修復了Redis服務器本身外部的CRC64初始化。
4、修復了stringmatchlen()不應該期望null結尾的字符串。
6、集群節點可用性檢查有所改善
7、集群總線上的高發布/訂閱負載。
8、Redis benchmark:修復核心ump因為雙免費
9、跟蹤:發送驅逐消息時,驅逐條目。
10、從上游antirez/rax更新的rax.c。
11、修正了redis6.0在加載過程中沒有釋放關閉的連接。
12、支持linux/bsd系統上cpu親和力綁定(setcpuaffinity)
13、客戶端緩存:在服務器信息中添加跟蹤前綴數字統計
14、Add——用戶參數到redis-benchmark.c (ACL)
6.0.0
* 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 <username>.
* MIGRATE AUTH2 option, for ACL style authentication support.
* Other random bugfixes.
1、XCLAIM AOF/replicas 傳播已修復。
2、客戶端緩存:新的 NOLOOP 選項以避免收到有關自己執行的更改。
3、ACL GENPASS 現在使用 HMAC-SHA256,並具有一個可選的“位”參數。這意味着您可以將其用作通用的“安全隨機字符串”原始!
4、群集“SLOTS”子命令的內存優化。
5、LCS 命令現在是 STRALGO 的子命令。
6、更有意義的復制偏移量。提高了部分重同步的成功率。
7、優化延遲回復的內存使用。
8、更快的 CRC64 法可更快地加載 RDB。
9、XINFO STREAM FULL,一個新的子命令,用於獲取整個流狀態。
10、新增CLIENT KILL USER <用戶名>命令,關閉某個用戶的連接。
11、MIGRATE AUTH2 選項,用於 ACL 樣式身份驗證支持。
12、修正了一些其他錯誤
Redis 6.0-rc4
* 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)
1、提高了大量客戶端連接時使用 INFO 命令的查詢速度。
2、在所有阻塞命令上都大大加快了速度:現在阻止同一個key的命令復雜度是 O(1)而不是O(N)。
3、陳舊的副本現在允許 MULTI/EXEC。
4、新命令:LCS(最長公共子序列)。
5、添加新配置以使 DEL 像 UNLINK。
6、RDB 加載加速。
7、修復了許多錯誤。
Redis 6.0-rc3
* 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.
1、修復了由於重構 SSL 而導致的連接代碼崩潰。
2、用於阻止命令的精確超時。現在超時已達到 HZ 分辨率,無論連接的 clinet 數量如何。新超時存儲在基數樹中並按到期時間排序。
3、修復了由於 CONFIG maxclients 而調整事件循環大小時發生的罕見崩潰。
4、修正部分重新同步成功后的 systemd 准備情況。
5、Redis-cli 詢問密碼模式將在啟動時提示(以提高安全性)。
6、鍵空間通知添加了關於MIGRATE/RESTORE命令的內容。
7、修復了線程 I/O 錯誤。
8、在 Sentinel 中實現新的 ACL 樣式 AUTH。
9、使 'requirepass' 與 Redis<=5 更向后兼容。
10、ACL:如果默認用戶關閉,則將其視為禁用狀態,而不管其是否為“ nopass”。
11、修復了在 Redis 群集中升級實例時可能出現的不一致問題
12、-READONLY 錯誤后中止事務。
13、對模塊 API 的許多不同修復。
14、添加了 BITFIELD_RO 以在只讀副本上調用該命令。
15、PSYNC2:有意義的偏移量實現。允許斷開連接的主機仍在向副本發送 PING,以便能夠成功 PSYNC 以增量方式傳遞給新的從站,從而丟棄了僅由 PING 組成的復制積壓。
16、修正 Lua 腳本處於繁忙狀態時流水線的 MULTI/EXEC。
17、重新修復模塊中的傳播 API,在其他更改后再次中斷。
Redis 6.0-rc2
* 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.
1、ACL LOG:記錄拒絕的命令,密鑰訪問和身份驗證。
2、重新設計了客戶端緩存。現在,我們使用keys而不是緩存插槽。
3、客戶端緩存:已實現廣播模式。
4、客戶端緩存:已實現 OPTIN/OPTOUT 模式。
5、新增配置參數來刪除用於在非持久性實例中進行復制的RDB文件。
一些bug修復:
6、在邊緣情況下對流的不同修復。
7、修正由於 RESP3 更改而導致重復的 CLIENT SETNAME 答復。
8、修正因新的有效到期除以零而導致的崩潰。
9、避免哨兵提升當前的從節點為該從節點的副本。
10、修復了 KEYS 命令中以 * 開頭,后跟 \x00 的錯誤。
11、線程 I/O:現在也使用主線程來執行 I/O。
12、對模塊API進行了許多修復,而在下一個RC中還會有更多修復。
13、如果字符串中間包含 \0,則 ld2string 應該失敗。
14、使 Redis 測試更可靠。
15、修復了SPOP返回空的bug
Redis 6.0-rc1
* 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:
* 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:
* A Disque module for Redis was released here: