Forum: Ruby on Rails idea: rails + mysql master/slave replication ==> mysql_repli

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
maui (Guest)
on 2007-01-27 03:35
(Received via mailing list)
Hi everyone,

We're working on an RoR app that has a spiky demand curve (think online
sweepstakes).  As a result we need to handle a large number of
simultaneous requests.  We're using MySQL as our db as we have on
several previous (non-RoR) projects.  In the past we've found MySQL
master/slave replication to be very useful.  Unfortunately, RoR doesn't
seem to have an easy mechanism to support this feature as it needs to
distinguish database reads from writes and route them to the
appropriate server.

So, we had an idea inspired by MySQL's Connector/J
ReplicationConnection
(http://dev.mysql.com/doc/refman/5.1/en/connector-j...).
 We were thinking of creating a new ActiveRecord::ConnectionAdaptor
that supports a pool of connections.  The YAML for this type of
connector in database.yml would take an array of masters and slaves.
Database read statements (ie. SELECT, DESCRIBE, SHOW TABLES) would be
routed to one of slaves (randomly).  Database writes and transactions
would be routed to one of the masters.

The API looks quite clean but, as we are new to RoR, we were wondering
if there is some fatal flaw that we hadn't considered.  Does this sound
like a good idea?

Thanks,

Mark
This topic is locked and can not be replied to.