Volume 13 · Chapter 6 — Mock Interviews and Rapid-Fire Revision
Rapid-Fire Revision: Services and Patterns
6.1 Introduction
This chapter continues the last-minute revision with cards on messaging, architecture patterns, resilience, delivery, and operations. As before, cover the answer, respond, and check - aiming for instant, structured recall.
SQS: why must consumers be idempotent?
The visibility-timeout-and-redelivery mechanism that guarantees no message is lost makes delivery at-least-once, so messages can be processed more than once. Idempotency (via a key) prevents double-applying - critical for money.
SQS vs SNS, and the fan-out pattern?
SQS delivers each message to one consumer (distribute work); SNS delivers to all subscribers (fan-out). Combine them: SNS to per-service SQS queues gives fan-out with durable per-consumer buffering, retries, and DLQs.
EventBridge vs SNS/SQS?
EventBridge is a serverless event bus with content-based routing (rules match by event content) and broad integration with AWS/SaaS sources. Use SNS/SQS for high-throughput fan-out to known subscribers; EventBridge for flexible rule-based routing.
Stream (Kinesis) vs queue?
A queue distributes discrete messages consumed once. A stream retains an ordered flow that multiple consumers read independently and can replay. Use a stream for continuous, ordered, multi-consumer, replayable data.
Orchestration vs choreography?
Choreography is decentralized event reactions (loosely coupled, good for simple flows). Orchestration (Step Functions) is a central coordinator defining steps explicitly (visible, with retries and compensation) - use it for complex multi-step flows and sagas.
Saga pattern?
A multi-step cross-service operation as a sequence of local transactions, each in one service, with compensating actions to undo earlier steps on failure - giving consistency without a distributed transaction.
Outbox pattern?
Write the event to publish in the same local transaction as the state change, then publish it reliably - so the state update and event can’t diverge. Paired with idempotent consumers for reliable event-driven consistency.
Circuit breaker?
On a high failure rate to a dependency, it opens and stops calling it (fail fast or fallback), protecting your service and giving the dependency room to recover - preventing cascading failure. Retries a trial call after a cooldown.
Why retries need backoff, jitter, and idempotency?
Naive immediate retries from many clients cause a retry storm that worsens the outage. Exponential backoff waits longer each time, jitter desynchronizes clients, limits cap attempts, and idempotency prevents duplicate effects.
Sync vs async communication?
Synchronous (request/response): simple, immediate result, but couples caller to downstream availability. Asynchronous (queue/event): decouples, absorbs bursts, fans out, but eventual consistency and idempotent consumers needed. Choose per interaction.
How to decompose into microservices?
By business capability and bounded context, not technical layer. High cohesion within, loose coupling between, each service owns its own data (never a shared database). Right-size so most work stays within one service.
What does an API gateway provide?
A single controlled entry point handling cross-cutting concerns - authentication, rate limiting, routing, TLS termination - so services don’t re-implement them and clients get one secured endpoint.
Why is statelessness key to scaling?
Stateless services hold no local client state, so any instance handles any request and you scale out by adding instances behind a load balancer. State lives in shared external stores. It’s what makes horizontal scaling work.
What does the IaC plan/apply workflow protect against?
Making unreviewed, surprising, or destructive infrastructure changes. Plan/what-if shows exactly what will be created, changed, or destroyed - reviewed in a PR - before apply executes it, catching a database deletion or firewall opening first.
Build once and promote - why?
So production runs exactly what was tested. Rebuilding per environment risks a different artifact. Build one immutable versioned artifact, inject config per environment, promote it - which also makes rollback trivial.
Rolling vs blue-green vs canary?
Rolling replaces instances gradually with health checks. Blue-green switches traffic between two environments for instant rollback. Canary exposes a small subset first, gated on metrics. All limit blast radius and enable fast rollback.
The three pillars of observability?
Metrics (numeric over time - detect, trend, alert), logs (event detail - what happened), traces (a request across services - where it broke). Correlated by a shared ID to go from “errors up” to root cause fast.
Redundancy vs backup?
Redundancy replicates data in real time, so it replicates deletions/corruption too - it protects availability, not against data loss. Backups are point-in-time copies you restore from. Need both; test restores; make backups immutable and cross-Region.
6.2 Closing
These services-and-patterns cards, with the core-concept cards from the previous chapter, cover the breadth an AWS and banking interview draws on. Combined with the mock-interview chapters and the full series, they’re your consolidated preparation. The final chapter closes the series.