Java Reference
In-Depth Information
Figure 11-11. Memory utilization over the life of a program
To view this type of change in your batch jobs, you can use VisualVM's snapshot feature. As a job
runs, click the Snapshot button in the middle of the screen. VisualVM records the exact state of the JVM
when you take that snapshot. You can compare this with other snapshots to determine what changes.
Typically, the change indicates the location of the issue. If it isn't the smoking gun, it's definitely where
you should start looking.
The ability to scale batch jobs isn't a requirement to be able to address performance bugs as
discussed in the previous sections of this chapter. On the contrary, jobs that have bugs like those
discussed typically don't scale no matter what you do. Instead, you need to address the issues within
your application before applying the scalability features that Spring Batch or any framework provides.
When you have a system with none of these issues, the features that Spring Batch offers to scale it
beyond a single-threaded, single-JVM approach are some of the strongest of any framework. You spend
the rest of this chapter looking at how to use Spring Batch's scalability features.
Scaling a Job
In an enterprise, when things are going well, data gets big. More customers. More transactions. More site
hits. More, more, more. Your batch jobs need to be able to keep up. Spring Batch was designed from the
ground up to be highly scalable, to fit the needs of both small batch jobs and large enterprise-scale batch
infrastructures. This section looks at the four different approaches Spring Batch takes for scaling batch
jobs beyond the default flow: multithreaded steps, parallel steps, remote chunking, and partitioning.
Multithreaded Steps
When a step is processed, by default it's processed in a single thread. Although a multithreaded step is
the easiest way to parallelize a job's execution, as with all multithreaded environments there are aspects
you need to consider when using it. This section looks at Spring Batch's multithreaded step and how to
use it safely in your batch jobs.
Spring Batch's multithreaded step concept allows a batch job to use Spring's
org.springframework.core.task.TaskExecutor abstraction to execute each chunk in its own thread.
Figure 11-12 shows an example of how processing works when using the multithreaded step.
Search WWH ::

Custom Search