perf: leaderboard SWR cache + threadpool fix for season-III stalls

- Fix 1: UV_THREADPOOL_SIZE=24 via start_server.sh wrapper (libuv reads OS
  environ; process.env and PM2 env blocks don't propagate on this system)
- Fix 2: Stale-while-revalidate for leaderboards — serve cached/stale data
  instantly, refresh in background; dedicated aggregateCache isolated from
  the 100-entry responseCache; single-flight dedup for concurrent computes
- Fix 3: Background warmer precomputes current + last-completed season
  leaderboards at +20s boot and every 4 min
- Fix 5: Adaptive TTL (5 min live, 24 h completed) via aggregateCacheTtl
- Fixes 1+2 combined: player page stall 95s -> 3.6s under concurrent heavy
  leaderboard load; warm hits served in 1-4ms (was 13-53s)
This commit is contained in:
deploy
2026-06-30 12:03:43 +00:00
parent 0f8f22df29
commit 659785f8f3
4 changed files with 144 additions and 84 deletions
+6 -3
View File
@@ -49,9 +49,12 @@ module.exports = {
{
name: 'srebot-api',
...RESTART_POLICY,
script: 'server.js',
interpreter: 'node',
node_args: '--max-old-space-size=6144',
// Shell wrapper exports UV_THREADPOOL_SIZE at the OS level.
// PM2's env: and env_file options don't propagate to the child
// process's OS environ block (required by libuv for threadpool init).
script: 'start_server.sh',
interpreter: 'none',
node_args: [],
cwd: DEPLOY_PATH,
instances: 1,
autorestart: true,