gpt4 book ai didi

php - Redis 中的 FLUSHALL ASYNC 线程安全吗?

转载 作者:行者123 更新时间:2023-12-03 06:41:26 25 4
gpt4 key购买 nike

我是 DevOps 的新手,如果 Redis 中的 FLUSHALL ASYNC 线程安全,请指导我。当 Redis 使用不同的线程在后台删除 key 而不阻塞服务器时,它会影响我的服务器性能吗?目前使用:laravelP.S 我想使用这个命令,这样我的服务器就不会像之前那样变得无响应(持续 10 秒,所有的命中不断加起来导致 CPU 饥饿)

最佳答案

FLUSHALL ASYNC 所做的实际上是为每个数据库字典创建一组新的空哈希表(每个字典有两个哈希表)并安排旧哈希表进行延迟释放。

它是线程安全的,但它会在后台清空数据库时增加您的 CPU 使用率,并且您可能还会遇到一些性能下降。

在一个空的 redis 服务器上,我加载了几个数据库,每个数据库有 2000 万个 key :

>select 4
OK
[4]> debug populate 20000000 key 20
OK
(16.49s)
[4]> select 3
OK
[3]> debug populate 20000000 key 20
OK
(16.75s)
[3]> info memory
# Memory
used_memory:3739770656
used_memory_human:3.48G

跑基准:

~$ redis-benchmark -c 5 -t set,lpush -q
SET: 30413.62 requests per second
LPUSH: 30553.01 requests per second

运行 FLUSHALL ASYNC 后的相同基准测试(服务器在后台删除 40M key ):

~$ redis-benchmark -c 5 -t set,lpush -q
SET: 26288.12 requests per second
LPUSH: 25367.83 requests per second

我看到大约 15% 的降级

关于php - Redis 中的 FLUSHALL ASYNC 线程安全吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59820997/

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