Service boundary và modular monolith
Boundary tốt theo business capability, ownership và invariant; không theo bảng database hoặc lớp kỹ thuật.
Boundary criteria
Nhóm dữ liệu và rule cần transaction mạnh, change cadence, scale profile, security boundary và team ownership. Service phải có API/event contract và tự chịu migration/operations. Shared DB tạo coupling schema, transaction và deployment dù process đã tách.
Microservices cost
Network failure, eventual consistency, duplicated platform work, CI/CD, observability, security, versioning và on-call. Independent deployment chỉ thật khi release không cần coordination hàng loạt.
Modular monolith
Module boundary trong một deploy giữ transaction/debug đơn giản, phù hợp domain/team chưa cần autonomy. Dùng dependency rule, module API và ownership để tránh big ball of mud; có thể tách sau dựa measurement.
Distributed monolith symptoms
- Mọi request gọi chuỗi service đồng bộ.
- Shared DB và shared model library.
- Deploy một service cần deploy tất cả.
- Không service nào sở hữu dữ liệu end-to-end.
- Integration environment là cách duy nhất test behavior.