Architecture Patterns¶
Well-Architected Framework¶
Multi-Tier Architecture¶
Microservices Architecture¶
Event-Driven Architecture¶
Event-Driven Implementation¶
// Event Publisher
@Service
public class OrderEventPublisher {
private final EventBridgeClient eventBridge;
public void publishOrderCreated(Order order) {
PutEventsRequestEntry entry = PutEventsRequestEntry.builder()
.source("order-service")
.detailType("OrderCreated")
.detail(toJson(new OrderCreatedEvent(
order.getId(),
order.getUserId(),
order.getTotal(),
Instant.now()
)))
.eventBusName("orders")
.build();
eventBridge.putEvents(PutEventsRequest.builder()
.entries(entry)
.build());
}
}
// Event Consumer (Lambda)
public class OrderCreatedHandler implements RequestHandler<ScheduledEvent, Void> {
@Override
public Void handleRequest(ScheduledEvent event, Context context) {
OrderCreatedEvent orderEvent = parseDetail(event.getDetail());
// Process event
notificationService.sendOrderConfirmation(orderEvent);
inventoryService.reserveItems(orderEvent);
return null;
}
}
Serverless Architecture¶
Multi-Region Architecture¶
Data Lake Architecture¶
CQRS Pattern in Cloud¶
Strangler Fig Pattern¶
Disaster Recovery Patterns¶
Cost Optimization Patterns¶
Common Interview Questions¶
- How to design for high availability?
- Multi-AZ deployments
- Auto Scaling
- Health checks and failover
-
Stateless application design
-
Active-Active vs Active-Passive?
- Active-Active: Both regions serve traffic
- Active-Passive: Standby only for failover
-
Trade-offs: cost, complexity, latency
-
How to handle data consistency across regions?
- Eventually consistent replication
- Use global tables (DynamoDB)
- Design for idempotency
-
Handle conflicts appropriately
-
When to use serverless vs containers?
- Serverless: Variable load, event-driven, short tasks
-
Containers: Long-running, predictable load, complex apps
-
How to migrate from monolith to microservices?
- Strangler Fig pattern
- Start with bounded contexts
- Extract incrementally
- Use API Gateway as facade