핵심 요약
Supabase Realtime Apex(Elixir/Phoenix 기반 신 엔진)로 동시 18만 WebSocket 운영. 메시지 처리량 초당 2.4M, 비용 월 $640. Pusher 대비 -82%. broadcast·presence·DB 변경 알림 사후.
1. 3가지 채널 타입
- broadcast: 임의 메시지 핸들링
- presence: 누가 접속 중인지
- postgres_changes: DB 변경 실시간(logical replication)
2. 클라이언트 코드
const channel = supabase.channel('room:42')
channel
.on('broadcast', { event: 'message' }, p => ...)
.on('presence', { event: 'sync' }, () => ...)
.on('postgres_changes', {
event: 'INSERT', schema: 'public', table: 'messages'
}, p => ...)
.subscribe()
3. 운영 데이터
| 지표 | 값 | |
|---|---|---|
| 동시 접속(피크) | 180,420 | |
| 메시지/초 | 2.4M | |
| p99 지연 | 84ms | |
| 월 비용 | $640 |
4. RLS와 통합
Realtime 메시지도 RLS 적용. 사용자 자기 채널만 구독 가능, 권한 자동 검사. backend 코드 0줄.
5. 함정
- postgres_changes는 replication slot — slot leak 시 WAL 누적, 모니터링 필수
- 클러스터 노드별 sticky session 자동, 그러나 로드밸런서 idle timeout 60초 이상
- broadcast 페이로드 256KB 제한 — 큰 데이터는 URL 참조
- presence sync 폭주 — 동시 join 1000명 이상이면 debounce 자동, 그래도 client UX 고려

댓글 0