Java Performance – Managing Session Size

javaperformancesession

From what I know, the session information is usually saved on the server.
In Java the data is handled as a Map which I guess contains the a String identifier and an object reference which points to a memory zone from the server.

Considering that, is it safe to assume that storing a Properties file on the session will not have a critical effect on performance?

I have to handle some Language Properties files (ResourceBundle). For some reason I have to translate at every request at least 30 strings in one of 3 languages. This results in many conditional clauses which can be avoided by storing the Properties file on the session.

Note:
The Properties file is just an example. The aim of the question is to determine why and how placing an Properties object in the session differs from pacing an String object. I am aware of the size aspect but does this issue stands while all Objects are stored on the server?

Best Answer

You shouldn't store it in session but at the same time you also shouldn't load the Properties file after each request because of the detrimental impact that repeated file I/O will incur.

Store it on the ApplicationContext which allows the one Properties file to be loaded into memory once and can be used to the beneft of all users on all sessions.

Related Topic