Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

# change log

## Unreleased

- add backup request config + dispatcher to duplicate slow master reads to replicas in Redis Cluster mode

# 1.3.3

- avoid infinite call when cluster endpoint was down
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ fetch = 600
# read_from_slave is the feature make slave balanced readed by client and ignore side effects.
read_from_slave = true

# backup_request duplicates slow reads to replica nodes when enabled.
# trigger_slow_ms decides the fixed delay (set "default" or remove field to rely on moving average).
# multiplier is applied to the rolling average latency to determine another trigger threshold.
backup_request = { enabled = false, trigger_slow_ms = 5, multiplier = 2.0 }

############################# Proxy Mode Special #######################################################
# ping_fail_limit means when ping fail reach the limit number, the node will be ejected from the cluster
# until the ping is ok in future.
Expand Down
1 change: 1 addition & 0 deletions default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
fetch_interval = 1800000 # 1800s , 30 minutes
fetch_since_latest_cmd = 1000 # 3600s , 1 hour
read_from_slave = false
backup_request = { enabled = false, trigger_slow_ms = 5, multiplier = 2.0 }

ping_fail_limit = 10
ping_interval = 300
Expand Down
1 change: 1 addition & 0 deletions docs/functionality.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
- 订阅与阻塞命令:
- SUBSCRIBE / PSUBSCRIBE 会进入独占会话,按频道哈希槽选择节点,并在 MOVED / ASK 时自动重连与重放订阅;
- BLPOP 等阻塞类命令复用独占连接,避免被 pipeline 请求阻塞。
- 备份读(backup request):仅在 Redis Cluster 模式下可选启用;当 master 读命令在配置阈值上仍未返回时,会复制该请求至对应 replica,优先向客户端返回更快的副本响应,同时继续跟踪 master 延迟以动态更新阈值。
- 依赖大量 `Rc<RefCell<>>`、`futures::unsync::mpsc`,并使用 `tokio::runtime::current_thread`.

## 协议与命令抽象
Expand Down
5 changes: 5 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ cargo build --release
- `hash_tag`:一致性 hash 标签,例如 `{}`。
- `read_timeout` / `write_timeout`:后端超时(毫秒)。
- `read_from_slave`:Cluster 模式下允许从 replica 读取。
- `backup_request`:Cluster 模式下用于配置“副本兜底读”策略的表,包含:
- `enabled`:是否开启该策略(默认 `false`)。
- `trigger_slow_ms`:固定延迟阈值(毫秒,可写 `"default"` 关闭固定阈值),超过该延迟仍未返回则发送副本备份请求。
- `multiplier`:相对阈值,等于“master 累计平均耗时 × multiplier”;当满足固定阈值或相对阈值任意条件即派发备份请求。
- `backup_request` 的三个字段均可通过 `CONFIG SET cluster.<name>.backup-request-*` 在线调整。
- `slowlog_log_slower_than`:慢查询阈值(微秒,默认 `10000`,设为 `-1` 关闭记录)。
- `slowlog_max_len`:慢查询日志最大保留条数(默认 `128`)。
- `hotkey_sample_every`:热点 Key 采样间隔(默认 `32`,越大代表对请求采样越稀疏)。
Expand Down
Loading