Các thành phần hệ thống
Các building blocks phổ biến để xây dựng hệ thống phân tán.
1. Load Balancer
Phân phối incoming traffic across multiple servers.
- Algorithms: Round‑Robin, Least Connections, IP Hash, Weighted.
- Types: Hardware (F5), Software (NGINX, HAProxy), Cloud (AWS ELB, Azure Load Balancer).
2. Caching
Lưu trữ dữ liệu tạm thời để giảm latency và database load.
- Cache strategies: Cache‑Aside, Read‑Through, Write‑Through, Write‑Behind.
- Cache invalidation: Time‑based, event‑based.
- Popular caches: Redis, Memcached, CDN.
3. Database
Lựa chọn database phù hợp với pattern truy cập.
- SQL (RDBMS): ACID, strong consistency, phù hợp transactional data (MySQL, PostgreSQL).
- NoSQL: High scalability, flexible schema, phù hợp unstructured data (MongoDB, Cassandra).
- NewSQL: Kết hợp scalability của NoSQL và ACID của SQL (CockroachDB, Spanner).
4. Message Queue
Decouple components và xử lý bất đồng bộ.
- Use cases: Background jobs, event‑driven architecture, log aggregation.
- Examples: Kafka, RabbitMQ, Azure Service Bus, AWS SQS.
5. CDN (Content Delivery Network)
Phân phối nội dung tĩnh đến edge servers gần user.
- Benefits: Giảm latency, giảm tải origin server.
- Providers: Cloudflare, Akamai, AWS CloudFront.
6. API Gateway
Entry point cho client, xử lý authentication, rate limiting, routing.
- Features: SSL termination, request/response transformation, monitoring.
- Examples: Kong, Apigee, AWS API Gateway.
7. Service Discovery
Tự động detect vị trí của services trong môi trường dynamic.
- Tools: Consul, etcd, ZooKeeper, Kubernetes Service.