I’m new to java and tomcat. I’m developing a website in java using spring mvc. It’s deployed to a linux server that’s running Tomcat 8. Everything works fine when I deploy, it connects to the database great. The issue is that the site seems to go idle very quickly. I haven’t been able to time it exactly, but it seems like it only takes about a minute of inactivity for the entire site to go idle. Then the next request is extremely slow, loading in all my classes. I’m losing my sessions as well.
Is this a common occurrence? Does it sound like I’m doing something wrong in java? Tomcat? Both?
EDIT: In light of StuPointerException’s comment, I’ve updated my database connection management. I’m now using Apache dbcp. I will update if this resolves the problem. I want to give my QA tester ample time to hit my site some more.
Advertisement
Answer
It’s difficult to answer your question directly without more information about your server setup.
For what it’s worth though, every time I see this kind of behaviour it’s down to a mis-configured database connection pool. There can be a significant overhead in creating new database connections.
If you don’t use a connection pool or you’re allowing connections in the pool to die (due to missing validation queries/checks) then you will start to see performance problems over time due to connection timeouts.