Java Reference
In-Depth Information
1. Serialization of data, particularly within Java EE, can be a big performance bottle-
2. Marking instance variables transient will make serialization faster and reduce
the amount of data to be transmitted. Both of those are usually big performance
wins, unless re-creating the data on the receiver takes a very long time.
3. Other optimizations via the writeObject() and readObject() methods can sig-
nificantly speed up serialization. Approach them with caution, since it is easy to
make a mistake and introduce a subtle bug.
4. Compressing serialized data is often beneficial, even if the data will not travel
across a slow network.
Java EE Networking APIs
The data exchange techniques that we have just examined—XML parsing, JSON processing,
and object serialization—have their uses within a variety of applications, but one of their
primary uses is within one of the Java EE networking APIs: JAX-WS, JAX-RS, and IIOP/
These are very different protocols with very different features. Their feature sets are the
primary determinant of why and when you would use each of them. There are endless de-
bates, for example, about whether JAX-RS is faster than JAX-WS, but those debates of ne-
cessity assume a common denominator application that can be written in either framework. If
certain security features are required, then the choice will be JAX-WS, regardless of its per-
formance relative to JAX-RS. If an application must talk to an existing server that exports an
IIOP interface, then that dictates the choice.
As a set, though, the networking APIs have similar performance challenges to overcome.
This section discusses some of those challenges and addresses how to meet them.
Sizing Data Transfers
The primary factor driving performance of these technologies is their data exchange, which
is one reason this chapter spent a lot of time looking into that. The amount of data transfer
Search WWH ::

Custom Search