A strong answer shows you understand the core concepts and the trade-offs. Key microservices concepts: Architecture and boundaries - Services organised around business capabilities (bounded contexts from domain-driven design), each independently deployable and owned by one team. - Database per service: each service owns its data; other services access it through APIs or events. Communication - Synchronous: REST or gRPC for request/response. - Asynchronous: message brokers (Kafka, RabbitMQ, Azure Service Bus) for events and commands, giving loose coupling and resilience. - API gateway as the single entry point (routing, authentication, rate limiting); Backend for Frontend (BFF) to tailor APIs for each client type. Data consistency patterns - Saga pattern for distributed transactions: a sequence of local transactions with compensating actions, coordinated by orchestration (a central coordinator) or choreography (services reacting to events). - Transactional outbox for reliable event publishing; idempotent consumers (inbox) for duplicate messages. - CQRS to separate read and write models; event sourcing to store state as a sequence of events (used where audit and temporal queries matter). - Eventual consistency between services. Resilience - Timeouts, retries with exponential backoff and jitter, circuit breakers, bulkheads and fallbacks (Polly, Resilience4j). - Health checks with readiness and liveness probes. Discovery and configuration - Service discovery (Kubernetes DNS, Consul), centralised configuration (Azure App Configuration, Spring Cloud Config), secrets in a vault. Observability - Distributed tracing with correlation IDs (OpenTelemetry), centralised structured logging, metrics and alerting. Deployment and operations - Containers and orchestration (Kubernetes, Azure Container Apps), CI/CD per service, infrastructure as code, and deployment strategies such as rolling, blue-green and canary. - Service mesh (Istio, Linkerd) for mTLS, traffic management and telemetry in larger systems. Security - OAuth 2.0 / OpenID Connect at the edge, token validation in services, service-to-service authentication (mTLS or managed identities), and least privilege. Testing - Unit, integration and consumer-driven contract tests (Pact) so services can be deployed independently. Migration - Strangler fig pattern for moving from a monolith incrementally. Trade-offs to mention Microservices add operational complexity, network latency, distributed debugging and data consistency challenges. They pay off for large systems and teams; smaller systems often do better with a modular monolith.
Ravindra Wadile · · 0 likes