Microservice Patterns
Communication Patterns
Single entry point for all clients, routing requests to appropriate microservices with cross-cutting concerns like auth and rate limiting.
- Request routing and composition
- Authentication and authorization
- Rate limiting and throttling
- Response aggregation
- Kong API Gateway
- AWS API Gateway
- Azure API Management
- Netflix Zuul/Spring Cloud Gateway
Automatic detection of service instances and their network locations, enabling dynamic service registration and lookup.
- Service registration
- Health checking
- Load balancing integration
- Dynamic DNS resolution
- Consul for service mesh
- Eureka for Spring Cloud
- etcd for Kubernetes
- ZooKeeper coordination
Decentralized service coordination where each service produces and consumes events independently without central orchestrator.
- Event-driven communication
- Loose coupling between services
- Autonomous service decisions
- Event bus or message broker
- Order processing workflows
- Event-driven microservices
- Reactive architectures
- Domain event handling
Centralized coordinator controls the workflow, explicitly defining the sequence and logic of service interactions.
- Central workflow engine
- Explicit service sequencing
- Transaction coordination
- Compensation handling
- Order fulfillment workflows
- Business process automation
- Multi-step transactions
- Temporal.io workflows
Data Management Patterns
Separates read and write operations into different models, optimizing each for their specific use case and scalability needs.
- Separate read and write models
- Optimized query performance
- Event sourcing integration
- Eventual consistency handling
- E-commerce product catalogs
- Financial transaction systems
- High-traffic dashboards
- Audit-heavy applications
Stores all state changes as a sequence of events rather than current state, providing complete audit trail and time-travel capabilities.
- Immutable event log
- Event replay capability
- Temporal queries
- Complete audit history
- Banking transaction history
- Version control systems
- Order state transitions
- CQRS implementations
Manages distributed transactions across microservices using compensating transactions to maintain data consistency.
- Choreography or orchestration based
- Compensating transactions
- Long-running transactions
- Eventual consistency guarantee
- Order and payment processing
- Travel booking systems
- Multi-step workflows
- Distributed rollback scenarios
Each microservice has its own private database, ensuring loose coupling and independent deployment and scaling.
- Data encapsulation
- Independent schema evolution
- Technology diversity
- Failure isolation
- Polyglot persistence
- Service autonomy
- Independent scaling
- Domain-driven design
Resilience Patterns
Prevents cascading failures by failing fast when a service is unavailable, with automatic recovery detection.
- Open/closed/half-open states
- Failure threshold monitoring
- Automatic recovery attempts
- Fallback responses
- Inter-service communication
- External API calls
- Database connection failures
- Third-party integrations
Automatically retries failed operations with exponential backoff and jitter to handle transient failures.
- Configurable retry attempts
- Exponential backoff strategy
- Jitter for thundering herd prevention
- Idempotency requirements
- Network request failures
- Temporary service unavailability
- Message delivery
- API rate limit handling
Isolates resources into pools to prevent complete system failure when one resource is exhausted.
- Resource pool isolation
- Thread pool separation
- Connection pool partitioning
- Blast radius limitation
- Critical vs non-critical requests
- Multi-tenant isolation
- Service tier separation
- Resource quota enforcement
Monitors service health with liveness and readiness probes for automated recovery and load balancing decisions.
- Liveness probe (is running)
- Readiness probe (can serve traffic)
- Dependency health checks
- Graceful degradation
- Kubernetes probes
- Load balancer decisions
- Auto-scaling triggers
- Service mesh integration
Cross-Cutting Concerns
Tracks requests across multiple microservices, providing visibility into distributed system behavior and performance.
- Request correlation IDs
- Span and trace collection
- Performance bottleneck detection
- Service dependency mapping
- Jaeger distributed tracing
- Zipkin monitoring
- AWS X-Ray
- OpenTelemetry integration
Aggregates logs from all microservices into a central location for searching, analysis, and troubleshooting.
- Log aggregation and indexing
- Correlation ID tracking
- Real-time log streaming
- Search and analytics
- ELK Stack (Elasticsearch, Logstash, Kibana)
- Splunk aggregation
- CloudWatch Logs
- Datadog logging
Manages multiple API versions simultaneously to support backward compatibility and gradual client migration.
- URI versioning (/v1/resource)
- Header-based versioning
- Backward compatibility
- Gradual deprecation
- Public API evolution
- Mobile app compatibility
- Third-party integrations
- Breaking change management
Infrastructure layer handling service-to-service communication with traffic management, security, and observability.
- Automatic mTLS encryption
- Traffic routing and splitting
- Load balancing
- Distributed tracing integration
- Istio service mesh
- Linkerd lightweight mesh
- Consul Connect
- AWS App Mesh
