Skip to content

From nightly batch to real time

Aspect Aspect
Typical organization A retailer, lender, insurer or logistics company whose systems exchange data in overnight jobs
Symptoms Stock, balances or order status are a day old; nightly jobs overrun; failures found in the morning
Root cause Integration built on scheduled file exports and bulk loads
Usual fix Capture changes as they happen and stream them to every system that needs them
Patterns Event-driven architecture, messaging, change data capture, transactional outbox
  • The website shows items in stock that sold out this morning.
  • Customer service can’t see a payment made an hour ago.
  • The overnight batch window is full, and a late job delays everything the next day.
  • When a nightly job fails, the business finds out at 9 a.m.
  • Fraud or risk checks run hours after the transaction.

Batch integration was the natural choice when systems were few and overnight was quiet. As the business moved online and around the clock, the overnight window shrank and expectations of freshness rose. The batch jobs themselves are rarely the problem; it’s that the data only moves once a day.

Option When it fits Cost and risk
Run batches more often Freshness of an hour is enough Low. Quick, but load and failure handling get harder
Change data capture (CDC) from the database log The source can’t easily be changed to publish events Medium. Little change to the source; events mirror tables
Publish business events from the application, with an outbox You own the source application Medium. Events carry business meaning, such as “order placed”
Call APIs synchronously One consumer needs an answer immediately Low to medium. Couples systems tightly if overused
  1. Start with the freshness that matters most, such as stock levels or payment status, and agree a target, for example “within one minute”.
  2. Capture changes at the source, with CDC for systems you can’t change and an outbox for those you can, so an event is never lost when a database write succeeds.
  3. Stream them through a durable, replayable broker, so new consumers can start from any point and failed ones can catch up.
  4. Make consumers idempotent, because events can arrive more than once.
  5. Keep the batch running in parallel until the streaming path is proven, then retire it.
Changes flow as they happen1. Applications you own write an event to an outbox table in the same transaction as their data. 2. A relay publishes outbox events to a durable broker. 3. Change data capture reads the log of databases you can't change. 4. Every consumer receives changes within seconds and can replay history if it falls behind.Event streaming Store systemssales as they happen Order servicewrites + outbox Legacy databasecan't be changed Publisheroutbox relay Event brokerdurable, replayable Change data capturereads the DB log Stock servicelive availability Customer servicesees payments now Analyticsfresh within minutes1234
Changes flow as they happen Every change is captured once and streamed; each consumer reads at its own pace and can replay history.
  1. Applications you own write an event to an outbox table in the same transaction as their data.
  2. A relay publishes outbox events to a durable broker.
  3. Change data capture reads the log of databases you can't change.
  4. Every consumer receives changes within seconds and can replay history if it falls behind.
  • Ordering and duplicates. Events can arrive out of order or twice; design consumers for both.
  • Schema changes now break consumers in real time. Version events and register their schemas.
  • More moving parts to operate: a broker, connectors and consumer lag to monitor.

Data reaches consumers within the agreed time, the batch window shrinks or disappears, and failures are noticed in minutes instead of the next morning.

  • LinkedIn streamed database changes and activity through Kafka.
  • Uber cut data latency from a day to under an hour with incremental ingestion.
  • Stripe shows why safe retries need idempotency.

Written and edited by Abhinav Taduka, enterprise software architect.