Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a J2EE application hosted on a linux VPS server. I use nginx as the web server and tomcat6 as the application server. At times, the website keeps waiting to load or sometimes even throws a 504 bad gateway nginx error. During this downtime of a few minutes(typically 3-5 minutes), if I try to access the server via SSH, I get a connection timeout error. When the website starts working after a few minutes, I noticed that tomcat, nginx are still running on the same process id as before. I do not need to restart tomcat or nginx, it starts working by itself. Also once the site is running again, I also notice that the SSH connection to the server also succeeds.

I am not sure where exactly the issue lies? Is it a connectivity issue with the server or is it some error in my config? Any insights would be appreciated.

share|improve this question
    
Are you swapping? –  Michael Hampton Mar 28 '13 at 4:28
    
How can I find out if the swapping is happening or not? As per the server config, my guaranteed memory is 1G and swap memory is 2G. –  Maxim Dsouza Mar 28 '13 at 4:49
    
@MichaelHampton code26714 tomcat6 20 0 938m 308m 8260 S 1 30.9 1:45.36 629m java 26773 mysql 20 0 601m 172m 6952 S 1 17.3 1:53.98 429m mysqld code This is the output from my top command sorted by swap usage, if it is helpful. –  Maxim Dsouza Mar 28 '13 at 4:52
    
Oh no, you're on a crappy OpenVZ based VPS. Don't attempt to run Java applications on such systems. –  Michael Hampton Mar 28 '13 at 4:56
    
@MichaelHampton Its not a OpenVZ VPS, as per what I booked it is supposed to be a Xen VPS. My VPS is Warp 2 from this link photonvps.com/xen.html –  Maxim Dsouza Mar 28 '13 at 5:10

1 Answer 1

You're using a Xen VPS with 1GB of RAM and 2GB of swap, and your VPS provider has the same ratio of RAM to swap for all other customers, including 256MB of swap for the 128MB of RAM for customers on the lowest tier.

That would seem like a very high swap to RAM ratio for a VPS hoster, especially if they offer low tiers like 128MB of RAM with 256MB of swap, which invariably run out of RAM all the time when used by unsuspecting novice users.

It would sound like the Bad Gateway error you're receiving is caused by the overly long delay in the reply of your J2EE app, which might be caused by all the swapping going on.

Your best bet is test the performance of the server. You should probably start by running dd to test disc throughput, then followed up by some kind of UNIX benchmarking tool.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.