Monday 19 October 2015

Memory constraints and limitations of Virtual Private Server

Before you decide to go for Virtual Private Server( VPS ), make your requirements very clear and know the memory limitations of VPS. Long time back I purchased a VPS and I was able to install MySql, Glassfish, Nginx, mail server, puppetmaster and client, memcached, git, etc. Later on I was trying to improve the performance of Glassfish cluster instances and Mysql.
I was able to make changes in memory settings MySql and optimized its performance and tested with mysqltuner. No problem!
Since I had two glassfish cluster instances running on the same machine, I thought of increasing JVM heap size of both instances to 5G. Earlier I had allocated only 2G and I was trying to push this to 5G for both instances.
After making changes in cluster xml, I started 1st instance and it was successful. Instance one was ready to serve requests.
When I try to start the 2nd instance, BOOOOOM!, 2nd instance throws "Out Of Memory Exception", Couldn't reserve enough space for JVM.

Then I checked the available memory in my machine using "free -g". It displayed like this 17G free available memory and only 3G occupied.

What does that mean? 17GB still left but unable to allocate.

Then I spoke to my hosting provider guys and I have been told that it doesn't work the way you think.

This command:
       "cat /proc/user_beancounters" 


You have to investigate the output of the above command to understand why it couldn't allocate 5G to second instance.

Look for this row:
       privvmpages
Check for limit column. That number is the maximum limit that can be allocated to any application. In my case, it was just about 5G. Thats it!
They will not allow you to edit and increase this limit. You have to go for either large vps or a dedicated server to allocate more memory.

No comments:

Post a Comment