Scrivio Interview library
DesignAdvanced6 min read · updated 12 November 2026

When would you choose Kafka Streams inside a Spring Boot service, and when a separate stream processing platform such as Apache Flink, for an organisation building real-time features?

I would choose Kafka Streams inside a Spring Boot service when the processing reads from Kafka and writes to Kafka, belongs to one team's domain, and has moderate state, because it is just a library that deploys with the service and needs no separate cluster. I would choose a platform such as Apache Flink when we need richer event-time handling, many sources and sinks, very large state or centrally operated cross-domain jobs. Team skills and whether a platform team will run a shared cluster weigh heavily, and many organisations end up with both: Kafka Streams for service-local processing and Flink for cross-domain analytics.

Why this question is asked

Real-time features, such as live recommendations, fraud signals and up-to-date dashboards, all need stream processing, and the choice of engine shapes who builds it, who runs it and what it costs for years. Interviewers ask this design question at senior levels to see whether we can match a technology to an organisation, not just compare feature lists. In this answer, we will see what kind of thing each one is, how they compare on processing features, how each scales and recovers, what the organisational factors are, and why a mixed model is common.

1A Library Versus a Platform

Kafka Streams is a Java library. We add it to a Spring Boot application, define a topology, and the processing runs inside our service's JVM. Scaling means running more instances of the service; Kafka's consumer group protocol shares the input partitions between them. There is no separate cluster, no job submission and no extra infrastructure beyond Kafka itself. The team that owns the service owns the processing, deploys it with its normal pipeline and monitors it like any other service.

Apache Flink is a distributed processing engine. Jobs are submitted to a Flink cluster, with a JobManager that coordinates and TaskManagers that run the work, often on Kubernetes through the Flink operator or as a managed cloud service. Flink takes care of distribution, checkpointing and recovery itself, and supports many inputs and outputs. That power comes with a system to run, upgrade and understand.

Step throughWhere the processing runs
  1. Kafka Streams: Spring Boot service instancesthe topology runs inside each JVM
  2. Kafka: input, output, changelog, repartition topicsthe only infrastructure
  3. Flink: JobManagerschedules jobs, coordinates checkpoints
  4. Flink: TaskManagersrun operators, hold state
  5. Flink: checkpoint storage (e.g. S3)snapshots for recovery
  6. Sources and sinksKafka, databases, files, CDC, ...

6 layers, from the top down. Step through them one at a time.

Kafka Streams needs only Kafka; Flink is its own distributed system.

2Comparing Processing Features

Both handle stateful processing with exactly-once guarantees, windows and joins, and both have good support for event time, meaning they process by when an event happened rather than when it arrived. Flink goes further: watermarks give fine control over late and out-of-order events, it has rich windowing, complex event processing, a mature SQL layer, and one engine for both streaming and batch.

The biggest practical difference is connectivity. Kafka Streams reads from and writes to Kafka only; anything else goes through Kafka Connect or our own code. Flink has connectors for Kafka, databases, change data capture, files and object storage, and many other systems, so a job can join a Kafka stream with a database's change stream and write to a data lake in one place.

Kafka Streams and Flink side by side
AspectKafka StreamsApache Flink
DeploymentLibrary inside the serviceSeparate cluster or managed service
Sources and sinksKafka onlyMany connectors, Kafka included
Event time and late dataGood: windows, grace periodsRicher: watermarks, CEP, SQL
Scaling unitInput partitions and instancesOperator parallelism, rescalable
State recoveryReplay compacted changelogsRestore from snapshots
Who operates itThe service teamUsually a platform team

3Scaling and State

Kafka Streams scales by partitions: the maximum parallelism of a sub-topology is the number of partitions of its input topics. With 24 partitions we can usefully run up to 24 stream threads in total. To go beyond that, we must add partitions, which remaps keys.

State is the other limit. Kafka Streams keeps state in local RocksDB stores backed by changelog topics. When an instance fails or the application is rescaled, a task's state is restored by replaying its changelog. For a few gigabytes per task this is quick, but with hundreds of gigabytes, restores can take a long time; standby replicas help, at the cost of keeping full copies. Flink takes periodic snapshots of state to durable storage such as S3, incremental for RocksDB state, and restores from them, and it can rescale a job to a different parallelism from a savepoint. For very large state and frequent rescaling, that model is easier to live with.

4The Organisational Factors

Often the deciding factors are people, not features. Kafka Streams needs Java and Kafka skills, which a Spring Boot team usually has, and it fits a model where each team owns its processing end to end. Flink needs knowledge of a new engine, its deployment and tuning, and for most organisations that means a platform team that runs the Flink infrastructure, upgrades it and helps product teams use it.

So we ask: will someone run a shared stream processing platform as a product, with on-call and support? If yes, Flink becomes attractive for work that spans domains or needs its features. If not, asking each product team to run its own Flink cluster is usually a mistake, and Kafka Streams inside their services is the safer choice.

Step throughChoosing an engine for a new real-time feature
  1. Kafka in and Kafka out only?
    YesNext questionNoFlink, or Kafka Connect + Kafka Streams
  2. Owned by one team, moderate state?
    YesNext questionNoFlink on the shared platform
  3. Needs watermarks, CEP or SQL at scale?
    YesFlink on the shared platformNoKafka Streams in the service

3 steps in order. Play them, or step through them one at a time.

5Why a Mixed Model Is Common

In practice many organisations use both. Product teams use Kafka Streams inside their Spring Boot services for processing that belongs to their domain: enriching their own events, maintaining materialised views, computing per-customer aggregates. A platform team runs Flink, often with Flink SQL, for cross-domain analytics, joins across many sources, data lake ingestion and heavy event-time work.

Kafka is the shared backbone between them: the output of a team's Kafka Streams application is a topic, and a Flink job can read it like any other. Clear guidelines on which kind of work goes where, plus shared conventions for topics and schemas, keep the two worlds from duplicating each other.

6Follow-up questions

Couldn't we use Spring Cloud Stream instead?

Spring Cloud Stream is a programming model over binders such as Kafka; its Kafka Streams binder still runs Kafka Streams underneath. It changes how we write and configure the application, not where processing runs, so the same trade-offs apply.

What about running Flink jobs inside a Spring Boot service?

It is technically possible to run Flink in local mode, but then we lose its distributed scaling and recovery, which are the reasons to choose it. If the work fits in one service, Kafka Streams is the more natural library.

How would you migrate a Kafka Streams application to Flink later?

Usually by building the Flink job to read the same input topics and write to new output topics, running both in parallel, comparing outputs, and switching consumers over. State does not transfer between the engines, so the Flink job must rebuild it from input history or from a snapshot topic.

7Conclusion

In this answer, we compared Kafka Streams, a library that runs inside the service and needs only Kafka, with Flink, a separate distributed platform with many connectors, richer event-time features and snapshot-based state handling. Kafka Streams scales with partitions and restores state from changelogs, which becomes slow with very large state, while Flink handles large state and rescaling better. Team skills and whether a platform team will run a shared cluster often decide, and a mixed model is common: Kafka Streams for service-local processing, Flink for cross-domain analytics.

What to say in the interviewAbout 90 seconds aloud

Open with

Kafka Streams is a library, so it runs inside the Spring Boot service, scales by running more instances, and needs no infrastructure beyond Kafka. That makes it a great fit when the processing is Kafka in, Kafka out, belongs to one team's domain, and the state is moderate; the team deploys and monitors it like any other service.

Then, if they want more

Flink is a separate distributed platform. It has connectors for many sources and sinks, richer event-time handling with watermarks, complex event processing and SQL, and it handles very large state with snapshots to durable storage and rescaling from savepoints.

Kafka Streams scales up to the number of input partitions and restores state by replaying changelog topics, which gets slow with hundreds of gigabytes, even with standby replicas. But the biggest factor is usually organisational: Flink needs someone to run it as a platform, with upgrades, on-call and support.

If no platform team will own that, asking every product team to run Flink is a mistake.

So I'd typically recommend a mixed model: product teams use Kafka Streams in their services for domain-local processing like enrichment and materialised views, and a platform team runs Flink for cross-domain analytics, joins across many sources and data lake work, with Kafka topics and schemas as the shared contract between them.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "When would you choose Kafka Streams inside a Spring Boot service, and when a separate...": https://scrivio-interview-library.netlify.app/spring-boot/kafka/aba6d8def2/