This quick reference provides at-a-glance guidance for common microservices patterns, best practices, and decision points. Use this as a handy reference during design sessions, code reviews, and architectural discussions.
| Factor | Fine-Grained | Medium-Grained | Coarse-Grained |
|---|---|---|---|
| Complexity | High | Medium | Low |
| Change Frequency | High | Medium | Low |
| Team Capacity | Multiple Teams | Single Team | Shared Team |
| Scaling Needs | Independent | Moderate | Uniform |
| Data Coupling | Low | Medium | High |
Decision Rule: Choose granularity based on your organizational context, not rigid rules.
| Aspect | Synchronous | Asynchronous |
|---|---|---|
| Coupling | Higher | Lower |
| Latency | Direct | Indirect |
| Resilience | Lower | Higher |
| Complexity | Lower | Higher |
| Use Cases | Real-time queries | Event processing |
1
2
3
4
Query Data β REST/GraphQL
Commands β Async Messages
Events β Event Streaming
Real-time β WebSockets/gRPC
1
2
3
4
5
6
7
8
9
10
11
# Good URLs
GET /api/v1/orders/123
POST /api/v1/orders
PUT /api/v1/orders/123
DELETE /api/v1/orders/123
# Bad URLs
GET /api/getOrder?id=123
POST /api/createOrder
PUT /api/updateOrder
DELETE /api/deleteOrder
| Pattern | Use Case | Complexity | Consistency |
|---|---|---|---|
| Strong Consistency | Financial transactions | High | Immediate |
| Eventual Consistency | User profiles | Medium | Delayed |
| Saga Pattern | Multi-service workflows | High | Compensating |
| Event Sourcing | Audit trails | High | Event-based |
1
2
3
4
Need different read/write models? β Yes β Consider CQRS
High read/write ratio? β Yes β Consider CQRS
Complex queries? β Yes β Consider CQRS
Simple CRUD? β No β Skip CQRS
| Pattern | Purpose | When to Use |
|---|---|---|
| Circuit Breaker | Prevent cascade failures | External service calls |
| Retry | Handle transient failures | Network operations |
| Timeout | Prevent hanging requests | All remote calls |
| Bulkhead | Isolate resources | Critical vs non-critical |
| Fallback | Graceful degradation | User-facing features |
1
2
3
CLOSED β Normal operation
OPEN β Failing fast (no calls)
HALF-OPEN β Testing recovery
1
2
3
# Exponential backoff with jitter
delay = base_delay * (2 ** attempt) + random_jitter
max_attempts = 3
| Pattern | Pros | Cons | Best For |
|---|---|---|---|
| Client-Side | Simple, fast | Client complexity | Internal services |
| Server-Side | Client simplicity | Additional hop | External clients |
| Service Mesh | Rich features | Operational complexity | Large deployments |
1
2
3
4
5
6
7
8
GET /health
{
"status": "UP",
"checks": {
"database": "UP",
"external-service": "DOWN"
}
}
1
API Gateway β JWT Validation β Service Authorization
1
2
3
4
5
6
7
8
9
10
11
12
{
"header": {
"alg": "RS256",
"typ": "JWT"
},
"payload": {
"sub": "user123",
"iat": 1516239022,
"exp": 1516242622,
"roles": ["user", "admin"]
}
}
| Type | Examples | Purpose |
|---|---|---|
| Business | Orders/minute, Revenue | Business health |
| Application | Response time, Error rate | App performance |
| Infrastructure | CPU, Memory, Disk | Resource usage |
1
2
3
4
5
6
Request ID: 12345
βββ Service A (10ms)
βββ Service B (50ms)
β βββ Database Query (30ms)
β βββ External API (15ms)
βββ Service C (25ms)
1
2
3
4
ERROR β System errors, exceptions
WARN β Potential issues, degraded performance
INFO β Important business events
DEBUG β Detailed diagnostic information
| Strategy | Downtime | Risk | Complexity | Rollback |
|---|---|---|---|---|
| Blue-Green | None | Low | Medium | Instant |
| Canary | None | Very Low | High | Gradual |
| Rolling | None | Medium | Low | Gradual |
| Recreate | Yes | High | Low | Manual |
1
2
3
4
5
6
7
8
9
10
11
12
13
# Multi-stage build
FROM node:16-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
FROM node:16-alpine
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY . .
EXPOSE 3000
USER node
CMD ["npm", "start"]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-service
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
template:
spec:
containers:
- name: my-service
image: my-service:v1.0
ports:
- containerPort: 8080
readinessProbe:
httpGet:
path: /health
port: 8080
livenessProbe:
httpGet:
path: /health
port: 8080
1
2
3
4
5
/\
/ \ E2E Tests (Few)
/____\
/ \ Integration Tests (Some)
/__________\ Unit Tests (Many)
| Test Type | Scope | Speed | Cost | Purpose |
|---|---|---|---|---|
| Unit | Single function | Fast | Low | Logic validation |
| Integration | Service boundaries | Medium | Medium | Interface validation |
| Contract | API contracts | Fast | Low | API compatibility |
| E2E | Full workflow | Slow | High | User journey validation |
1
2
3
4
5
6
7
8
9
10
11
# Consumer contract
interactions:
- description: "Get user by ID"
request:
method: GET
path: /users/123
response:
status: 200
body:
id: 123
name: "John Doe"
| Anti-Pattern | Description | Solution |
|---|---|---|
| Distributed Monolith | Tightly coupled services | Proper service boundaries |
| Chatty Services | Too many service calls | Coarser-grained interfaces |
| Shared Database | Multiple services, one DB | Database per service |
| Lack of Automation | Manual deployments | CI/CD pipelines |
| Premature Decomposition | Too many small services | Start with monolith |
π¨ Red Flags:
Too Small (Nano-service):
Too Large (Mini-monolith):
Just Right:
1
2
Team Size = 2-8 people (Amazon's "Two Pizza Rule")
Services per Team = 1-3 services
Java Ecosystem:
1
2
3
Spring Boot + Spring Cloud
Netflix OSS (Eureka, Hystrix, Zuul)
Apache Kafka + Docker + Kubernetes
Node.js Ecosystem:
1
2
Express.js + Consul
RabbitMQ + Docker + Kubernetes
Polyglot Approach:
1
2
3
4
API Gateway: Kong/Ambassador
Service Mesh: Istio/Linkerd
Monitoring: Prometheus + Grafana
Logging: ELK Stack
Organizational Readiness:
Technical Readiness:
| Problem | Symptoms | Solution |
|---|---|---|
| Cascade Failures | Multiple services failing | Implement circuit breakers |
| Slow Responses | High latency | Add caching, optimize queries |
| Data Inconsistency | Stale data | Implement eventual consistency |
| Deployment Issues | Failed deployments | Improve health checks |
| Monitoring Gaps | Unknown system state | Add distributed tracing |
This quick reference is designed to be printed or bookmarked for easy access during development. For detailed explanations, refer to the full chapters in this book.
Last Updated: February 2026