I have a java (tomcat / spring based) cloud multi-tenant application running on cloud foundry, which uses a cloud database. We use tomcat jdbc for connection pooling with maximum 8 connections per tenant. We have max wait configured for 60 seconds on connections in tomcat jdbc. We cache connection for 300 tenants at any given time.
Recently we experienced Too many open files Error.
When we checked lsof, we had some interesting findings:
- There were 191 entries for each jar in
lsofoutput. Does it mean, the jar file is being opened for each request? - There were many socket connections (to Cloud Database and Load Balancer - We have one http call to another micro-service in some calls) in
CLOSE_WAITstate.
We further checked our dynatrace and found following:
- We had some
getConnectioncalls which failed with Broken Pipe error duringborrowConnection(reconnect or validate), after 10 mins. I am not sure whymax waitwas not honoured, and is the socket closed after the Broken Pipe. - Eventually
getConnectionandjar loading(Don't know, why jar is being loaded again) started failing withToo many open filesError.
We also don't see any connection leak as it would resulted in PoolExhaustedException not the current one.
Any ideas / hints on what is going wrong?