- Communication patterns: sync REST/gRPC (request-response, coupling chặt hơn, dễ debug) vs async message queue — RabbitMQ/Kafka (loose coupling, resilient, nhưng eventual consistency).
- Service discovery: mỗi service đăng ký địa chỉ vào registry (Consul, etcd), services khác lookup thay vì hardcode URL — cần thiết khi services scale up/down động.
- API Gateway: single entry point cho clients, xử lý auth/rate-limiting/routing, tránh clients phải biết topology nội bộ (Kong, AWS API Gateway).
- Saga pattern cho distributed transactions: Choreography (services emit events, services khác react — loose coupling) vs Orchestration (central saga orchestrator điều phối — dễ debug hơn).
- Event sourcing: lưu toàn bộ events thay vì current state — audit log hoàn chỉnh, có thể replay để rebuild state.
- Nhược điểm thực tế: distributed tracing cần setup (Jaeger, Zipkin), network latency thay vì function call, integration tests phức tạp hơn, debugging khó hơn.
- Lưu ý: microservices quá sớm — monolith trước, tách khi có bounded contexts rõ ràng và team đủ lớn.
- Communication patterns: sync REST/gRPC (request-response, tighter coupling, easier to debug) vs async message queue — RabbitMQ/Kafka (loose coupling, resilient, but eventual consistency).
- Service discovery: each service registers its address in a registry (Consul, etcd), and other services look up the address instead of hardcoding URLs — necessary when services scale up/down dynamically.
- API Gateway: a single entry point for clients, handling auth/rate-limiting/routing so clients don't need to know the internal topology (Kong, AWS API Gateway).
- Saga pattern for distributed transactions: Choreography (services emit events, others react — loose coupling) vs Orchestration (a central saga orchestrator coordinates — easier to debug).
- Event sourcing: store all events instead of current state — complete audit log, can replay to rebuild state.
- Real-world drawbacks: distributed tracing requires setup (Jaeger, Zipkin), network latency instead of function calls, more complex integration tests, harder debugging.
Pitfall: adopting microservices too early — start with a monolith, extract when bounded contexts are clear and the team is large enough.