TechPartner

← Quay lại Blog
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

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
  1. 1Nền tảng metric & CAP
  2. 2Monolith 1 server
  3. 3Tách DB & vận hành
  4. 4Redis + CDN
  5. 5Read replica
  6. 6Load balancer
  7. 7Message queue
  8. 8Sharding & đa vùng
  9. 9Phỏng vấn & cheat sheet
  10. 10Capstone ShortLink
Mục lục
  1. Mục tiêu phần 6
  2. Stateless + LB
  3. Auto-scale
  4. Click count scale
  5. Centralized logs
  6. Bài tập
UsersLoad BalancerApp pod 1App pod 2App pod NRedis clusterPrimary DBReplicas
Giai đoạn ~100.000 người dùng: load balancer và nhiều instance stateless.

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)


Điều hướng seri: ← Phần 5 · Phần 7 →

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.

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.