I am running a jruby application on sinatra and using activerecord and
after I have given the application a significant amount of traffic, i
start to run out of connections in my connection pool. It got me
thinking that since i am not in rails and i have manually configured
activerecord myself, should i add code to return the connections to
the pool at the end of each request to sinatra? My guess is that
rails does this for free, but not in sinatra and this might be the
cause of my issue.
> I am running a jruby application on sinatra and using activerecord
and after I have given the application a significant amount of traffic,
i start to run out of connections in my connection pool. It got me
thinking that since i am not in rails and i have manually configured
activerecord myself, should i add code to return the connections to the
pool at the end of each request to sinatra? My guess is that rails does
this for free, but not in sinatra and this might be the cause of my
issue.
We are using a builder template and I was setting instance variables
on my sinatra object. (I have a class that derives from Sinatra::Base
When I retrieve information from ActiveREcord I was setting it to an
instance variable on the class and invoking builder to generate some
XML. This was getting in the way of multiple requests… I think… I
was getting odd errors before setting lock to true.
Now that things are working and we are profiling the system I am going
to go back and “investigate” that decision to see what I can do.
after do #close all db connections if we are using JDBC pooling closing
here will just return to the pool.
ActiveRecord::Base.clear_active_connections!
end
I guess the next question is :
What database are you using? What jdbc driver? Could that need to be
configured differently?
What app container are you running under? We war up our app and run
it in tomcat