Feature: The WAL command can be dynamically disabled #2015
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
背景
RocksDB 中的
disableWAL
是禁用 Write-Ahead Logging(WAL)的选项。用于确保数据的持久性和一致性。在 RocksDB 中,WAL 是默认启用的,这意味着每次写入操作都会首先追加到一个日志文件中,然后再写入内存中的数据结构。Pika 目前打算支持 WAL 动态关闭的命令,在写压力大的情况下,用户可以根据自己的需求动态去关闭 WAL 去缓解写瓶颈。命令介绍
我们可以根据 disablewal (true/false) 命令接受两个参数来决定 WAL 选项的开关,true 表示写 WAL 功能关闭,false 表示写 WAL 功能开启,需要注意的是写 WAL 默认是开启的
压测命令
在同一配置下,我们对 WAL 的开关场景进行在 Mac 本机进行了压测
redis-benchmark -p 9221 -n 100000 -r 100000 -t set -d 8196
关闭 WAL
开启 WAL
结论
可以看到对于 10w 条请求的压测命令,关闭 WAL 会比开启 WAL 平均快 3~4 秒完成对请求的处理返回
fix: #1961