Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separated Hazelcast's own session expiration from Tomcat #86

Merged
merged 6 commits into from
Apr 27, 2020

Conversation

alparslanavci
Copy link
Contributor

Before this change, Tomcat's background process for expiration was retrieving all the remote sessions to local to check & expire them. This can cause OOMEs when the total session size is larger than the local container's heap.

To prevent that, the expiration of the sessions in the Hazelcast cluster is separated from Tomcat. Now, Hazelcast's max-idle-seconds property is set to sessionTimeout value by default to define expiry policy on the cluster side. The configuration is done by adding a dynamic map config to the Hazelcast cluster if there is no configuration for this map in the cluster. If so, then the existing cluster configuration has the priority.

Fixes #83.

@bergander
Copy link
Contributor

Note that this change will break the functionality of having different session timeout for each session, see my previous note about that: #40 (comment)

@alparslanavci
Copy link
Contributor Author

@bergander thanks for the reminder. I added support for session specific timeout.

Copy link
Contributor

@mesutcelik mesutcelik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 added two minor comments.

} catch (InvalidConfigurationException e) {
log.info("Max idle seconds cannot be setup, \"" + mapName
+ "\" map is already configured in the Hazelcast cluster!");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that is not needed. On the fly MapConfig update is not persistent so it is not resilient to cluster restarts. We need to mention clearly that hazelcast config must be set with maxIdleSeconds that is greater than session timeout. This can be added as an info to the log and updated in README.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

README.md Outdated
@@ -196,6 +196,9 @@ Based on Tomcat configuration or `sessionTimeout` setting in `web.xml`, sessions

`processExpiresFrequency`, which is defined in [`<Manager>`](#configuring-manager-element-for-tomcat), is the only setting that controls the behavior of session expiry policy in the Tomcat Web Session Replication Module. By setting this, you can set the frequency of the session expiration checks in the Tomcat Instance.

Starting with v2.1, the session expiration in Hazelcast cluster is separated from the Tomcat control. Instead, Hazelcast's own expiry mechanism (`max-idle-seconds` property) is used. By default, `sessionTimeout` value is configured as the `max-idle-seconds` for the session map in Hazelcast. So, the session expiry in Hazelcast cluster happens at the same time with Tomcat by default. However, if you would like to change the expiration setting on the Hazelcast cluster, you need to configure eviction for the related session map. Please see the Hazelcast's own eviction mechanism details [here](https://docs.hazelcast.org/docs/latest/manual/html-single/#map-eviction).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting with v2.1, the session expiration in Hazelcast cluster is not controlled by Tomcat anymore. Instead, Hazelcast's own expiry mechanism (max-idle-seconds property) is used. if you would like to change the expiration setting on the Hazelcast cluster, you need to configure eviction for the related session map. Please see the Hazelcast's own eviction mechanism details [here](https://docs.hazelcast.org/docs/latest/manual/html-single/#map-eviction).

Maybe some shorter version like that can be a good option?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HazelcastSessionManager.findSessions can lead to OOME
3 participants