• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Tomcat goes down when database goes down

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i have deployed tomcat 5.5 in our sun solaris server and many applicaton are running on it which connects to 8-10 different different database . applications are running fine but if any of my database goes down then my whole tomcat server goes also down after some time and no application runs at that time.
i have put maxThreads to 150 in my server.xml file. is it right to put -1 as maxThreads ?
or there is any other solution to keep my tomcat running fine ??

please help

Thanks
Naveen Jain
 
Saloon Keeper
Posts: 22265
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is absolutely no reason why Tomcat should go down when the database goes down. Applications may fail, and if they're poorly written, they may fail badly, but the Tomcat server doesn't have any database logic directly wired into it. While it does support connection pools, the actual pooling mechanism is simply constructed and located by Tomcat as a generic module, not actively controlled by it.

From the sound of it, what you're describing is a situation where there are a lot of database connections and when the DB server goes down, they all hang until they time out. But before you go tweaking Tomcat, you should be asking why there are so many requests active at the same time and if there isn't a smarter way to be making requests. 150 requests at a single instant seems a bit much for most apps unless you're running a really heavy load.

A database request requires more than just Tomcat resources. Each one is typically going to consume a pair of network sockets as well and they, too are limited. In fact, I've seen situations where, thanks to poor error recovery, the OS ran out of sockets and the whole machine ended up being rebooted once every few days.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say

whole tomcat server goes also down



Do you mean that the Tomcat process aborts and is no longer running - OR - that Tomcat stops responding but still shows as a running process. If it shows as a running process, how much CPU time is it using?

I think Tim's comment is on the right track and poor error recovery has left all your threads tied up.

Bill
 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've had an issue like that. Tomcat seems to freeze up and if I remember correctly doesn't even respond with the manager tool.

I recall it being a connection issue with MySQL. An application was connecting to a server but the server wasn't listening on that port.

The server was local, but not listening on 127.0.0.1, so connections to localhost:3306 would just hang. Changing localhost to the IP mysql was actually listing on solved the problem.
    Bookmark Topic Watch Topic
  • New Topic