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.
code
26714 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 mysqldcode
This is the output from my top command sorted by swap usage, if it is helpful.