Java Reference
In-Depth Information
10.4
Antipattern: Bad Workload Management
At McDonald's, there may be five lines, but I always seem to wind up behind
the kid who orders 27 Big Macs. Sure, other lines may be longer, but mine
always seems to move the slowest. In this instance, the cash registers are
resources, and one person is taking a disproportionate share of the resources.
Web servers generally don't have this problem because the content is static
and all of it is served relatively quickly. Web application servers, on the other
hand, experience this problem in spades. Some jobs simply take more time to
complete than others—for example, database write operations are often con-
siderably longer than reads. Enterprise applications behind the server may dic-
tate transaction length; enterprise transactions may be synchronized, forcing
application servers to wait for completion. Some database architectures force a
connection to be held for the entire duration of a recoverable transaction
(called a unit of work ), which can encompass many different atomic opera-
tions. In some cases, the web application server itself can dictate transaction
length. Heavily layered EJB applications can simply take time to execute.
In any case, highly variable transaction lengths can cause significant prob-
lems. Consider the jobs in figure 10.4. We have 20 jobs, each of one unit, dis-
tributed evenly across 4 queues. Two metrics are significant: total throughput
and waittime. The total throughput is operating at maximum efficiency
because each of the servers will be working on a job, and the average wait time
is 2 units.
Now, consider the jobs in figure 10.5. There are still 20 total units, but the
jobs are of variable length. There are 11 jobs, one of 10 units, and the rest of
one unit each. In the figure, we distributed the work in a round-robin fashion
and generated the order randomly. In this instance, the second queue got the
larger job. Since we were distributing work round-robin, two additional jobs
were added to the queue. In this instance, we could have finished the job in
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Figure 10.4
Good load balancing ensures that all servers will have a
proportionate workload.
1
1
1
1
Q 1
Q 2
Q 3
Q 4
Search WWH ::




Custom Search