Microservices là trade-off
Tách service phải bắt đầu từ business capability/data ownership. Ghi sync/async, timeout, retry, idempotency và source of truth.
Bài tập
Thiết kế catalog/order/payment/notification. Với mỗi boundary ghi deploy/scaling/security/observability và failure mode. Cuối cùng viết điều kiện giữ monolith để tránh chia nhỏ vì phong trào.
Bài giảng chuyên sâu
Microservices: boundary trước service count
Tách theo business capability và data ownership, không theo bảng database. Sync API cần timeout/retry/circuit behavior; async cần queue/event, idempotency và DLQ. Service autonomy tăng nhưng kéo theo network, observability, contract testing, deployment và distributed failure. Monolith vẫn phù hợp khi boundary chưa rõ hoặc team chưa chịu được overhead.
Bài tập: phân tích catalog/order/payment/notification, ghi owner, source of truth, sync/async và failure. Failure drill: downstream chậm, duplicate payment event và schema incompatibility; recovery phải tránh side effect lặp.