gpt4 book ai didi

redis - Redis 6 中的多线程 I/O 在哪些类型的工作负载中有所作为?

转载 作者:行者123 更新时间:2023-12-04 00:55:53 25 4
gpt4 key购买 nike

我的基本理解是Redis中的所有操作都是单线程的。在 Redis-6 中有多线程 I/O .. 我只是好奇如果所有 I/O 线程仍然需要等待执行所有查询的单线程,这有什么优势?我希望有人可以提供一些示例工作负载来说明优点或缺点。

最佳答案

My basic understanding is that all operations in Redis are single threaded.


不。即使在 Redis 6 之前,也有一些后台线程,例如后台保存,异步取消链接键。

I'm just curious what advantage this has if all the I/O threads still need to wait on the single thread that does all the querying?


在 Redis 6 之前,Redis 以 4 步顺序(在单线程中)处理请求:
  • 从套接字读取请求
  • 解析它
  • 处理它
  • 将响应写入套接字

  • 在完成这 4 个步骤之前,Redis 无法处理其他请求,即使有一些请求准备好读取(步骤 1)。并且通常将响应写入socket(第4步)很慢,所以如果我们可以在另一个IO线程(配置: io-threads)中进行写入操作,Redis可以处理更多的请求,并且速度更快。
    您也可以将 Redis 设置为在另一个 IO 线程中运行第 1 步和第 2 步(配置: io-threads-do-reads),但是,Redis 团队声称通常没有太大帮助(通常线程读取没有太大帮助。--引用来自 redis.conf)。
    注意 :由于第 3 步始终在单个线程中运行,因此 Redis 操作仍然保证是原子的。

    someone could provide some example work loads that would illustrate the advantages or disadvantages.


    如果您想使用 redis-benchmark 测试 Redis 加速,请确保您也在线程模式下运行基准测试本身,使用 --threads 选项来匹配 Redis 主题的数量,否则您将无法注意到改进. -- 引用自 redis.conf

    关于redis - Redis 6 中的多线程 I/O 在哪些类型的工作负载中有所作为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62618284/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com