Java Reference
In-Depth Information
on performance. Typically, people learn that data stored in a processor cache can be
accessed so quickly that it's effectively free; that data in memory can be accessed fast;
that large data structures can begin to cause problems; and that data stored on disk is
extremely slow. This advice boils down to “avoid I/O operations where you can.”
Remoting, by its nature, requires some level of network communication, which is
the key reason for its comparatively abominable performance. Even if you're making a
method call that passes no arguments and has no return value, the speed of the net-
work is a critical factor. In a typical modern system, a processor will have to wait for
less than a nanosecond to load the next operation instruction from an internal cache,
or up to a few tens of nanoseconds to load instructions or data from main memory.
On a typical, small-scale network, fetching even a few bytes of data would be measured
in hundreds of microseconds or possibly milliseconds; on a large network, or perhaps
over the Atlantic, this latency can easily reach more than 100 milliseconds. As you can
see from figure 10.5, any method invocation that you need to make over the local net-
work is likely to be a thousand times slower than performing it locally.
Invocations over the internet can be a million times slower than local ones. In this
measurement, we're ignoring the length of time it takes for the method to run. If the
method takes a second to complete, then the remoting overhead is comparatively
small. We're also assuming that the method parameters and return value are suffi-
ciently small that transferring them will take negligible time. If the data to be trans-
ferred is large, say, 50 kilobytes, then this can be a much larger factor than the
network latency (about a millisecond on a fast local network, or 10 to 15 seconds over
a slow mobile phone network). Any way you slice it, making remote calls isn't a cheap
thing to do.
Figure 10.5 The execution times for remote methods are dramatically increased by the latency of the
network, even on a local network with a 500 microsecond latency.
 
Search WWH ::




Custom Search