CHAPTER 8 HIGH-PERFORMANCE DEPLOYMENTS The default implementation persists each of the object s nonstatic and nontransient fields. Static fields are JVM specific (similar to global variables), and, by definition, transient fields are purposely not persisted. If your application requires any custom functionality in these methods, you can override them in your own serializable class. You can always gain access to the original functionality inside the overridden method by invoking the out.defaultWriteObject() and in.defaultReadObject() methods, respectively. In addition to implementing the java.io.Serializable interface, your nonstatic and nontransient fields must be either primitive types (for example, ints or floats) or serializable themselves (implementing the java.io.Serializableinterface and adhering to the same set of standards). If you attempt to deploy an application to a cluster that maintains nonserializable session information, then you will most likely receive a run-time error or unexpected behavior. An example of unexpected behavior is when you test failover and it may appear not to work at all for example, when your users fail over they are required to log in to the application again but the root of the problem is in the session serialization, not in the failover configuration. As a result, you may see an entry in your log files that alludes to attempting to serialize a nonserializable object. Architecting Clusterable Applications Once you ve satisfied the technical requirements, you can conceivably fail over any amount of session information from one server to another, but in practice you need to understand your sessions and decrease the quantity of information stored in your sessions. The quantity of data stored in your sessions directly impacts your cluster s performance because the session data must be transferred between primary and secondary application server instances. To further complicate matters, the granularity of session objects can have a direct impact on the quantity of data transferred between machines. Consider storing a configuration object in a user s session object that occupies approximately 1MB of memory. Modifying a single integer in that object marks it as dirty, and the entire 1MB object must be transferred across the network to the server s secondary server(s). On the other hand, while sending a single integer is more efficient than sending a 1MB object, managing 2,000 individual object attributes is not sustainable. So you need to establish a balance between manageability and performance. Because you need to meticulously scrutinize every byte of data stored in your sessions, I suggest following these guidelines when defining session attributes: Store in sessions temporal information, such as navigation information (where did I come from? What steps did I follow to get here? Where am I going?), and ensure that it is cleaned up appropriately when the active business process is complete. Store paging indices or iterators, but never in the objects themselves. Store a handle to a stateful session bean that maintains the user s session information. The last guideline may be a point of contention for some, but there is a good reason behind it: most production performance problems that result in application server crashes are OutOfMemoryError errors. My experience has demonstrated that the biggest cause of OutOfMemoryErrors in enterprise Java applications is the presence of a large number of heavy sessions; sessions impact memory requirements in direct proportion to the number of users in your application, including phantom users lingering for the duration of your session time-out. Stateful session beans are maintained in a cache with a predefined and specific upper limit
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.