Skip to content
tchandy edited this page Sep 14, 2010 · 23 revisions

If you have replicated database configured in shards.yml (see Config File for more info), Octopus will automatic send all writes to master, and all reads to slaves. You should specify on your models what model will be replicated, with this syntax:

#This class is replicated
class Cat < ActiveRecord::Base
  replicated_model()
end

Basically, you could have multiple slaves, they will be selected via simple round robin algorithm. Also, if you want to send some queries to a specific slave or to a master, use this syntax:

#sends the query to master
User.using(:master).count
#Sends the query to specific slave
User.using(:slave_1).count
Clone this wiki locally