Redis - 默认阻塞虚拟机 [英] Redis - Default blocking VM

查看:47
本文介绍了Redis - 默认阻塞虚拟机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阻塞 VM 的整体性能更好,因为没有时间浪费在同步、产生线程和恢复阻塞等待值的客户端.所以如果你愿意接受更高的时不时的延迟,阻塞 VM 是一个不错的选择.尤其如果交换很少发生并且大多数经常访问的数据恰好适合您的记忆.

The blocking VM performance is better overall, as there is no time lost in synchronization, spawning of threads, and resuming blocked clients waiting for values. So if you are willing to accept an higher latency from time to time, blocking VM can be a good pick. Especially if swapping happens rarely and most of your often accessed data happens to fit in your memory.

这是 Redis 的默认模式(也是我认为现在 VM 在 2.6 中已弃用的唯一模式),让操作系统处理分页(如果/需要时).我的理解是正确的,启动/启动时需要一些时间才能变得热".当使用 16gb 数据集在 1gb RAM 节点上工作时,Redis 是否尝试在启动时将其全部加载到虚拟内存中,因此 90%+ 会立即被调出,并且只有在大量使用后,上述陈述才成立?

This is default mode of Redis (and the only mode going forward I believe now VM is deprecated in 2.6), leaving the OS to handle paging (if/when required). I am correct in my understanding that it will take some time to get "hot" when booted/started. When working on a 1gb RAM node with a 16gb dataset, does Redis attempt to load it all into virtual memory at boot and thus 90%+ is immediately paged out, and only after some good amount of usages does the above statement hold true?

推荐答案

Redis VM 已在 Redis 2.4 中弃用,并已在 Redis 2.6 中删除.这是一个死胡同:不要使用它.

Redis VM was already deprecated in Redis 2.4, and has been removed in Redis 2.6. It is a dead end: don't use it.

我认为您将阻塞 VM 与操作系统分页混淆了.它们是两种不同的东西.

I think you are confusing the blocking VM with OS paging. They are two different things.

当 Redis VM 完全没有配置时(无论阻塞模式如何),操作系统分页是 Redis 的默认模式.如果它不适合物理内存,操作系统将交换 Redis 内存.事件循环可以随时冻结.当它发生时,性能很糟糕,因为 Redis 内部数据结构都不是为此设计的(没有局部性,没有分页系统).

OS paging is the default mode of Redis when Redis VM is not configured at all (whatever the blocking mode). The OS will swap Redis memory if it does not fit in physical memory. The event loop can be frozen at any time. When it happens, performance is abysmal because none of the Redis internal data structures is designed for this (no locality, no paging system).

Redis VM 可以配置为非阻塞模式(使用 I/O 线程).当 I/O 完成时,事件循环不会被阻塞,Redis 仍然是响应式的.但是,当 I/O 堆积过多时,I/O 线程将完全忙碌,您最终会得到响应式 Redis,但无法处理任何需要 I/O 的查询.

Redis VM can be configured in non blocking mode (using I/O threads). When I/Os are done, the event loop is not blocked, and Redis is still responsive. However, when too many I/Os pile up, the I/O threads will be completely busy, and you end up with a responsive Redis, but unable to process any queries requiring I/Os.

Redis VM 也可以配置为阻塞模式.在这种模式下,所有 I/O 都在主事件循环线程中同步执行.所以事件循环在 I/O 的情况下会被冻结(例如在键丢失的情况下).所有客户都受到影响.但是,总体性能(CPU 消耗和延迟)优于非阻塞模式,因为节省了一些线程调度/同步.

Redis VM can also be configured in blocking mode. In this mode all I/Os are synchronously performed in the main event loop thread. So the event loop is frozen in case of I/O (for instance in case of a key miss). All clients are impacted. However, general performance (CPU consumption and latency) is better than with the non blocking mode because some threading scheduling/synchronization is saved.

在实践中,OS 分页和 Redis 阻塞 VM 之间的区别在于粒度级别.对于 Redis VM,粒度是关键.对于操作系统分页,它是页面(一个 4 KB 的块,可以跨越几个不相关的键).

In practice, the difference between OS paging and the Redis blocking VM is the granularity level. With Redis VM, the granularity is the key. With OS paging, well it is the page (a 4 KB block which can span on several unrelated keys).

在所有 3 种情况下,转储文件的初始加载都将非常缓慢,并会在您的系统上生成随机 I/O 峰值.正如您所指出的,大多数对象将被加载然后换出.预热时间很长.

In all 3 cases, the initial load of the dump file will be extremely slow and generate a peak of random I/Os on your system. As you pointed out, most objects will be loaded and then swapped out. The warm-up time will be significant.

除非您的数据具有极端局部性,或者您根本不关心延迟,否则将 1 GB RAM 用于 Redis VM 的 16 GB 数据集是科幻小说 IMO.

Except if you have extreme locality in your data, or if you do not care at all about the latencies, using 1 GB RAM for a 16 GB dataset with the Redis VM is science-fiction IMO.

Redis VM 被淘汰是有原因的.按照设计,它永远不会像基于磁盘的数据存储(它可以利用文件映射或直接 I/O 来避免双缓冲,并使用适应的数据结构,如 B 树)一样好.

There is a reason why the Redis VM was phased out. By design, it will never perform as well as a disk-based datastore (which can exploit file mapping or direct I/Os to avoid the double buffering, and use adapted data structures like B-trees).

Redis 作为内存存储非常出色.但是,如果您需要存储比 RAM 大的东西,请不要使用它.其他(基于磁盘的)存储都会表现得更好.

Redis as an in-memory store is excellent. But if you need to store something which is bigger than RAM, don't use it. Other (disk-based) stores will all perform much better.

这篇关于Redis - 默认阻塞虚拟机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆