Quick revision
The short answer
A multi-threaded step runs one step's chunks concurrently on a TaskExecutor, so the reader must be thread-safe and the saved restart position is unreliable. Parallel steps run different, independent steps at the same time through a split flow. Partitioning has a manager step that divides the data into ranges with a Partitioner, and worker steps that each process one range with their own ExecutionContext, which keeps restart working per partition and can run locally or on remote workers, while remote chunking instead sends items to remote workers for processing and writing over messaging middleware.
What to remember
In this answer, we compared four ways to run batch work in parallel. A multi-threaded step runs one step's chunks on several threads and needs a thread-safe reader while losing reliable restart. Parallel steps run independent steps together in a split flow. Partitioning divides the data into ranges with a Partitioner and runs a worker step per range with its own ExecutionContext, keeping restart per partition locally or remotely. Remote chunking sends items from one reader to remote workers over messaging middleware for processing and writing.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
A multi-threaded step runs one step's chunks concurrently on a TaskExecutor, so the reader must be thread-safe and the saved restart position is unreliable. Parallel steps run different, independent steps at the same time through a split flow. Partitioning has a manager step that divides the data into ranges with a Partitioner, and worker steps that each process one range with their own ExecutionContext, which keeps restart working per partition and can run locally or on remote workers, while remote chunking instead sends items to remote workers for processing and writing over messaging middleware.
Why this question is asked
When a batch job is too slow, the first instinct is to add threads, and Spring Batch offers several ways to do it. They are not interchangeable: each one splits a different thing, and they have very different effects on restart, which is the main reason we use Spring Batch at all. Interviewers ask this question to check that we know what each option parallelises and what it costs. In this answer, we will recap a single-threaded step, then look at multi-threaded steps, parallel steps, partitioning, and remote chunking, and finish with a comparison and a rule of thumb for choosing.
1A Quick Recap of a Single-Threaded Step
A normal chunk-oriented step runs on one thread. It reads a chunk of items, processes them, writes them, commits, and repeats. Because chunks are handled strictly in order, the reader's position saved at each commit is exactly right, so a restart can resume at the next chunk. All the parallel options trade some of this simplicity for speed.
2Multi-Threaded Step: One Step, Several Threads
The simplest option is to give a step a TaskExecutor, a Spring abstraction over a thread pool. Each thread then runs the chunk loop independently: it reads its own chunk from the shared reader, processes it, writes it and commits.
There are two catches. First, the reader is shared, so it must be thread-safe. FlatFileItemReader and JdbcCursorItemReader are not; JdbcPagingItemReader is safe for concurrent reads, and a non-safe reader can be wrapped in SynchronizedItemStreamReader. Second, chunks finish out of order, so no single saved position is correct: if thread 2's chunk commits and thread 1's fails, the saved count is meaningless. That is why readers in multi-threaded steps set saveState to false, and a restart begins again from the start, unless the writer is idempotent and the input marks processed rows. Multi-threaded steps suit jobs where restart is not important or the processing, not the reading, is the slow part.
3Parallel Steps: Different Steps at the Same Time
Parallel steps do not split the data of one step. They run different steps that do not depend on each other at the same time. For example, a nightly job loads customers, loads products and loads prices; the three loads are independent, and a fourth step builds the catalogue after all three. In Spring Batch we express this with a split flow.
Each step is still single-threaded internally, so each keeps normal restart behaviour. The speed-up is limited by the number of independent steps and by the longest one; if one load takes two hours and the others ten minutes, the job still takes two hours.
4Partitioning: Split the Data, Each Part a Step
Partitioning is the option that scales one large step while keeping restart. A manager step calls a Partitioner, which divides the data into partitions, for example ranges of ids, and returns one ExecutionContext per partition with that partition's range. The manager then runs a worker step once per partition. Each worker execution is a real StepExecution with its own reader, its own saved state and its own status.
- Manager stepcalls the Partitioner, waits for workers, aggregates results
- Partitioner8
ExecutionContexts: ids 1-1M, 1M-2M, ... - Worker step executionsone per partition, run on a
TaskExecutoror remote workers - Per-partition stateown reader position, own status, restartable alone
4 layers, from the top down. Step through them one at a time.
Because every partition has its own state, a restart after a failure re-runs only the partitions that did not complete, each from its own last commit. The workers can run on local threads, or on other machines with remote partitioning, where the manager sends partition requests over messaging or a shared job repository and remote workers execute them. This flexibility is why partitioning is the usual choice for big, restartable loads.
5Remote Chunking: Ship Items to Workers
Remote chunking splits the work differently. The manager reads the items itself and sends chunks of items over messaging middleware, such as a JMS broker or Kafka through Spring Integration, to remote workers. The workers process and write each chunk and send a reply. It helps when processing and writing are expensive and reading is cheap, for example when each item needs heavy computation. The costs are a message broker, the network traffic of sending every item, and the fact that the manager's single reader is still a limit. The spring-batch-integration module provides the building blocks.
| Option | What is split | Reader | Restart |
|---|---|---|---|
| Multi-threaded step | chunks of one step | shared, must be thread-safe | unreliable, saveState off |
| Parallel steps | independent steps | one per step | normal, per step |
| Partitioning | data into ranges | one per partition | per partition |
| Remote chunking | processing and writing | one, on the manager | managed by the manager; needs messaging |
6Follow-up questions
Which should I try first for a slow, restartable load?
Partitioning with local threads. It keeps restart per partition, needs no new infrastructure, and can later move to remote workers if one machine is not enough. A multi-threaded step is quicker to set up but gives up restart, which is usually the reason we chose Spring Batch.
Do any of these options help if the database is the bottleneck?
Not really. More threads writing to an already busy database only add lock contention and queueing. We first make each thread efficient, with batched writes and keyset reads, then add parallelism while watching database load.
What happened to throttleLimit?
In older versions, multi-threaded steps had a throttleLimit setting for how many chunks run at once. It was deprecated in Spring Batch 5, and concurrency should be controlled by the size of the TaskExecutor's thread pool instead; check your version.
7Conclusion
In this answer, we compared four ways to run batch work in parallel. A multi-threaded step runs one step's chunks on several threads and needs a thread-safe reader while losing reliable restart. Parallel steps run independent steps together in a split flow. Partitioning divides the data into ranges with a Partitioner and runs a worker step per range with its own ExecutionContext, keeping restart per partition locally or remotely. Remote chunking sends items from one reader to remote workers over messaging middleware for processing and writing.
Open with
These three split different things. A multi-threaded step is one step with a TaskExecutor, so several threads each run the read, process, write loop on their own chunks from a shared reader.
Then, if they want more
It is easy to set up, but the reader must be thread-safe, and because chunks commit out of order the saved reader position is meaningless, so we turn saveState off and lose precise restart.
Parallel steps are different steps that do not depend on each other, run at the same time with a split flow and a TaskExecutor, for example loading customers, products and prices together before building a catalogue; each step keeps its normal restart.
Partitioning splits the data of one step: a manager step uses a Partitioner to create, say, eight ExecutionContexts with id ranges, and a worker step runs once per partition with its own reader and its own StepExecution.
That keeps restart working per partition, so only failed partitions re-run, and the workers can be local threads or remote machines with remote partitioning. There is also remote chunking, where the manager reads and sends chunks of items over a message broker to remote workers that process and write them, which helps when processing is the expensive part. For a large restartable load, partitioning is my default.
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.
- Official documentation
- Spring Batch reference
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 "Explain the difference between a multi-threaded step, parallel steps and partitioning in...": https://scrivio-interview-library.netlify.app/spring-boot/spring-batch/d566121cda/