Load balancer (6/10): Horizontal scaling ~100.000 user
Load balancer L7, app stateless, Redis session, autoscaling, đếm click async — kiến trúc scale ngang cho ShortLink.
· 1 min read
Khóa học System Design cơ bản — thiết kế hệ thống scale 1 → 1 triệu user · Phần 6/10▼
Mục tiêu phần 6
~100.000 user: một app server không đủ CPU — scale ngang với load balancer, app stateless, Redis cluster, autoscaling.
Stateless + LB
Users → L7 LB → App × N
→ Redis (session + cache)
→ Primary + 2 replicas
Session: JWT hoặc Redis session — tránh sticky session nếu có thể.
Auto-scale
Metric: CPU > 60% 5 phút → +1 instance; < 30% → -1 (cooldown).
Click count scale
Redirect path: INCR clicks:{slug} trên Redis; worker mỗi 10s flush batch lên Postgres hoặc ghi event (phần 7).
Centralized logs
Một request qua 3 pod — cần request_id header xuyên suốt.
Bài tập
Peak 5k RPS, 1 pod 800 RPS → cần tối thiểu mấy pod? (7, + headroom → 8–10)
Câu hỏi thường gặp
Phần 6 tập trung vào quy mô nào?
Load balancer L7, app stateless, Redis session, autoscaling, đếm click async — kiến trúc scale ngang cho ShortLink.
Bài đọc tiếp theo
Thiết kế hệ thống cơ bản (1/10): Học System Design — metric, QPS, CAP
System design là gì? Khóa miễn phí 10 phần: functional/non-functional, QPS, p99, availability, CAP — ước lượng traffic ShortLink scale 1→1M user. Bản đồ: /blog/hoc-system-design-co-ban-tu-dau
Đọc tiếp →Capstone URL shortener (10/10): System Design 1M MAU + rubric
Đề phỏng vấn URL shortener: 20k RPS redirect, 200 write/s, p99 & availability — rubric 100 điểm và đáp án tham khảo.
Đọc tiếp →Monolith System Design (2/10): Scale 1 user — kiến trúc MVP ShortLink
Thiết kế hệ thống giai đoạn MVP: monolith, Nginx, PostgreSQL một server — API URL shortener, schema SQL, sequence redirect, failure mode trước khi scale.
Đọc tiếp →Startup của bạn cần tech partner?
Trao đổi miễn phí về MVP, timeline và mô hình chia lợi nhuận phù hợp.