Service Mesh
Cách hiểu bằng lời của tôi
Service Mesh là lớp hạ tầng quản lý service-to-service communication bên trong hệ thống. Nếu API Gateway kiểm soát traffic đi vào từ bên ngoài, service mesh kiểm soát traffic nội bộ giữa các service.
Cơ chế
Service mesh thường dùng sidecar proxy cạnh mỗi service instance. Proxy chặn inbound/outbound traffic và áp policy mà application code không cần tự implement.
Khi hữu ích
- Hệ có nhiều microservices và cần traffic policy nhất quán.
- Muốn mTLS, identity, authorization nội bộ.
- Muốn telemetry/tracing giữa service mà không sửa nhiều code.
- Cần advanced traffic control như canary, retries, timeout, circuit breaking ở hạ tầng.
Trade-off cần nhớ
Service mesh thêm control plane, sidecar overhead, config complexity và một lớp debug mới. Nếu hệ còn nhỏ, gateway + library pattern có thể đủ.