[Rails] Re: Maintain connections to two databases
I tested this in production mode, and it's _much_ faster. It's fast
enough that I'm almost certain that it's not reconnecting to the
secondary database each time (at least in production mode). I don't
know if it's just overhead of other development behaviors or if it's
actually doing things differently (with respect to connections/pools/
reconnects); and I don't have time to investigate deeper.
But thanks for the suggestions and analyses!
On Sep 21, 6:04 am, Michael Schuerig <mich...@schuerig.de> wrote:
> On Tuesday 21 September 2010, michael_teter wrote:
>
> > Yes, I'm making the connection in my model as you describe. That is
> > working fine in the sense that it is connecting to the secondary
> > database.
>
> > My problem is, it appears to be connecting every time I instantiate
> > that object. I've traced the entire establish_connection path, and
> > it appears to be creating a new ConnectionPool object each time.
> > What's happening in establish_connection() is a little confusing to
> > me.
>
> > As far as I can tell, there is no re-use of connections to the
> > secondary database.
>
> Something's suspicious here. The behavior of establish_connection is
> correct (I think), but I don't see why it would be called more than
> twice for each instance of your app. Once each for the primary and
> secondary database. If establish_connection is called more often than
> that in the production environment(!) you ought to investigate the
> reason. Usually, class caching is enabled there and connections are
> retained across requests.
>
> Another angle of attack is to set a breakpoint (or puts caller)
> somewhere deep down in the database adapter to see when and from where
> connections are established.
>
> Michael
>
> --
> Michael Schuerig
> mailto:mich...@schuerig.dehttp://www.schuerig.de/michael/
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home