Figure 10.2 Round-tripping is considered the top EJB performance problem by many consultants.
It occurs when significant iterations occur over major interfaces. In this case, we iterate through
a list of fields, and set or get them independently across a client-server boundary.
Caching, described in detail in chapter 5, eliminates the need for the
round-trip communication for the expected case by keeping a local copy
of frequently accessed data the first time it's fetched. Parallel implemen-
tations can somewhat reduce the effectiveness of a local cache. Multiple
servers require multiple copies of the same data, and multiple round-
trips to build them. Updates to cacheable data are more expensive
because the cached copy on each server must be invalidated. Still, for
applications with high read / write ratios and extremely high volume,
caching is effective. Further, edge servers offer caching solutions that
eliminate the need for multiple cached copies.
The Facade design pattern, discussed in chapter 8, refactors a round-
tripping architecture to make a call to a facade object, which then
encapsulates many request and response distributed calls into a single
distributed call. Stateless session beans are good choices for facade
objects. We can also use distributed command objects to solve this
problem; this approach requires only a single round-trip. (The stateless
session bean requires an initialization round-trip in addition to the
round-trip for the actual communication—not a perfect solution, but
still a significant improvement.)