C H A P T E R 11
Scaling and Tuning
The IRS processed over 236 million tax returns in 2010. Atlanta's Hartsfield-Jackson airport handled
nearly 90 million passengers in 2010. Facebook has more than 45 million status updates a day. Apple
sold more than 1.7 million iPhone 4s in its first three days of availability. The amount of data the world
generates every day is staggering. It used to be that as the data increased, so did the processors to
process it. If your app wasn't fast enough, you could wait a year and buy a new server, and all was fine.
But that isn't the case anymore. CPUs aren't getting faster at nearly the rate they used to. Instead, by
adding cores instead of transistors to a single core, CPUs are getting better at parallel processing instead
of becoming faster at a single task. The developers behind Spring Batch understand this and made
parallel processing one of the primary focuses of the framework. This chapter looks at the following:
Profiling batch jobs: You see a process for profiling your batch jobs so that the
optimization decisions you make positively impact your performance and not the
other way around.
Evaluating each of the scalability options in Spring Batch: Spring Batch provides a
number of different scalability options, each of which is reviewed in detail.
Profiling Your Batch Process
Michael A. Jackson put forth the best two rules of optimization in his 1975 book Principals of Program
Rule 1. Don't do it.
Rule 2 (for experts only). Don't do it yet.
The idea behind this is simple. Software changes over the course of its development. Because of this,
it's virtually impossible to make accurate decisions about how to design a system until the system has
been developed. After the system has been developed, you can test it for performance bottlenecks and
address those as required. By not taking this approach, you risk being described by my second most
favorite quote on optimization, this one by W. A. Wulf:
More computing sins are committed in the name of efficiency (without necessarily
achieving it) than for any other single reason—including blind stupidity.