M2 안정성: 부하·장애 주입 테스트 통과 + 재시작 후 시간 초과 몰림 수정
- 2,000 연결 / 500 방 / 초당 248 행동: p95 20ms, p99 37ms, CPU 0.2코어, 메모리 141MB, 오류 0 - 부하 중 SIGKILL→재시작: 2,000 연결 자동 복구, 수 유실 0 - 복구된 방 마감을 30초 + 0~30초 무작위로 분산(몰림으로 p99 336ms → 40ms) - 보고서: docs/reports/load-20261004.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -96,7 +96,9 @@ describe('Room timers', () => {
|
||||
const restored = Room.restore('room1', '482913', seq, JSON.parse(stateJson) as RoomSnapshot, deps);
|
||||
restored.clearTimer();
|
||||
expect((restored.game!.state as any).moves).toHaveLength(1);
|
||||
expect(restored.effectiveDeadline()).toBe(clock.now() + 30_000);
|
||||
const d = restored.effectiveDeadline()!;
|
||||
expect(d).toBeGreaterThanOrEqual(clock.now() + 30_000);
|
||||
expect(d).toBeLessThan(clock.now() + 60_000);
|
||||
expect(restored.roomView().seats.every((s) => s && !s.connected)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -207,7 +207,9 @@ export class Room {
|
||||
room.game.state = def.migrate(room.game.state, room.game.stateVersion);
|
||||
room.game.stateVersion = def.stateVersion;
|
||||
}
|
||||
room.game.deadlineFloor = now + 30_000;
|
||||
// 30s to reconnect, plus up to 30s jitter so thousands of restored rooms don't all time out
|
||||
// in the same instant (thundering herd after a restart, docs/04 §3).
|
||||
room.game.deadlineFloor = now + 30_000 + Math.floor(Math.random() * 30_000);
|
||||
room.scheduleTimer();
|
||||
}
|
||||
return room;
|
||||
|
||||
Reference in New Issue
Block a user