DB load balancing

Hey all,

Are any of you folks running rails apps on a MySQL Master/Slave
configurations?

If so, do you do splits of reads/writes, or any type of load balancing
from rails?

I’ve developed several applications in the past with PHP and other
languages where I did some software load balancing. For example, my
previous application would parse the query and figure out if it was a
read or a write. Then it would send off the query to the appropriate db
server for it to execute (ie, a select to a MySQL slave, and a write to
a MySQL Master). It’s pretty basic, but provided pretty decent
scalability from the DB side of the application.

From what I’ve seen, I don’t think Rails can do this, unless you
specifically tell the model to connect to the slave when doing Finds,
and connect to the master when doing the update/delete/creates. But
this approach forces the developer to remember to connect to the db.

Anyone have any solutions for this? Possibly a 3rd party
application/load balancer?

Peter Bui wrote:

previous application would parse the query and figure out if it was a
Anyone have any solutions for this? Possibly a 3rd party
application/load balancer?

I would suggest overridding the save method in ActiveRecord or using
some type of hook that would force writes to the master server.

I also suggest checking out memcached, it’s a caching deamon for caching
DB queries.
I recall that someone wrote a memcached backend for ActiveRecord
caching.

Jason