Abuse 의 두 축
WebSocket abuse 두 모양: 한 source 에서 너무 많은 connection, 또는 한 connection 에 너무 많은 message. 완화책 다름. Connection limit 이 서버 자원 (file descriptor, memory) 고갈 캡. message rate limit 이 시끄러운/악성 클라 캡 — connection drop 안 하면서.
IP 별 connection cap
source IP 별 활성 connection 추적. cap 넘으면 code 4029 로 reject (application 관습; HTTP 의 429 와 비슷). proxy 뒤에선 조심: websocket.client.host 가 real client 아니라 proxy IP 일 수 있어. 역방향 proxy 가 X-Forwarded-For 설정하면 그거 써.
Connection 별 message rate limit
WebSocket 별 최근 message timestamp 추적. 마지막 1초 안에 limit 넘으면 message drop, {type: 'error', code: 'rate_limited'} 응답. connection close 하지 마 — 그건 escalation, 네트워크 fail 처럼 보여. 악용 message 만 drop, 계속 가.