C.W.K.
Stream
Lesson 07 of 07 · published

Scale 의 비용

~12 min · production, scaling, managed

Level 0Poller
0 XP0/60 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Connection 별 자원 비용

각 WebSocket connection 이 소비: file descriptor 1, ~10-50KB memory (read/write buffer + framework metadata + connection 별 state), idle 시 CPU 0, 활성 시 message rate 비례 CPU. 100K connection 한 큰 박스에 fit. 1M 가능하지만 신중. 10M 은 region 별 sharding 또는 managed service 필요.

OS limit 중요

Linux 가 프로세스당 1024 file descriptor default. 안 올리면 한 서버에 1024 WebSocket connection 못 열어. ulimit, limits.conf, sysctl 통해 올림. net.core.somaxconn + tcp_max_syn_backlog 튜닝해서 network 깜빡 후 reconnect storm 처리.

Self-host vs managed: 솔직한 trade-off

Self-host 가 1K connection 엔 쌈, 10M 엔 비쌈. Managed 가 1K 엔 비쌈, 10M 엔 쌈 (팀 안 뽑고 scale + on-call 전문성 얻음). 대부분 앱의 crossover 가 100K-1M 동시 connection 부근. cwkPippa 가 확실히 self-host territory; global SaaS chat 제품은 아닐 수 있어.

Code

고 connection 수 위한 Linux 튜닝·shell
# /etc/security/limits.conf
*  soft  nofile  1000000
*  hard  nofile  1000000

# /etc/sysctl.conf
net.core.somaxconn         = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_fin_timeout   = 15
net.core.netdev_max_backlog = 5000

# Reload
sudo sysctl -p
ulimit -n 1000000
Scale 의 decision matrix·text
| Scale                      | Recommendation                          |
| -------------------------- | --------------------------------------- |
| < 1K concurrent            | Single FastAPI server, raw WebSocket    |
| 1K - 100K concurrent       | 2-5 servers + Redis Pub/Sub             |
| 100K - 1M concurrent       | Sharded servers + Redis cluster + LB    |
| 1M+ concurrent             | Strongly consider Ably / Pusher / etc.  |
| Tight team or deadline     | Managed service from the start          |
| Custom protocol or trading | Self-host at any scale                  |

External links

Exercise

일상의 실제 service 셋 픽 — chat 앱, stock 앱, notification 앱. 동시 WebSocket connection 추정 (DAU 찾고 30% 피크 online 가정). 각자 decision matrix 위치. 각 회사가 (팀 + 제품 알고 있는 만큼) 왜 (그 추천을) 픽할지 안 픽할지 소리 내 추론.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.