Can db connections be shared

Unless you start establishing connections by hand, each instance of mongrel has one database connection, which it will reuse until it dies. If you only had one mongrel then there would only ever be 1 connection.

Fred

You will get multiple connections regardless of whether you create them
by hand, even if it’s using a named pipe. I fired up 2 connections by
hand to illustrate the point:

`netstat -an | grep mysql.sock

unix 2 [ ACC ] STREAM LISTENING 7235
/var/lib/mysql/mysql.sock

unix 3 [ ] STREAM CONNECTED 2373005
/var/lib/mysql/mysql.sock

unix 3 [ ] STREAM CONNECTED 2372935
/var/lib/mysql/mysql.sock`

-Bill

Frederick Cheung wrote:

You will get multiple connections regardless of whether you create
them by hand, even if it's using a named pipe. I fired up 2
connections by hand to illustrate the point:

What do you mean by "fire up 2 connections". I always see one
connection per mongrel (+ instances of query browser etc... obviously)

You said “by hand”, which I assumed to mean running mysql from the
command line. How are you creating a connection by hand with Mongrel?

Frederick Cheung wrote:

I read your post again. I misinterpreted it to read that if you create
connections by hand, those connections would be shared. Just a
misinterpretation.

-Bill

William Pratt wrote:

You said "by hand", which I assumed to mean running mysql from the
command line. How are you creating a connection by hand with Mongrel?

Well obviously that creates extra connections. By 'by hand' I mean
calling ActiveRecord::Base.establish_connection. My point was that
unless you go out of your way, your rails app will use one connection
per instance of mongrel.

Fred