Architecture Documentation and Communication Questions
Making an architecture legible to others: architecture decision records, diagramming and visualization (C4, sequence, deployment diagrams), and communicating designs to technical and non-technical stakeholders. Covers capturing rationale, keeping docs current, and presenting a system clearly under time pressure. The communication skill that separates a good design from an understood one.
Design the observability section for architecture documentation for a messaging service processing millions of messages per minute. List critical metrics (throughput, producer/consumer lag, error rate), tracing strategy, suggested dashboards, alert rules, and explain which metrics map to business KPIs and why.
Sample Answer
Observability section — Messaging Service (millions msgs/min)
Overview: goal is end-to-end visibility (ingest → broker → processing → delivery) for performance, reliability, and business impact.
Critical metrics (per service/component, per topic/partition):
- Throughput: msgs/sec, bytes/sec (ingress/egress). Tag by topic, producer app, partition.
- Producer/Consumer lag: time and offset lag per consumer group and partition.
- Error rate: error count/second, error % of total, classified by type (validation, delivery, retry, DLQ).
- Latency p50/p90/p99: end-to-end (produce → ack → processed) and component-level.
- Success rate & retries: deliveries succeeded vs retried vs dead-lettered.
- Resource metrics: CPU, memory, disk IO, network, GC pauses, connection count.
- Queue depth/backpressure & retention size.
- Throughput per client and throttling events.
Tracing strategy:
- Instrument producers, brokers, processing consumers with distributed tracing (W3C Trace Context).
- Propagate trace id in message headers; record span at produce, broker enqueue/dequeue, consumer processing, downstream calls.
- Sample adaptively: 100% for errors, 1-5% for success, increase sampling for hot topics.
- Include baggage: topic, partition, message id, customer-id, business-event-type.
Suggested dashboards:
- Overview: global throughput, error rate, p99 latency, active consumers, backlog.
- Topic health: throughput, consumer lag, error rate, retention per topic.
- Consumer group detail: per-partition lag, processing rate, worker CPU/memory.
- SLA/KPI: successful deliveries/min, percent within 300ms, revenue-affecting events.
- Infrastructure: broker cluster health, disk, network, partition leaders.
- Alerts & traces quick links: recent errors -> trace view.
Alert rules (examples, routed by severity):
- P0: consumer lag > X minutes for >5% partitions OR backlog growth > 10%/5min → paging.
- P0: error rate > 1% of throughput for 5min or sudden spike (3x baseline) → paging.
- P1: p99 end-to-end latency > SLA threshold for 5min → paged to on-call.
- P1: broker disk usage > 80% or partition under-replicated > 1 → paged.
- P2: consumer restart rate > threshold, GC pauses > 1s → ticket.
- P3: single-topic throughput drop >50% without config change → investigate.
Mapping metrics → business KPIs (why):
- Throughput → business throughput (orders/messages/min): directly maps to capacity and revenue processing rate.
- Consumer lag/backlog → customer experience SLA (time-to-process): high lag = delayed customer-facing actions, SLA breaches.
- Error rate & DLQ rate → successful business transactions %: correlates to failed orders, lost revenue, and customer churn.
- End-to-end p99 latency → SLA compliance and perceived responsiveness; critical for real-time features.
- Delivery success rate → financial KPIs (completed transactions) and support tickets.
- Throttling/availability metrics → uptime/availability KPI; impacts SLAs and contractual penalties.
Operational guidance:
- Define per-tenant/priority SLAs and tune alerts thresholds per topic.
- Instrument business identifiers to correlate technical failures to revenue impact in dashboards.
- Run regular chaos tests and ensure dashboards show injected failures and alerts trigger expected runbooks.
- Keep runbooks linked from alerts with remediation steps and relevant traces.
This observability design enables rapid detection, triage, and business-impact assessment for a high-throughput messaging service.
You're deciding between CDN edge caching and an in-service cache for static user profile assets. Document the alternatives comparing cache invalidation complexity, consistency guarantees, geographic performance, estimated cost per million requests, and operational complexity. Draft the core recommendation and justify it for a global user base.
Sample Answer
Summary: Two viable patterns — CDN edge caching (public CDN like Cloudflare/Akamai/CloudFront) vs in-service cache (service-fronted cache such as regional Redis/ELB-level caching or application-layer cache). Below I compare key dimensions and give a recommendation for a global user base.
Alternatives:
- CDN edge caching
- Cache invalidation complexity: Medium — supports TTLs, cache-control and soft/purge APIs. Invalidation at scale requires purge API orchestration or versioned URLs (cache-busting) to avoid mass purges.
- Consistency guarantees: Eventual. Edges may serve stale objects until TTL expires or explicit purge propagates; purges are fast but not instantaneous globally.
- Geographic performance: Excellent — single-digit to low-double-digit ms globally from nearest PoP.
- Estimated cost / 1M requests: $0.50–$5 (request + egress; depends on CDN and region); bandwidth dominates if assets are large.
- Operational complexity: Low — managed service, simple integration, fewer infra responsibilities.
- In-service cache (regional Redis/edge application caches or nearest-AZ caches)
- Cache invalidation complexity: High — need coordinated invalidation across regions, or central invalidation service; more logic in app.
- Consistency guarantees: Stronger possible — can implement near-real-time invalidation (pub/sub), read-through/write-through patterns to keep caches coherent.
- Geographic performance: Moderate — faster within region/availability zone; global users may see higher latency unless you deploy many regional caches.
- Estimated cost / 1M requests: $5–$30 (compute + managed cache nodes + network egress if regional replication used).
- Operational complexity: High — provisioning, scaling, replication, failover, and operational runbook for cache coherence.
Recommendation:
Use CDN edge caching as primary delivery mechanism for static user profile assets, combined with cache-control headers and versioned asset URLs for deterministic invalidation. For assets requiring immediate consistency (e.g., profile photo changed and must be visible instantly to owner), add a short cache TTL + origin purge on update and a user-scoped cache-bypass query param for critical paths, or implement a fast synchronous invalidation flow (invalidate CDN by versioned URL). Optionally deploy regional in-service caches only for write-heavy metadata workflows needing strong consistency; keep origin storage (S3/object store) and small TTLs to minimize stale windows.
Justification:
Global performance and cost favor CDN edges — lowest latency worldwide and lowest per-request cost. CDN reduces operational burden while offering pragmatic invalidation tools. Combine conservative TTLs and versioned URLs to balance eventual consistency with user expectations; reserve in-service caches where strict, low-latency consistency is required and you can absorb operational overhead.
Create an annotated sequence-style narrative (text form) showing: Client -> API -> Service A (synchronous) -> Service B (enqueue async) -> Worker -> Database. Include where retries, backoff, timeout policies, and idempotency tokens are applied. Explain exactly where in architecture docs you would capture retry policies and idempotency guarantees for both clients and downstream workers.
Sample Answer
Client -> API -> Service A (sync) -> Service B (enqueue async) -> Worker -> Database
- Client → API (HTTP)
- Annotated: Client includes an Idempotency-Token header (UUID) on create requests.
- Policies: Client-level retry: simple retry with exponential backoff for network/timeouts only; do not retry on 4xx. Max attempts = 3, initial delay = 200ms, max delay = 2s.
- Timeout: Client waits up to 5s for API response before applying retry/backoff.
- Doc placement: API Contract + Client SDK README (Idempotency header required, allowed retry behavior, example code).
- API → Service A (synchronous call)
- Annotated: API validates Idempotency-Token and request, returns 202/200 immediately on deduplication.
- Policies: API enforces request timeout = 3s to Service A; on transient 5xx or timeout, API retries Service A synchronously with short capped retries (max 2 attempts) using exponential backoff (100ms → 400ms).
- Idempotency: API stores a short-lived idempotency record keyed by (Idempotency-Token, client-id) with status: RECEIVED / ENQUEUED / COMPLETED.
- Doc placement: Sequence diagram + API reliability table (timeouts, retry counts) + Idempotency spec.
- Service A → Service B (enqueue async)
- Annotated: Service A constructs a message including the client Idempotency-Token and writes to durable queue (e.g., Kafka/SQS) with message deduplication attributes.
- Policies: Enqueue is fire-and-forget but must be confirmed; Service A uses a single write attempt with transactional guarantee where supported; if enqueue fails, Service A returns an error to API and triggers retry per step 2.
- Doc placement: Messaging guarantees section (delivery semantics: at-least-once, deduplication TTL), sequence diagram.
- Queue → Worker (async consumption)
- Annotated: Worker receives messages; queue may redeliver (at-least-once).
- Policies: Worker processes with idempotency check before side-effects: check idempotency-record in Database; if record not present, insert with status IN_PROGRESS (use DB unique constraint on idempotency key to prevent race).
- Retry/backoff: On transient processing error, Worker retries with exponential backoff and jitter, using a retries-attempts header; move to DLQ after N attempts (e.g., 5) and alert.
- Timeout: Worker-level operation timeouts for external calls (e.g., downstream HTTP calls) are short (500ms–2s).
- Doc placement: Worker runbook + Operational playbook (DLQ handling), Component-level design doc (processing semantics).
- Worker → Database (idempotent write)
- Annotated: Database enforces uniqueness on idempotency key. Processing updates idempotency record to COMPLETED and writes business rows in a transaction.
- Policies: If DB write fails with transient error, Worker retries transaction; if fatal conflict (duplicate key), treat as already-processed and mark COMPLETED.
- Doc placement: Data model + Idempotency implementation details (schema, constraints), SLOs for write latency.
Where to capture policies and guarantees in architecture docs (exact locations):
- API Contract (openapi): required headers, response codes, idempotency semantics, client retry guidance.
- Sequence Diagrams (architecture section): annotated arrows showing timeouts, retry counts, and backoff windows.
- Reliability & Resilience Matrix (non-functional): per-component timeouts, retry strategy, circuit-breaker thresholds, max attempts, backoff algorithm.
- Messaging & Delivery Guarantees page: queue semantics, deduplication TTL, DLQ policy.
- Data Model & Idempotency Spec: schema, unique constraints, state transitions (RECEIVED→IN_PROGRESS→COMPLETED), TTL for idempotency records.
- Runbooks / Operational Playbooks: alert thresholds, DLQ handling, manual retry steps.
- Client SDK README / Integration Guide: example client retry code, recommended backoff, sample idempotency-token generation.
Rationale: document both behavioral (what to do) and mechanical (how implemented/schema/timeouts) so clients know safe retry semantics and operators can troubleshoot duplicated deliveries and worker retries.
Write a concise design decision section explaining why you would choose eventual consistency for a geo-replicated shopping-cart service. Include business rationale, acceptable user experience trade-offs, typical conflict scenarios, and mitigations (e.g., last-write-wins, vector clocks, compensating actions).
Sample Answer
Decision: Choose eventual consistency for the geo-replicated shopping-cart to optimize latency, availability, and regional fault tolerance while preserving a responsive UX for global customers.
Business rationale:
- Low-latency interactions in each region increase conversion and reduce cart abandonment; synchronous cross-region coordination would add round-trip delays and reduce availability.
- High availability during region failures or network partitions protects revenue and supports SLAs for e‑commerce uptime.
- Cart data is ephemeral and user-scoped, so slight temporary divergence has low long‑term business risk compared to user-facing outages.
Acceptable UX trade-offs:
- Users may see transient differences between devices/regions (out-of-order item additions, temporary quantity mismatches). Acceptable if divergence resolves quickly and key actions (checkout) surface final consistency check.
- On checkout, enforce a final reconciliation step (conflict detection + merge) with clear UI prompts if changes occurred.
Typical conflict scenarios:
- Concurrent updates from two regions: user adds item A in EU and simultaneously removes it in US.
- Multiple devices: mobile adds quantity while desktop decrements concurrently.
- Network partition: region serves stale cart while another region accepts updates.
Mitigations:
- Merge strategy: prefer operation-based CRDTs (observed-remove set, PN-counter) for common cart ops to auto-merge without data loss.
- Where CRDTs aren't feasible, use vector clocks or causal metadata to detect concurrent writes and apply deterministic merge rules (e.g., per-item last-write-wins with timestamps) while preserving user intent where possible.
- Checkout-time canonicalization: perform strong consistency check and reservation of inventory; if conflict, present concise conflict UI with recommended resolution or apply compensating actions (create order for available items, refund or notify for unavailable).
- Audit and compensation: keep an immutable operation log to replay or reconcile and implement compensating transactions for payments/inventory.
- UX affordances: show "last updated" timestamps, real-time sync indicators, and lightweight conflict prompts to keep users informed.
Trade-offs and justification:
- Eventual consistency maximizes user-perceived performance and availability—critical for conversion—while mitigations (CRDTs, reconciliation at checkout, compensating actions and clear UX) limit business risk and maintain trust.
You are reviewing a payments platform architecture that mixes synchronous authorization and asynchronous settlement. The diagram lacks reliability annotations. Identify five critical reliability concerns (for example: duplicate charges, out-of-order processing, partial failures) and for each propose an architecture-level mitigation and how you would record it in the project's risk register and runbooks.
Sample Answer
Framework: I list five critical reliability concerns, each with an architecture-level mitigation and the exact way to record it in the risk register and runbooks so ops and stakeholders can act.
- Duplicate charges
- Mitigation: Enforce global idempotency keys (client-provided or generated at auth time) stored in a single source-of-truth (strongly consistent DB or idempotency service). Use at-most-once processing in async pipeline; dedupe on write.
- Risk register: Title: "Duplicate charge risk"; Likelihood: Medium; Impact: High (financial/regulatory); Owner: Payments Platform Lead; Mitigation: Idempotency + audit trail; Detection: monitoring of duplicate-key hits; Residual risk: Low; Target RTO: 1h.
- Runbook: Steps to query idempotency store, reconcile duplicates, reverse/compensate transactions, contact ops/legal, run SQL to create compensating reversal, and verify downstream clearing.
- Out-of-order processing (auth vs settle)
- Mitigation: Use explicit event versioning and causal ordering (stream partitioning by payment ID, include sequence numbers) and an ordering guarantee (per-partition single writer or per-payment concurrency control).
- Risk register: Title: "Out-of-order settlement"; Likelihood: Medium; Impact: Medium; Owner: Integration Lead; Mitigation: Partitioning + sequence checks + tombstones; Detection: metrics for sequence gaps/reorders.
- Runbook: Detect gaps (dashboard), pause consumer, replay from offset, run reconciliation to ensure settlement matches last successful auth.
- Partial failures across sync/async boundary
- Mitigation: Implement transactional outbox pattern: sync auth writes to DB and outbox in same transaction; reliable publisher reads outbox and marks published. Combine with compensation workflows for partial success.
- Risk register: Title: "Partial write/publish failures"; Likelihood: Medium; Impact: High; Owner: Platform Eng; Mitigation: Transactional outbox + retry policy; Detection: stale outbox rows older than threshold.
- Runbook: Inspect outbox table, manually publish rows, run compensating actions for any orphaned auths, escalate if >X rows.
- Message loss / DLQ exhaustion
- Mitigation: Durable message broker with at-least-once semantics, exponential backoff, DLQ with alerts and automated replay tooling; watermark persisted per consumer.
- Risk register: Title: "Lost/poisoned messages"; Likelihood: Low-Medium; Impact: High; Owner: Messaging Owner; Mitigation: Broker durability + DLQ + replay tooling; Detection: DLQ growth alert.
- Runbook: Tail DLQ, inspect payload, fix consumer or transform message, replay via tooling, or route to manual processing queue.
- Reconciliation / state drift between ledger and clearing
- Mitigation: Maintain an authoritative ledger (append-only) and nightly/real-time reconciliation jobs that compare ledger vs settlement system; implement anomaly detection and automated holds.
- Risk register: Title: "Ledger/clearing drift"; Likelihood: Medium; Impact: Critical; Owner: Finance + Platform; Mitigation: Real-time reconciliation, alerts, auto-hold on anomalies; Detection: Reconciliation mismatch > threshold.
- Runbook: Run reconciliation job, steps to isolate offending transactions, create compensating entries, contact clearing partner, restore balances, and post-mortem.
For each risk entry include: detection metric (alert threshold), playbook link, communication plan (stakeholders, SLA), pre-approved compensations, and test frequency (quarterly drills).
Unlock Full Question Bank
Get access to all Architecture Documentation and Communication interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.