BEST PractICE 1 Do Not Store Large Object Graphs in httpsession

zhaozj2021-02-17  78

1 BEST PractICE 1 Do Not Store Large Object Graphs in httpsession

Large applications require a persistent HttpSessions, while this will cost a certain system resource. An HttpSession must be read by the servlet from the servlet from the servlet. In this process, serialization data is included and read from the database, write it. In most applications, each servlet just requires a small part of the data in the entire session. However, by storing a large object in httpsession, the application will force WebSphere Application Server to handle the entire httpsession object each time.

WebSphere Application Server has a configuration option to optimize the performance of persistent HttpSession. Details about this configuration will be discussed in the documentation of WebSphere Application Server. The same is that you can choose to store status data objects of the entire servlet object in httpsession. 1

Don't forget to be explicitly set to invalid after using the HTTPSESSESSION object. Details can be found in practice 2Release HttpSessions When Finished.

A dedicated data source (Data Source) is required when configuring persistence session in WebSphere Application Server. To avoid persistence session to compete for JDBC's Connections, do not reuse an application's data source or resources of WebSphere Application Server.

An example of an application using different size objects is compared. As the size of the object stored in the httpsession increases, the throughput of the system is lowered, and this influence is largely data sequence, the system consumes the system. resource of.

JDBC Alternative to use httpsession data for Storing Servlet State Data

Each servlet in most systems is only part of the data of the overall application, one way to store an object in httpsession is to use JDBC, which can be separated and maintained using JDBC in each servlet.

An example of a JDBC solution is to separate the data required in each servlet into different rows, and the data separated into the line is placed in the system application maintenance data source. The primary key for these rows (data required for each servlet) is stored in httpsession as a separate Attribute.

This method of this method is shown in Figure 1B:

Figure 1C shows the improvement of data in the partitioned servlet and using JDBC to maintain a servlet data in HttpSession as a separate object:

JDBC Alternative - Cleanup Issues

In the above method, it is mentioned that you need to store the data in the database. When these data is used, you need a mechanism to clear the data, and there is a better method:

(1), periodic offline:

(2) HTTPSessionBindingListener.

转载请注明原文地址:https://www.9cbs.com/read-29702.html

New Post(0)