We have a web application based on Java/JEE. Some of its pages are AJAX based and very similar to KAKAY.com pages to filter results on several attributes.
For e.g. if we display 1500 products and their 50 different attributes along with their values (like color, size, weight, price), user can filter on a color (which may reduce the no. of products to 1300 for e.g. and disable a lot of mismatching attribute values). User can go on to filter on other attributes step by step until he gets to the refined set of products he wants. This is done on server side with
Java bitmap objects for quick calculations.
Some of these pages are really heavy on server side because bitmap size is huge (like 50 mb file on serializing bitmap objects to disk). For each user session, this 50mb is cloned to maintain state of bitmaps specific to that session. These pages with a single user perform to acceptable level. As we increase the number of users to 5-7 performance starts degrading. We tested with 7 simultaneous users accessing the same page, then making selections on same attributes. Server side time to process 1 request increases to 15 secs per session with 7 sessions from 4 secs with a single session. I profiled with JConsole yesterday and saw that, when we make the selection there are high spikes in Heap memory utilization (goes from 250mb to 450mb for e.g. and so on ). Spikes come down gradually in steps (like every 10 secs it comes down by 25 mb), which I am assuming means we do not have memory leaks or at least major memory leaks. But if we keep on pounding the system with 7 sessions and make selection over selection, performance remains degraded and spikes remain high.
Environment
My Questions:
1. The sudden high spikes I see in Heap memory utilization when all users make parallel selection and gradually they come down - from this my interpretation is the spikes are for allocation of "objects local to methods which are eventually collected by garbage collector in short intervals". So I should probably look into software to see why so many local objects are being created for each server side iteration (instead of long time surviving session objects or
servlet context objects). Can you help me to correct/confirm my understanding?
2. I am not sure if the heap memory is used by JVM for anything else other than application objects. These high spikes - can they be JVM requirement to carry through the current set of requests for its own purpose rather than our application's objects? I know to understand this I should go a step further to profile to see which exact objects are created during spikes. But what I have collected so far, can you give me a hint or share your own thoughts/experiences?
3. Generally I see forums discussing JVM memory settings in the range of 256mb to 2gb. My question is how many parallel users can the applications like Amazon or Kayak can support with 2GB of RAM on a single machine? How are they managing this situation? I know we can bring more servers and load balance but what about per machine with 2GB max heap size, how many max parallel users all pounding the system?
-Varun