Enterprise Application Integration Questions
Integration architecture across many heterogeneous enterprise systems, legacy and modern: how systems exchange data (synchronous calls, push, scheduled bulk or file transfer, messaging) and when each fits, point-to-point versus middleware designs, connectors and adapters, choosing a native connector, iPaaS or custom build, bridging SOAP/XML and REST/JSON, canonical data models and schema mapping, governing shared-schema change, system-of-record ownership, orchestration versus choreography, hybrid on-premises to cloud connectivity over outbound-only or flaky links, multi-tenant integration platforms with idempotent delivery and downstream rate limits, failure handling, dead-letter queues and reconciliation at integration seams, and phased delivery against poorly understood legacy systems. Excludes the design of a single API surface, API gateway and versioning mechanics, broker-level event streaming, data-platform ingestion, and vendor selection or cloud migration programmes covered elsewhere.
Explain orchestration versus choreography as integration styles. Define each, say what kind of tooling typically backs each, and show how one business process, such as routing a new lead to the right team and starting follow-up, would be implemented both ways.
Sample Answer
The idea in plain words
Both styles coordinate a business process that crosses several systems. The difference is who knows the whole process.
- Orchestration: one component, the orchestrator, holds the process definition. It calls each step in order, tracks state and decides what happens on failure. Think of a conductor telling each musician when to play.
- Choreography: nobody holds the whole process. Each system publishes events (messages saying something happened) and others react to the events they care about. Events travel through a message broker (a server that receives messages and delivers them to whoever subscribed) or an event bus (the same idea seen as a shared channel that services plug into). Think of dancers who each know their own steps and respond to the others.
Definitions and typical tooling
| Orchestration | Choreography | |
|---|---|---|
| Who controls the flow | A central orchestrator | Each participant, reacting to events |
| Where the process lives | In one definition (a workflow or flow diagram) | Spread across the subscriptions of many services |
| Typical tooling | Workflow engines (the most common example, a service that stores each run's state and timers), business process management tools (visual designers for business-owned workflows), integration platforms (iPaaS) flows, enterprise service bus orchestrations, state-machine services (a service whose runs move between named states such as scored, assigned, emailed) | A message broker or event bus with publish-subscribe topics (a publisher sends to a named topic and every service subscribed to that topic gets a copy; the publisher does not know who they are) |
| Coupling | The orchestrator knows every participant's interface | Participants know the event shape, not each other |
| Visibility | Easy: one place shows each run's state | Harder: you must trace events across services |
| Change | Edit the one definition | Change subscriptions, possibly in several services |
One process, both ways: route a new lead and start follow-up
The business rules (assumed): when a lead arrives, score it; assign it to a team by region and score; create a task for the owner; send a first follow-up email; if there is no reply in 2 days, create a reminder.
Orchestrated. A workflow RouteLead starts when the lead arrives and runs the steps itself:
- Call the scoring service. Save the score in the run's state.
- Call the assignment service with region and score. Save the owner.
- Call the task system to create the task.
- Call the email service to send the first email.
- Wait 2 days (a durable timer inside the engine: the wait is saved with the run's state, so it survives a restart of the engine instead of living only in memory). If no reply is recorded, call the task system for the reminder.
If step 3 fails, the orchestrator retries with a delay, then raises an alert or runs a compensating step (an action that undoes an earlier one, for example unassigning). The run's page shows exactly where it is.
Choreographed. The CRM (customer relationship management system) publishes a LeadCreated event. Each service reacts:
- The scoring service receives
LeadCreated, publishesLeadScored. - The assignment service receives
LeadScored, publishesLeadAssigned. - The task service receives
LeadAssignedand creates the task. The email service receivesLeadAssigned, sends the email and publishesEmailSent. The task and email steps can run at the same time. - A reminder service receives
EmailSent, sets its own timer and, after 2 days without aLeadRepliedevent (published when a reply is recorded, for example by the CRM), creates the reminder.
If the task service is down, the broker holds the event and delivers it later, but nothing in the system knows that the lead is stuck unless you build monitoring that follows the events by a shared correlation id (an id copied into every event of one lead).
Which to choose
For this example I would choose orchestration for the lead-routing process: the steps are ordered, rules are business-owned, and the sales team needs to see where a lead is. I would use events (choreography) for the side effects that do not need a decision, such as telling analytics and a dashboard that a lead was created. Choose choreography when many independent consumers need the same fact and none should be known to the publisher.
Common mistakes
- Calling a system of chained events "choreography" when one service secretly depends on exact reply timing; it is hidden orchestration.
- Building orchestration that grows into one huge workflow all teams must edit.
- Losing the correlation id, so no one can trace a lead across services.
- Forgetting failure handling: a missing step in either style leaves a lead half-processed.
Design an integration platform as a service (iPaaS) for enterprise customers: hosted connectors, a transformation layer, workflow orchestration, monitoring, and tenant isolation. Cover how a connector is built, vetted, versioned and rolled out, how you run untrusted connector code safely, and how you scale connectors on demand.
Sample Answer
The idea in plain words
An iPaaS (integration platform as a service) is a hosted product where many customers (tenants) build integrations from ready-made connectors (a packaged adapter that knows how to talk to one application, including its authentication, data model and quirks), shape the data in a transformation layer, and chain steps in workflow orchestration (a runtime that runs a flow of steps with retries and state). The platform runs other people's integration logic, and some connector code is written by third parties, so the design centres on two things: keeping tenants apart and keeping untrusted code from reaching anything it should not. A platform starting out needs, in this order: tenant-scoped data and queues, a manifest-checked connector format with immutable versions, a sandbox with a locked-down network, and per-tenant limits. Regional cells and a stated availability target come as customers require them.
Architecture in layers
- Control plane (the management side): tenant and user management, connector catalogue, flow definitions, the mapping UI, deployments, and quota settings per plan (limits on runs and concurrency). It stores configuration and metadata, not business payloads.
- Data plane (where messages actually flow): ingress (webhooks, polling, scheduled triggers) writes a job to a durable queue; workers pick jobs, run the flow's steps, call target systems, and write results. Everything here is partitioned by tenant.
- Secrets service: each tenant's credentials for third-party systems, encrypted per tenant, fetched only at call time.
- Observability: logs, metrics and traces tagged with tenant id, flow id and run id; per-tenant log views with sensitive fields masked.
How a connector is built, vetted, versioned and rolled out
- Built from a manifest (a declaration file) plus code: operations it offers, input and output schemas, the hostnames it may call (declared egress: outbound destinations it announces in advance), the credential scopes it needs, and its timeout and rate limits toward the target system. An illustrative manifest follows (generic keys invented for this example, not any product's format); the program also tests the egress rule and recomputes the sizing and availability figures used below.
import ipaddress
import json
import math
MANIFEST = {
"name": "crm-contacts",
"version": "1.4.0",
"operations": [
{"name": "list_contacts", "input": "schemas/list_in.json", "output": "schemas/contact.json"},
{"name": "upsert_contact", "input": "schemas/contact.json", "output": "schemas/contact.json"},
],
"egress_hosts": ["api.crm.example.test"],
"credential_scopes": ["contacts.read", "contacts.write"],
"limits": {"timeout_seconds": 30, "requests_per_second": 10},
}
print(json.dumps(MANIFEST, indent=1))
INTERNAL = [ipaddress.ip_network(n) for n in (
"10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "127.0.0.0/8", "169.254.0.0/16")]
def egress_allowed(host, ip):
"""Egress proxy rule: declared host, and never an internal address."""
addr = ipaddress.ip_address(ip)
if host not in MANIFEST["egress_hosts"]:
return "deny (host not declared)"
if any(addr in net for net in INTERNAL):
return "deny (internal address)"
return "allow"
for host, ip in [("api.crm.example.test", "203.0.113.10"),
("evil.example.test", "203.0.113.99"),
("api.crm.example.test", "10.0.0.5"),
("api.crm.example.test", "169.254.169.254")]:
print(host, ip, "->", egress_allowed(host, ip))
per_worker = 4 / 0.5
print("jobs/s per worker:", per_worker)
print("workers at 100% busy:", math.ceil(300 / per_worker), "| at 60% target:", math.ceil(300 / (per_worker * 0.6)))
print("per-tenant cap (20% of 300/s):", 0.2 * 300, "jobs/s")
month = 30 * 24 * 60
print("downtime allowed at 99.95%:", round(month * 0.0005, 1), "min/month")
print("two in series at 99.95% each:", round(0.9995 ** 2 * 100, 3), "%")
each = math.sqrt(0.9995)
print("each of two needs:", round(each * 100, 3), "% =", round(month * (1 - each), 1), "min/month")
Output:
{
"name": "crm-contacts",
"version": "1.4.0",
"operations": [
{
"name": "list_contacts",
"input": "schemas/list_in.json",
"output": "schemas/contact.json"
},
{
"name": "upsert_contact",
"input": "schemas/contact.json",
"output": "schemas/contact.json"
}
],
"egress_hosts": [
"api.crm.example.test"
],
"credential_scopes": [
"contacts.read",
"contacts.write"
],
"limits": {
"timeout_seconds": 30,
"requests_per_second": 10
}
}
api.crm.example.test 203.0.113.10 -> allow
evil.example.test 203.0.113.99 -> deny (host not declared)
api.crm.example.test 10.0.0.5 -> deny (internal address)
api.crm.example.test 169.254.169.254 -> deny (internal address)
jobs/s per worker: 8.0
workers at 100% busy: 38 | at 60% target: 63
per-tenant cap (20% of 300/s): 60.0 jobs/s
downtime allowed at 99.95%: 21.6 min/month
two in series at 99.95% each: 99.9 %
each of two needs: 99.975 % = 10.8 min/month
The manifest lists two operations, one allowed host, the permissions (scopes) the connector asks for and its limits. The four egress lines show the proxy rule from the network bullet under running untrusted code: a call to the declared host at an ordinary external address is allowed; an undeclared host is denied; and a declared host that resolves to a private address or to the metadata address 169.254.169.254 is denied, which is what stops a request being redirected to the platform's own internals. Addresses here are documentation-range examples. The remaining lines are the sizing and availability arithmetic worked below.
- Vetted before listing: automated checks (a dependency scan, which looks up known vulnerabilities in the libraries the connector uses; static analysis, which inspects the code without running it for dangerous patterns; and a manifest-versus-behaviour check that it only calls declared hosts), contract tests against the target's sandbox with recorded fixtures, failure tests (timeouts, 429, malformed replies), and review by a platform engineer for third-party submissions. Sign the approved artifact so workers run only signed builds.
- Versioned immutably:
1.4.0never changes once published. A flow pins a version. Breaking changes need a new major version; tenants migrate on their own schedule within a published support window. - Rolled out progressively, a canary-style rollout (the new version reaches a small slice first and widens only while it looks healthy): internal tenants, then, as example stages, 1 percent, 10 percent, 50 percent, 100 percent of tenants that opted into automatic updates, with automatic rollback if error rate or latency passes a threshold compared with the previous version. Security fixes may be forced after notice.
Running untrusted connector code safely
Treat every connector as hostile. Layers, each limiting what a compromise can do:
- Run each execution in a sandbox with a strong boundary, as a non-root user, read-only file system, no shared disk between tenants. Three strengths exist. A container with a system-call filter (a list of the requests to the operating system that the code is allowed to make; everything else is refused) is the cheapest and fastest to start, but it shares the host's kernel, so a kernel flaw is a way out. A lightweight virtual machine (a minimal virtual machine with its own kernel) puts a hardware boundary around the code at the cost of more memory and a slightly slower start. A user-space kernel (a program that answers the sandboxed code's operating-system requests itself, so it never reaches the real kernel) sits between the two, with some overhead on system-call-heavy work. A reasonable start: connectors the platform team wrote run in the hardened container; third-party code goes in a lightweight virtual machine or a user-space kernel.
- Resource limits: CPU, memory, execution time and output size, so one run cannot hog a node.
- Network: deny all outbound traffic except the connector's declared hostnames through an egress proxy (a gateway that all outbound connections must pass through, which checks each destination), and block internal addresses (the cloud metadata address, private ranges), which stops server-side request forgery (tricking the platform into calling its own internal services).
- Credentials: the connector never sees the secrets store. The platform injects only the one tenant's credential for the call, scoped and short-lived where the target supports it.
- No cross-run state: a fresh sandbox per run or a clean-up verified between runs.
- Everything the connector emits is logged with tenant id; an anomaly (unexpected host, spike in output) suspends that connector version.
Tenant isolation, quotas and data residency
- Isolation: every queue message, database row, cache key and log line carries a tenant id enforced in one data-access layer, not remembered by each feature. Sensitive tenants can get dedicated worker pools or dedicated queues.
- Per-tenant limits (the "noisy neighbour" defence: stopping one tenant's heavy use of shared capacity from slowing the others): a concurrency cap and a rate limit per tenant, using a token bucket (a counter that refills at a steady rate and allows short bursts), and a quota on runs per day by plan. Over-limit work waits in that tenant's own queue instead of slowing others. Rate limits also toward each target system, so one tenant's flow cannot get the platform's shared IP blocked.
- Data residency (keeping a customer's data inside a chosen region; the EU's GDPR data protection regulation is a common reason customers ask for it): deploy the data plane as regional cells (independent copies of the whole data plane in each region: queues, databases, workers, logs). A tenant is pinned to a region at signup, and its payloads, run history and logs stay there. The control plane holds only configuration that does not include personal data, or is replicated per region. Cross-region support access is controlled and logged.
Scaling connectors on demand
Scale workers on queue depth and age. Worked example (assumed numbers): arrival 300 jobs per second, each job takes 0.5 seconds, each worker runs 4 jobs at once.
- One worker handles 4 / 0.5 = 8 jobs per second.
- At 100 percent busy you need 300 / 8 = 37.5, so 38 workers. That leaves no headroom, so target 60 percent utilisation: 300 / (8 x 0.6) = 62.5, so 63 workers.
- Per-tenant fairness: cap one tenant at 20 percent of the 300 jobs per second, which is 60 jobs per second, so a runaway flow cannot take more.
Scale-out is fast for stateless workers; for rarely used connectors scale to zero (run no workers while idle) and accept a cold start (the delay while a fresh worker starts before its first job), and keep a small warm pool for latency-sensitive ones. Autoscaling must not exceed a target system's own limits, so each connector also has a global concurrency ceiling.
Availability of 99.95 percent
Enterprise customers usually ask for a contractual availability target, so the platform states one; 99.95 percent is an example. It changes the design because every component on the path of a job has to be more reliable than the promise. Per 30-day month (43,200 minutes) 99.95 percent allows 43,200 x 0.0005 = 21.6 minutes of downtime. Components in series multiply: two dependencies that must both work, each at 99.95 percent, give 0.9995 x 0.9995 = 0.9990, about 99.90 percent, so each in-path component needs a higher target than the whole. To keep the whole at 99.95 percent with two such components, each needs the square root of 0.9995, which is 99.975 percent, or 10.8 minutes of downtime a month each instead of 21.6. Design for it: regional cells with multiple zones, durable queues so ingress accepts work even when workers are down, no single shared database in the hot path, and graceful degradation (a failing target slows only the flows that use it). The promise applies to the platform accepting and running jobs, not to the third-party systems it calls.
Common mistakes
- Letting connectors read the secrets store.
- One shared worker pool and queue with no per-tenant limits.
- Mutable connector versions that change a tenant's flow overnight.
- Residency handled only for the database while logs and queues still cross regions.
Running the code
Save the program as connector_demo.py and run python connector_demo.py (Python 3.12, standard library only).
Large multi-service integrations mix long-running multi-step business processes with high-volume event propagation. Discuss the trade-offs between orchestration and choreography, propose an architecture that uses each where it fits, and explain how you keep failure isolation, observability and transaction semantics across it.
Sample Answer
The idea in plain words
Orchestration (one coordinator runs a process step by step) and choreography (services react to each other's events) are not rivals to pick between once for a whole company. They fit different kinds of work.
- Long-running multi-step business processes (take an order, reserve stock, charge a card, ship, invoice) have an order, deadlines, and a need to undo earlier steps if a later one fails. They benefit from an explicit owner of the process: orchestration.
- High-volume event propagation (an order was placed, so update search, analytics, notifications, recommendations) is a fan-out (one event delivered to many consumers) where many independent consumers react to a fact. It benefits from loose coupling: choreography.
The architecture is therefore hybrid: orchestrate inside a bounded process (one with a clear start and end, owned by one team), choreograph between domains (business areas such as ordering, inventory and billing; events that record something meaningful that happened in the business, like OrderPlaced, are called domain events). Four ideas carry the design and are worth naming first: the saga with compensations, the transactional outbox, idempotent consumers and a correlation id. Timeouts, circuit breakers, bulkheads, backpressure and trace headers harden it further. The hard part is the shared concerns: failure isolation, observability and transaction semantics, because no single database transaction spans the services.
Trade-offs
| Concern | Orchestration | Choreography |
|---|---|---|
| Process visibility | One run record per process | Reconstructed from events |
| Coupling | Orchestrator knows every participant | Publisher does not know consumers |
| Failure handling | Central: retry, timeout, compensate | Per consumer: retry, dead-letter queue (a holding area for messages that kept failing) |
| Throughput | Limited by the orchestrator's state storage per run | Scales with the broker and consumer count |
| Risk | The orchestrator becomes a bottleneck or a god service (one service that knows and does everything, so every team depends on it) | Cyclic or hidden dependencies; hard to see the whole |
| Change | Edit one definition | Edit subscriptions across teams |
The proposed architecture
Client -> Order service (owns the order)
| starts
v
Order saga orchestrator --commands--> Inventory | Payment | Shipping | Invoicing
| (durable state per run) <--replies/events--
|
+--> transactional outbox --> event bus (topics: OrderPlaced, OrderCancelled, StockChanged)
|-> Search indexer (own queue + DLQ)
|-> Analytics (own queue + DLQ)
|-> Notifications (own queue + DLQ)
|-> Recommendations (own queue + DLQ)
- The saga orchestrator owns the order-fulfilment process. A saga is a sequence of local transactions, each in one service, where a failure is handled by running compensating actions (undo steps) for the steps that already completed, instead of a distributed rollback.
- Events leave the process through a transactional outbox: the service writes the business change and an outbox row in the same local database transaction, and a relay publishes the outbox rows to the bus afterwards. This avoids the dual-write problem (updating the database and publishing a message are two actions, and a crash between them loses or invents an event). Concretely: if the service commits order 812 and crashes before publishing, search and analytics never hear of order 812 (a lost event); if it publishes first and the commit then fails, they hear of an order that does not exist (an invented event). With the outbox, the order row and its outbox row commit together or not at all; after a crash the relay finds the unpublished outbox row on restart and publishes it, possibly twice, which is why consumers must dedupe.
- Consumers of high-volume events each have their own queue, so a slow consumer does not delay the others.
Saga and compensation design
Each step before the pivot (defined below the table) must have a defined compensation, and compensations must be safe to run twice (idempotent) because they will be retried.
| Step | Action | Compensation | Notes |
|---|---|---|---|
| 1 | Reserve stock | Release the reservation | Reservation expires on its own after a time limit as a backstop |
| 2 | Authorise the payment (hold funds) | Void the authorisation | Authorise first, capture later, so a cancel is a void rather than a refund |
| 3 | Create the shipment request | Cancel the shipment request | Allowed only before the carrier has collected |
| 4 | Capture payment and send invoice | None in the saga: after the pivot the saga only moves forward and retries until the step succeeds | Runs only after the pivot point below. A later refund and credit note is a separate business process, such as a return, not a saga rollback |
The pivot transaction is the step after which the saga can no longer go backwards (for example, goods handed to the carrier). Place steps that can fail before it, and steps after it must be retried until they succeed, not compensated.
Worked trace, assumed timings. The saga fails at step 3:
| Time (s) | Event | Saga state |
|---|---|---|
| 0 | Order placed | STARTED |
| 1 | Stock reserved | STOCK_RESERVED |
| 3 | Payment authorised | PAYMENT_AUTHORISED |
| 4 | Shipment request rejected (address invalid) | SHIPPING_FAILED |
| 5 | Void payment authorisation (compensation of step 2) | COMPENSATING |
| 6 | Release stock (compensation of step 1) | COMPENSATING |
| 7 | Order marked cancelled, OrderCancelled event published through the outbox | CANCELLED |
For contrast, the same failure without a coordinator (choreography) looks like this: OrderPlaced makes inventory reserve stock and publish StockReserved; payment reacts to that and publishes PaymentFailed; inventory reacts to PaymentFailed by releasing the stock. It works, but nobody holds a record of the whole order, so "where is order 812?" has to be answered by reading events from three services.
Compensation runs in reverse order of the completed steps: step 2 is undone, then step 1. If a compensation itself fails, the orchestrator retries it with exponential backoff, for example waits of 2, 4, 8, 16 and 32 seconds, which total 2+4+8+16+32=62 seconds of waiting across 5 retries. Doubling gives a struggling dependency more breathing room each time while keeping the number of attempts small. Jitter means each wait is drawn at random between 0 and the doubled value (full jitter): without it, 100 sagas that failed at the same moment would all retry at exactly 2 seconds, then all at 4, hitting the dependency in synchronised waves; with it their retries spread out. With jitter the listed waits are upper bounds, so 62 seconds is the longest the five waits can total. After that the saga goes to a manual-intervention state with an alert, because silently abandoning a half-undone order is the worst outcome.
Isolation: between steps, other readers can see intermediate states (stock reserved, order not yet confirmed). Use explicit states such as PENDING in the data so screens and other services treat them correctly (a "semantic lock"). Example: while order 812 is PENDING, the screen shows "being processed", and other services refuse to edit or ship it until the saga reaches CONFIRMED or CANCELLED.
Failure isolation
- Timeouts on every call and a limit on retries, so one slow dependency cannot hold all workers.
- Circuit breakers (stop calling a dependency for a while after repeated failures) and bulkheads (separate worker pools per dependency: if payment calls get 10 workers and search calls get 10, a slow search service can use up only its own 10).
- Per-consumer queues and dead-letter queues on the event side, so one poisonous message (one that fails every time it is processed, for example because it is malformed) or slow consumer does not block others.
- Idempotent consumers: delivery is at-least-once (a message may arrive more than once), so each consumer records the event ids it has handled. Tiny example: event
e-77arrives; the consumer lookse-77up in itsprocessed_eventstable, finds nothing, applies the change and insertse-77in the same local transaction. Ife-77arrives again, the lookup finds it and the consumer skips it. - Backpressure: the orchestrator limits concurrent runs, so a burst of orders queues rather than overwhelms inventory.
Observability
- Create a correlation id at the start of the process and copy it into every command, event and log line.
- Propagate trace context between services using the W3C
traceparentheader (a standard header carrying a trace id, which is shared by every hop of one request tree, and the id of the calling hop) on HTTP calls; its shape istraceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01(version, trace id, parent span id, flags) and the same values in message metadata, so a distributed trace (the recorded tree of calls one request caused across services) shows the whole order across both styles. - Expose saga state as data: count of runs per state, age of the oldest run in each state, compensations in progress, dead-letter queue depth.
- Alert on age, not only on errors: a saga stuck in
COMPENSATINGfor 10 minutes matters more than one failed call.
Transaction semantics, stated plainly
There is no distributed ACID (atomic, consistent, isolated, durable) transaction here. Each service commits locally. Overall consistency is eventual: the system is correct once the saga finishes or fully compensates, and the states in between are visible and defined. Guarantees come from: local transactions, the outbox, at-least-once delivery, idempotent handlers, and compensations.
Judgment
I would orchestrate the order saga with a durable workflow engine or a state machine service, use the outbox to publish domain events, and choreograph every downstream consumer from those events. I would keep orchestrations small and owned by one team each, and never let an event consumer start a second hidden saga.
Common mistakes
- Publishing events directly after a database commit without an outbox.
- Writing compensations that are not idempotent, or that assume the earlier step succeeded.
- Putting everything, including analytics fan-out, in the orchestrator.
- No visibility of stuck sagas.
A customer asks whether order placement should call their ERP synchronously, with the user waiting, or go through asynchronous messaging. The UI needs near-real-time feedback, the ERP has occasional latency spikes, and the business needs reliable delivery. Walk through your decision criteria and propose a design.
Sample Answer
The idea in plain words
A synchronous call means the order service sends the request to the ERP (enterprise resource planning system, the back-office system that holds orders, stock and finance) and waits for the answer before replying to the user. Asynchronous messaging means the order service stores the order itself, replies at once that it was received, and passes the order to the ERP later through a queue (a store that holds messages until a consumer takes them). The deciding insight: the user needs fast feedback, not necessarily the ERP's final answer. So accept and record the order locally in the user's request, tell the user it is "received, being confirmed", and finish the ERP step in the background with guaranteed delivery. Make only the cheap checks synchronous.
Decision criteria, in the order I would ask
- Does the user's next step depend on the ERP's answer? If a price or stock figure must come from the ERP to show the page, that read is synchronous (or served from a recent copy). If only the creation of the order needs the ERP, it can wait.
- How bad is a wait or a failure? ERP latency spikes are stated. If the spike exceeds what the user will wait, a synchronous design turns an ERP slowdown into a visible outage.
- How bad is losing or duplicating an order? The business needs reliable delivery, so the order must be stored durably before any reply, and the ERP must not create it twice.
- Can the ERP say no later? (credit hold, invalid item). If yes, the design needs a visible "rejected" status and a way to tell the user.
- How much can the ERP take at once? If it has limited concurrency, a queue protects it.
The design
- The user submits an order. The order service writes the order row with status
pending_erpand, in the same database transaction, a row in an outbox table (a table of messages waiting to be sent, written in the same transaction as the business data so neither can exist without the other). - It replies
202 Accepted(RFC 9110: the request was accepted for processing but processing is not complete) with a status location. Illustrative exchange (not a real capture):
POST /orders HTTP/1.1
Host: shop.example
Content-Type: application/json
Idempotency-Key: 5f1c2a9e-0b7d-4d1e-9a52-3c8e1f0a7b44
{"items":[{"sku":"A-100","qty":2}]}
HTTP/1.1 202 Accepted
Location: /orders/ord_7421
Content-Type: application/json
Content-Length: 40
{"id":"ord_7421","status":"pending_erp"}
Field notes: Idempotency-Key is a client generated unique value so a double click or retry returns the same order (it is a convention used by some APIs and an IETF draft, not a finished standard, so the service defines its behaviour). Location points at where the user interface can poll the order status. The body is 40 bytes, which is the Content-Length.
3. A relay process reads the outbox and publishes each order to the queue. The queue gives at-least-once delivery (a message is never lost but can arrive twice).
4. An ERP adapter takes the message and calls the ERP using the order id as the ERP's external reference. Because of at-least-once delivery, it first checks whether the ERP already has that reference, or uses the ERP's own idempotency feature if it has one, so a repeat does not create a second order.
5. Retries use exponential backoff with jitter (waits that double and are randomised). After a set number of attempts the message goes to a dead-letter queue (a holding area for messages that kept failing), and an alert fires.
6. When the ERP confirms, the adapter updates the order status to confirmed (or rejected with a reason). The user interface sees it by polling /orders/ord_7421 or by a push channel (server-sent events or a websocket), and the customer also gets an email for rejection.
7. Cheap sync checks stay in the request: validate the input, check stock or price against a copy refreshed from the ERP, show its age if it matters.
Worked example (all inputs are assumptions)
Assumptions: peak 5 orders per second; normal ERP latency 0.3 seconds; spike latency 8 seconds for 120 seconds; the user interface gives up at a 3 second timeout; during the spike the ERP can process 2 orders per second; after it recovers it can process 12 orders per second.
Synchronous design during the spike.
- In flight calls (arrival rate x latency, Little's law): normal 5 x 0.3 = 1.5; spike 5 x 8 = 40. A pool of 20 worker threads is exhausted, so even calls to unrelated features queue behind the stuck ones.
- Every order sent during the spike takes 8 seconds, past the 3 second timeout: 5 x 120 = 600 orders show an error. Worse, the outcome is unknown to the caller, because the ERP may still have processed it. A user retry then risks a duplicate unless the ERP call is idempotent.
Asynchronous design during the same spike.
- All 600 orders are accepted in the request and shown as pending. No error is shown.
- Backlog growth during the spike: arrivals 5 per second minus ERP rate 2 per second = 3 per second net, for 120 seconds: 3 x 120 = 360 orders waiting at the end of the spike.
- After recovery, net drain = 12 - 5 = 7 per second, so the backlog clears in 360 / 7 = 51.4 seconds, about 52 seconds.
- User impact: pending for longer for some orders, no failures, no duplicates.
Sizing note: the queue and the status page must be able to hold 360 more rows without trouble; set an alert on queue depth and on the age of the oldest unconfirmed order (for example, page someone if an order is unconfirmed for 15 minutes; the number is a policy choice for the business).
Recommendation
Use the asynchronous design with an outbox and idempotent ERP adapter for order creation, and keep the small synchronous checks. I would choose synchronous only if the ERP is reliably fast, the business cannot accept a pending state, and a failure shown to the user is acceptable. Trade-offs I accept: eventual confirmation (the user sees "pending"), a status channel to build, and more moving parts to monitor (outbox lag, queue depth, dead letters). A middle option is a short synchronous attempt with a timeout (for example 2 seconds) and fallback to the queue when it fails; it improves the median case but still needs all the idempotency and outbox machinery, so it costs more than it saves unless most users want instant confirmation.
Common mistakes
- Publishing to the queue after the database commit as a separate step: a crash in between loses the order.
- Retrying a timed out synchronous call without idempotency.
- Returning
200 OKwith no status, so the user cannot tell pending from done. - Forgetting the rejected path.
- No alert on queue age.
Compare keeping a single system of record for master data with letting several systems be authoritative for different parts of it. Cover availability, consistency and governance, describe a case where distributed ownership is the better choice, and say what operational controls you would add to either approach.
Sample Answer
The idea in plain words
Master data is the shared reference information about the core things a business runs on (customers, products, suppliers), as opposed to transactions such as orders. A system of record (SoR) for a piece of data is the one system whose copy wins when copies disagree. The question compares two ways of assigning that authority: one system is authoritative for the whole record (single SoR), or different systems are authoritative for different parts (distributed ownership, also called attribute-level or domain-level ownership). The one idea: either way, for any single field there must be exactly one place that is allowed to write it. The real choice is whether that place is the same for all fields.
Other terms. Consistency means all readers see the same value; eventual consistency means copies agree after a delay once changes stop. Replication lag is that delay. Reconciliation is a job that compares copies and reports or repairs differences. Governance here means who decides the rules for the data (formats, who may change what, quality standards). A data steward is the named person accountable for the quality of one data area.
Comparison on the three axes asked
Availability (can people do their work when something is down).
- Single SoR: every write to any part of the record depends on one system. If it is down, all writes stop. Reads can continue from copies that were replicated out, but they get stale.
- Distributed: a write to a field depends only on the system that owns that field. An outage of one owner stops changes to its fields only. The cost shows when one business action needs fields from several owners: availability multiplies. Assumed example: two owners, each 99.9 percent available, an action needing both live is available 0.999 x 0.999 = 0.998001, about 99.8 percent. In a 30 day month (30 x 24 x 60 = 43,200 minutes), 99.9 percent allows 43.2 minutes down, and 0.998001 allows about 86.4 minutes down (0.001999 x 43,200 = 86.36). A single SoR gives the single figure for all writes; it is simpler, not necessarily better.
Consistency.
- Single SoR: simplest. All edits pass one place, so ordering and validation rules live once. Copies elsewhere lag by the replication lag (assume 5 seconds), and that is the only disagreement.
- Distributed: each field is consistent within its owner, but rules that span fields owned by different systems (billing address must match tax region) cannot be enforced by one database transaction. They are enforced by events and checks after the fact, so there are windows when the whole record is inconsistent. Also the owning systems must agree on the shared key (one customer id) or matching rules to say two records are the same customer.
Governance.
- Single SoR: one team owns the schema, quality and access rules. Clear accountability, but a bottleneck: every team that needs a new attribute queues behind it.
- Distributed: each domain owner moves at its own speed and knows its data best, but you need an explicit ownership matrix, shared definitions and a council to settle overlaps. Without them you get two systems each believing it owns the email address.
A case where distributed ownership is the better choice (assumed scenario)
A company has a finance system and a support system. Finance is the right owner of legal name, billing address, tax id and credit terms: it has audit rules, approval workflow and restricted access. Support is the right owner of contact preferences, preferred language and open-case flags: they change many times a day and finance should not be on the path of each change. Forcing both into one master means either finance's controls slow support, or support's pace weakens finance's controls. Giving each its own fields, with one customer id shared and changes published as events, is better. Other good reasons: data residency rules that require some fields to stay in one region; or a merger where two systems cannot be merged for a year.
Worked conflict, to show the key rule. Assume the customer email could be written by both CRM and support, and both write at nearly the same time (CRM at 10:00:05, support at 10:00:07 by their own clocks). A "last write wins" rule depends on those clocks being in step; with skew of even 3 seconds in the wrong direction the older change wins. The fix is not a smarter tie-break rule but removing the case: give email one owner (say CRM) and make support send a change request to it.
Operational controls, for either approach
- An ownership matrix: for every field, the owning system, steward and allowed writers. Published and versioned.
- Change events with a version and an event id, so downstream copies update and can drop duplicates.
- Reconciliation: a scheduled comparison of copies against the owner, with a mismatch count, a threshold that pages someone, and a documented repair (the owner's value overwrites the copy, not the reverse).
- Monitoring: replication lag, failed updates in a dead-letter queue (a holding area for messages that could not be processed), and age of the oldest unapplied change.
- Access and audit: only the owner can write its fields; every change records who and when.
- Matching and merge rules for duplicate customers (single SoR: in one place; distributed: agreed across systems), with a human review path.
- Runbooks and drills: what to do when the owner is down (queue changes, show read only), and how to promote a standby.
For a single SoR add a replica or read cache so reads survive an outage. For distributed add a cross-field validation job for the rules no single system can enforce.
My recommendation
Start with a single SoR for a small organisation or a young landscape: fewer moving parts, one place to fix. Move to distributed ownership by field group when separate teams with different controls and change speeds are already fighting over one master, and only with the ownership matrix and reconciliation in place first. What would flip it: a hard cross-field rule that must hold at all times pushes toward one owner for those fields.
Common mistakes
- Letting two systems write the same field and relying on last write wins.
- Calling a system the SoR without enforcing that others cannot write.
- Treating reads from a copy as authoritative.
- Skipping reconciliation because "events are reliable".
Unlock Full Question Bank
Get access to all 9 Enterprise Application Integration interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.