arnold
arnold

Reputation: 1712

Sharing JVM session

I have a java application, using JVM as session storage. But recently when a certain number of users exceed. The application goes down. JVM is running out of memory.

I want to add new application server also want to use load balancer but as the session is JVM dependent, I can not share it with other application server.

It would be great if I can use one JVM instance dedicatedly for the JVM session and access it via multiple application server.How I can do that?

I am using Java Spring in the project. Is my plan ok to accommodate lot of users requests?

Thanks in advance.

Upvotes: 0

Views: 1105

Answers (3)

Stephen C
Stephen C

Reputation: 718946

It sound like you are holding (large amounts of) session data in memory ... for performance reasons.

Is my plan ok to accommodate lot of users requests?

Ultimately you will run out of:

  • physical memory to hold all of the session data in one JVM, or

  • CPU and I/O bandwidth to satisfy the requests for session data from the other application servers, and/or

  • CPU resources for simply managing the data. (Hint: the time taken to do a full GC is proportional to the total amount on reachable data.)

If your architecture uses a single JVM for all session data, you will eventually hit a wall. That suggests that you should make it possible to replicate that part of your system. However, it is not possible to suggest the best way to do that ... without a much deeper analysis of your application ... and its real need for scalability.

Bottom line: there are no simple one-size-fits-all solutions for scalability.

Upvotes: 0

Kamil.H
Kamil.H

Reputation: 458

First make sure you know what the cause of out of memory is. If it is really related to having many sessions, you may want to change the way sessions are managed. Instead of keeping session in memory, you could save it into database. In that approach you would reduce memory and also after adding other machines session wouldn't be tied to any of them.

Upvotes: 0

Lasitha Benaragama
Lasitha Benaragama

Reputation: 2209

There is a 3rd Party Application called Terracotta. i Tried it and work fine for Spring Application.

You can find the Configuration details from below link.

http://www.terracotta.org/documentation/4.1/terracotta-server-array/introduction

Put a Comment if need any help.

Upvotes: 1

Related Questions