perf(playback): 观看进度上报异步化(Redis write-behind 批量落库)
- POST /app/watch/progress 只写 Redis 缓冲立即返回(p95 75ms→2ms), WatchProgressFlusher 每 2s 把 watch:pg:dirty 队列按身份合并批量 UPSERT, Redis 异常自动回退同步写库,接口契约不变 - 读接口用缓冲覆盖 DB 行保证读己之写;Caffeine 缓存剧集校验免去上报路径两条 DB 查询 - 落库按「新增进度/新增流水/更新行」分组攒批(MyBatis BATCH 只合并连续同形状语句), 配合 reWriteBatchedInserts 多值 INSERT,12.4 万积压 45 秒消化完, 1650 QPS 持续压测队列稳态归零
This commit is contained in:
1 parent
fc9e429187
commit
3e2d6a06d9
9 files changed
+837
-54
No files matched your search
+4
-2
@@ -71,8 +71,10 @@ services:
|
||||
env_file: .env
|
||||
environment:
|
||||
SERVER_PORT: "8081"
|
||||
# 默认连编排里的 db;要连外部库就在 .env 里覆盖 DB_URL
|
||||
DB_URL: ${DB_URL:-jdbc:postgresql://db:5432/${DB_NAME:-fruitshorts}}
|
||||
# 默认连编排里的 db;要连外部库就在 .env 里覆盖 DB_URL。
|
||||
# reWriteBatchedInserts=true:pgjdbc 把 JDBC 批内多条 INSERT 重写成多值
|
||||
# INSERT,观看进度缓冲落库(watch:pg:dirty 消费任务)依赖它跑满吞吐。
|
||||
DB_URL: ${DB_URL:-jdbc:postgresql://db:5432/${DB_NAME:-fruitshorts}?reWriteBatchedInserts=true}
|
||||
# 限流/缓存用 Redis;容器内 127.0.0.1 是容器自身,必须指向编排里的 redis
|
||||
REDIS_HOST: ${REDIS_HOST:-redis}
|
||||
REDIS_PORT: ${REDIS_PORT:-6379}
|
||||
|
||||
Reference in new issue
Block a user