Skip to content
Tech Interview Prep
Technical interview guide

Integration Patterns

The standard ways two systems exchange data (sync API calls, async messaging, batch, and webhooks) and when each fits.

Minutes to read
4
Practice MCQs
25
Interview Q&A
25
Edition
v5
Editorial status
Reviewed

Scope: Azure Architecture Center and AWS Prescriptive Guidance integration patterns current 2026-08-31.

Overview

Curated: · Written: · Reviewed:

Integration Patterns

In one line

Choose the mechanism from the interaction, not the transport. Use synchronous request-response when the caller needs an answer before it can proceed, a queue to hand work to one consumer group, a log when many readers need retained history, a webhook for external push, and a file or batch exchange for bulk, loosely coupled data. Start with who owns the fact, whether the caller waits, and what redelivery, reorder and broker outage do to the design.

Key definitions

  • At-least-once: the broker redelivers until acked, so duplicates are normal and the consumer must dedupe.
  • Idempotency key: a stable ID (message ID, transaction ID) backed by a uniqueness constraint, so a retry lands on the same result.
  • Dual write: updating a database and publishing an event as separate operations. A crash between them loses one side. A transactional outbox fixes this.
  • Visibility timeout: the SQS window after which an unacked message reappears. It must exceed the handler's processing time.
  • Competing consumers: workers sharing one queue. Throughput rises, but per-entity order is lost.
  • Saga: a multi-step workflow whose compensations are business operations, not rollbacks.

Formulas and complexity

Achain=∏i=1nAi=0.9995≈0.995A_{chain} = \prod_{i=1}^{n} A_i = 0.999^{5} \approx 0.995

Five serial hops at 99.9% give about 99.5% end to end, which misses a 99.9% SLO.

p99chain≤∑ip99i=5×40 ms=200 msp99_{chain} \le \sum_{i} p99_i = 5 \times 40\,\text{ms} = 200\,\text{ms}

This is the worst case with every hop at its p99 at once.

Tdrain=BN×rT_{drain} = \frac{B}{N \times r}

With backlog B, N consumers and per-consumer rate r, queue wait is roughly depth divided by drain rate. 120,000 messages at 500 msg/s is 240 s, which matches a 4-minute p99.

Tbatch=12 000 000×0.040 s20=24 000 s≈6.7 hT_{batch} = \frac{12\,000\,000 \times 0.040\,\text{s}}{20} = 24\,000\,\text{s} \approx 6.7\,\text{h}

Per-record calls at 40 ms through 20 connections cannot finish a 2-hour window.

How it works

The outbox writes the business row and the publication intent in one local transaction. A relay then publishes and marks progress.

Handler commits orders row and outbox row in one transaction Relay polls unpublished outbox rows Publish to broker with acks=all Mark row published or delete it Crash before mark: row republished, consumer dedupes
  • The dedup key is written in the same transaction as the effect, so a duplicate hits a unique constraint and rolls back.
  • Record the dedup marker after the effect commits. A marker committed before the effect can lose the effect on a crash.
  • For an effect outside your database, write a pending intent row, pass the intent ID as the provider's idempotency key, then mark it done.
  • Key by entity (account_id) so one partition or worker owns each account's sequence. A shared thread pool loses per-account order.

When to use and when not to

NeedUseAvoid when
Caller needs the result to proceedSync RPC with budgeted timeouts and bounded retriesLong chains, or a slow callee you cannot isolate
One consumer group, bursty loadQueue with competing consumersYou need replay for new readers or strict per-key order
Many readers, retained historyLog partitioned by entity keyYou need one global order or exactly-once effects outside the broker
External producer pushes eventsWebhook with HMAC, timestamp window and dedupeYou need history without a list-since-cursor API
Bulk, minutes-to-hours toleranceFile or batch with manifest and checksumsPer-record latency is a requirement

Traps interviewers probe

  1. Ack before the effect commits. A crash after a card charge and before the ledger write leaves a charge with no row. Fix: ack after the durable write, and send an idempotency key to the charge API.
  2. Visibility timeout below processing time. The message reappears mid-handler and the effect runs twice. Fix: set the timeout above p99 with headroom and make the handler idempotent. Raising maxReceiveCount hides the problem and sends healthy messages to the DLQ.
  3. Timestamp ordering across unsynchronized clocks. A 900 ms skew makes last-write-wins keep the older status. Fix: a producer sequence or entity version with compare-and-set.
  4. Trusting a green broker. A 200 from the broker means the bytes were accepted, not that the business step completed. Fix: reconcile on business IDs.
  5. Trusting a registry compatibility check. BACKWARD mode only proves the new schema reads old data. A type change that old consumers cannot read still passes. Fix: upgrade consumers first or choose FULL compatibility, and treat meaning changes as breaking even when bytes parse.

Interview tips

Open with: "I'd first decide who owns the fact and whether the caller needs an answer before it proceeds, then pick the mechanism. I'm assuming at-least-once delivery, so the consumer dedupes."

Expect these follow-ups: the broker is down; the same message arrives twice; events arrive out of order; a replay is older than the dedup retention; a schema changes under live consumers; consumer lag keeps growing.

30-second outline:

  1. State the interaction: does the caller wait, who owns the fact, does order matter per entity.
  2. Name the mechanism and its cost (coupling, latency, replay).
  3. State delivery as at-least-once, with the dedup key stored with the effect.
  4. Solve the dual write with an outbox or a per-effect idempotency key.
  5. Name the backstop: reconciliation on business IDs.
  6. Name one number to watch: consumer lag, DLQ depth or backlog age.

Feedback on this overview

Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.