5.8.2 Estimating size of HTTP session attribute information
Maximum size of attribute information of an HTTP session is required when allocating disk space of the database used by the session failover functionality.
It is difficult to calculate and obtain the size of attribute information of an HTTP session from the contents of a web application. Therefore, the functionality for estimating size of HTTP session attribute information is provided with Application Server. If you use the functionality for estimating the size of HTTP session attribute information, you can actually execute the application and output the size information of the attributes registered in the HTTP session, after serialization, as a message.
This subsection describes the functionality for estimating HTTP session attribute information size and calculation formulas used to obtain the size of attribute information of an HTTP session.
It also describes the memory that must be secured to suppress Full GC.
- Organization of this subsection
(1) Functionality for estimating HTTP session attribute information size
If you use the functionality for estimating HTTP session attribute information size, you can estimate the optimum maximum size of attribute information of an HTTP session by referring to the output size information.
This functionality is used for estimation. Because global information is not stored to a database, databaser are not connected.
- Important note
-
Do not use the functionality for estimating HTTP session attribute information size in operating environment. If you use this functionality, the database session failover functionality become disabled and the global session information is not replicated to the database.
(a) Settings for enabling the functionality for estimating HTTP session attribute information size
Specify on in the following parameters in <configuration> tag of logical J2EE server (j2ee-server) in Easy Setup definition file.
-
webserver.dbsfo.check_size.mode parameter
For details on Easy Setup definition file and parameters to be specified, see 4.3 Easy Setup definition file in the uCosminexus Application Server Definition Reference Guide.
If you enable the functionality for estimating HTTP session attribute information size, all other settings related to the database session failover functionality become disabled.
If you use the functionality for estimating HTTP session attribute information size, the functionality of specifying upper limit of the number of HttpSession objects and functionality of deleting HTTP Cookie that indicates session ID of HTTP session described in 5.4.2 Prerequisite settings operate even if you disable it.
(b) Messages reporting the size of attribute information of an HTTP session
If you enable the functionality for estimating HTTP session attribute information size, the following messages reporting the attribute information of an HTTP session are output at Error level when the request processing of web application completes.
Message ID |
Contents |
Contents included in size information |
---|---|---|
KDJE34330-I or KDJE34416-I |
Size of HTTP session attribution information created for each request |
Total size of the result of serializing the attributes registered in the HTTP session (Total of the sizes output by KDJE34331-I or KDJE34417-I)#1 |
KDJE34331-I or KDJE34417-I |
Size of one attribute for which serialization is completed |
|
- #1
-
If attributes are not registered in an HTTP session, it is the size of a magic number written by java.io.ObjectOutputStream class and version information data written by java.io.ObjectOutputStream class.
- #2
-
It is included only in the size of attribute, which is serialized first.
The following is an example of message output when you create HTTP session attribute information from an HTTP session in which the registered attributes are "Attribute 1" and "Attribute 2" (in the case of the database session failover functionality).
KDJE34331-I An attribute was serialized. (J2EE application = App01, context root = /test, request URL = http://host01/test/TestServlet, attribute name = Attribute1, class name = app.MyObject1, size(bytes) = 36, HTTP session ID = 01234567aaaabbbbccccddddeeeeffff) KDJE34331-I An attribute was serialized. (J2EE application = App01, context root = /test, request URL = http://host01/test/TestServlet, attribute name = Attribute2, class name = app.MyObject2, size(bytes) = 25, HTTP session ID = 01234567aaaabbbbccccddddeeeeffff) KDJE34330-I The attribute information was created. (J2EE application = App01, context root = /test, request URL = http://host01/test/TestServlet, size(byte) = 61, HTTP session ID = 01234567aaaabbbbccccddddeeeeffff)
(2) Calculation formulas for determining the size of HTTP session attribute information
You can determine the maximum size of HTTP session attribute information by using the following formulas.
Here, the size is calculated by considering that serialization is performed for one HTTP session by using one java.io.ObjectOutputStream object.
Maximum size of HTTP session attribute information (bytes)= Total number of bytes of byte arrays that have serialized attribute names of all attributes registered in the HTTP session + Total number of bytes of byte arrays that have serialized attribute values of all attributes registered in the HTTP session
If you register n objects as attributes in an HTTP session and name the registered attributes from attribute 1 to attribute n, you can determine the maximum size of HTTP session attribute information with the following formula:
Maximum size of HTTP session attribute information (bytes)= Number of bytes of byte array that has serialized attribute name of attribute 1 + Number of bytes of byte array that has serialized attribute value of attribute 1 + Number of bytes of byte array that has serialized attribute name of attribute 2 + Number of bytes of byte array that has serialized attribute value of attribute 2 : (omitted) + Number of bytes of byte array that has serialized attribute name of attribute n + Number of bytes of byte array that has serialized attribute value of attribute n
You can determine the number of bytes of a byte array that has a serialized attribute name and the number of bytes of a byte array that has a serialized attribute value by the following formulas:
Number of bytes of a byte array that has serialized attribute name
Number of bytes of a byte array that has serialized attribute name= Number of characters in attribute name x 3 x 1.2
Number of bytes of a byte array that has serialized attribute value
Number of bytes of a byte array that has serialized attribute value= Total number of bytes of the values of all fields, possessed by the objects of attribute value x 1.2
You can determine the number of bytes of field values by using the following formulas:
-
In the case of String objects: Number of characters × 3
-
In the case of other objects: Total number of bytes of the values of all fields, possessed by the object
-
In the case of primitive type: Number of bytes required for storing each primitive type
- Important note
-
The value, which you can calculate by using the calculation formula that determines the size of HTTP session attribute information, is a roughly estimated value. If you want to determine the conclusive maximum value of HTTP session attribute information, use the functionality for estimating HTTP session attribute information size.
(3) Memory that must be secured to suppress Full GC
Because the size of the HTTP session attribute information is the size after serialization, the size is different from the size of attribute objects, which are registered in the HTTP session, in the memory. Therefore, you must make a separate estimate of the memory in the external heap area required to suppress Full GC and set an appropriate value according to the estimate.
For details about suppression of Full GC, see 7. Suppression of Full GC by Using the Explicit Memory Management Functionality.