liveBook · Manning

Real-time processing

As explained in Apache Kafka in Action

Real-time data processing handles data with sufficiently low latency for systems to react soon after events occur.

A customer should not have to wait for tomorrow’s batch job to see that a product is out of stock. Real-time processing handles events soon after they occur, so systems can update information and react while it is still useful. It contrasts with batch processing, which collects data and produces results at scheduled intervals. section 12.1.2

With Kafka, a producer writes an event to a topic and consumers process it as needed. Kafka persists the event stream, so a consumer that fails can resume processing and a new service can also read older events. Services can therefore exchange data asynchronously without requiring every consumer to be available at the moment an event occurs. section 1.1 section 1.2

An online-store price change

When a product’s price changes, a stream processor can handle that event almost immediately rather than waiting for a scheduled update. An out-of-stock event can likewise prompt a prompt inventory update. These fast responses are valuable, but the current view may be an intermediate result: later events can change it. section 12.1.2

Figure 12.1 n batch processing, a large amount of data is processed at-once at specific times and the results are definite. When processing one event at a time, data is processed almost immediately, but it’s difficult to provide definite results, as the system is eventually consistent.

Compare scheduled batches with event-at-a-time processing: faster updates come with results that may change as further events arrive. section 12.1.2

Real time is not automatically the right choice. Batch jobs can provide definitive results for deadline-based reports and may reduce costs when run overnight. Kafka can feed those jobs too, or support less frequent message processing. Choose the processing schedule according to how quickly a result is needed and whether it must be final. section 12.1.2 section 1.2

How Apache Kafka in Action covers it

How deep it goes
Explains the batch-versus-stream distinction and the trade-off between prompt, changeable results and definitive batch results; does not specify latency targets.
Examples
Uses delayed account balances and parcel tracking, alongside online-store price changes, stock updates, and overnight transaction reports.
What it assumes
Introduces producer-consumer communication and batch-versus-stream processing through enterprise examples without requiring prior Kafka knowledge.
What you can do after
Evaluate/understand when prompt event handling is preferable to scheduled processing and when final batch results remain useful.
How it connects
Links stream processing to Kafka topics, producer-consumer communication, persistent event streams, asynchronous microservices, and eventual consistency.

Also explained in

Compare how 4 books explain real-time processing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Apache Kafka in Action. The section links point to the parts of the book it draws on.