V2EX = way to explore
V2EX 是一个关于分享和探索的地方
已注册用户请  登录
V2EX  ›  Redis

Redis 6.0 正式发布!

  •   RedisMasterNode ·
    2014BDuck · 2020-05-01 01:13:09 +08:00 · 7087 次点击
    这是一个创建于 631 天前的主题,其中的信息可能已经有所发展或是发生改变。

    3 个小时前 Antirez 在博客上发文《 Redis 6.0.0 GA is out!》,从 RC1 版本到今天,算下来也有 130 多天了,除了在 RC1 上已经知道的新功能(没有了解的同学可以看一下我的这篇译文: https://www.v2ex.com/t/630926#reply15 ),这段时间内 Redis 还做了很多优化、更新和功能的重做。

    先提纲回顾一下 Redis 6 RC1 时相对于 Redis 5 的变化:

    • 众多新模块( modules ) API
    • 更好的过期循环( expire cycle )
    • SSL
    • ACLs 权限控制
    • RESP3 协议
    • 客户端缓存( Client side caching )
    • 多线程 IO ( Threaded I/O )
    • 无盘复制副本( Diskless replication on replicas )
    • Redis-benchmark 的集群支持和 Redis-cli 优化
    • 重写 Systemd 支持( Systemd support rewrite )
    • Redis 集群代理与 Redis 6 一同发布(但在不同的 repo )
    • Disque 模块与 Redis 6 一同发布

    那么下面才是今天的主角,RC1 至 GA 期间的改动:

    1. 客户端缓存的重做,用了新的实现( broadcasting mode )
    2. 用于主从复制的 RDB 文件会在完成使命后删除
    3. 新增 ACL LOG 命令,这是 Antirez 在 twitch 上直播开发的功能,直播 coding 过程挺有意思的,言归正传,这个命令提供两个功能:查看最近 ACL 不通过的命令和用户 & 清理 ACL 不通过的日志;当然还有自动生成密码命令( ACL GENPASS )的一些内容,具体可以看博文原文。
    4. 优化 PSYNC2
    5. 带超时选项的命令优化
    6. RDB 文件加载优化,20-30%的提升
    7. 上个月新加的命令( STARLGO ),结合 Redis 和 LCS (最长公共字符串)的算法来实现一些功能


    1. Client side caching was redesigned in certain aspects, especially the caching slot approach was discarded in favor of just using key names. After analyzing the alternatives, with the help of other Redis core team members, in the end this approach looks better. Other than that, finally the feature was completed with the things I had in the backlog for the feature, especially the “broadcasting mode”, that I believe will be one of the most popular usage modes of the feature.
    When broadcasting is used, the server no longer try to remember what keys each client requested. Instead clients subscribe to key prefixes: they’ll get notifications every time a key matching the prefix is modified. This means more messages (but only for the selected prefixes), but no memory effort in the server side. Moreover the opt-in / opt-out mode is now supported, so it is possible for clients not using the broadcasting mode, to exactly tell the server about what the client will cache, to reduce the number of invalidation messages. Basically the feature is now much better both when a low-memory mode is needed, and when a very selective (low-bandwidth) mode is needed.
    2. This was an old request by many users. Now Redis supports a mode where RDB files used for replication are immediately deleted if no longer useful. In certain environments it is a good idea to never have the data around on disk, but just in memory.
    3. ACLs are better in a few regards. First, there is a new ACL LOG command that allows to see all the clients that are violating the ACLs, accessing commands they should not, accessing keys they should not, or with failed authentication attempts. The log is actually in memory, so every external agent can call “ACL LOG” to see what’s going on. This is very useful in order to debug ACL problems.
    But my preferred feature is the reimplementation of ACL GENPASS. Now it uses SHA256 based HMAC, and accepts an optional argument to tell the server how many bits of unguessable pseudo random string you want to generate. Redis seeds an internal key at startup from /dev/urandom, and later uses the HMAC in counter mode in order to generate the other random numbers: this way you can abuse the API, and call it every time you want, since it will be very fast. Want to generate an unguessable session ID for your application? Just call ACL GENPASS. And so forth.
    4. PSYNC2, the replication protocol, is now improved. Redis will be able to partially resynchronize more often, since now is able to trim the final PINGs in the protocol, to make more likely that replicas and masters can find a common offset.
    5. Redis commands with timeouts are now much better: not only BLPOP and other commands that used to accept seconds, now accept decimal numbers, but the actual resolution was improved in order to never be worse than the current “HZ” value, regardless of the number of clients connected.
    6. RDB files are now faster to load. You can expect a 20/30% improvement, depending on the file actual composition (larger or smaller values). INFO is also faster now when there are many clients connected, this was a long time problem that now is finally gone.
    7. We have a new command, STRALGO, that implements complex string algorithms. For now the only one implemented is LCS (longest common subsequence), an important algorithm used, among the other things, in order to compare the RNA of the coronaviruses (and in general the DNA and RNA of other organisms). What is happening is too big, somewhat a trace inside Redis needed to remain.
    7 条回复    2020-05-01 12:05:33 +08:00
       2020-05-01 01:16:19 +08:00   ❤️ 1
    再安利最近写的 Redis 6.0 一些新功能的实现的文章:

    Redis 6.0 ACL 基于 Bitmap 实现: https://blog.2014bduck.com/archives/343
    Redis 6.0 多线程 IO 的实现: https://blog.2014bduck.com/archives/326

    文章在 V2EX 上也能找到~不过安利博客大概可以流量+1

    我是 小黄鸭 @Shopee ^_^
       2020-05-01 06:16:16 +08:00
    楼主这网名 专注 redis ~
       2020-05-01 07:32:36 +08:00 via iPhone
    问一下 昨天看 release note 里提到的 6.0 里面 block 在同一个 key 的复杂度从 O(n)优化到了 O(1) 是做了什么?
       2020-05-01 08:53:01 +08:00
    Redis 的主从能做双主互连么?现在用的是 keydb 互连,不知道能不能转回 Redis 。
       2020-05-01 09:11:59 +08:00 via iPhone
    wow, local cache invalidation 这个功能点非常有升级动力
       2020-05-01 10:25:20 +08:00
    centos7 下 编译失败
       2020-05-01 12:05:32 +08:00
    多线程 IO ( Threaded I/O )
    关于   ·   帮助文档   ·   API   ·   FAQ   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   2393 人在线   最高记录 5497   ·     Select Language
    World is powered by solitude
    VERSION: · 29ms · UTC 15:17 · PVG 23:17 · LAX 07:17 · JFK 10:17
    ♥ Do have faith in what you're doing.