maui
2007-Jan-24 23:06 UTC
idea: rails + mysql master/slave replication ==> mysql_replication connection adaptor
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-reference-replication-connection.html). 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 --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---