-
Notifications
You must be signed in to change notification settings - Fork 505
Replication
If you have replicated database configured in shards.yml (see Config File for more info), Octopus will send all writes to master, and all reads to slaves. You should specify if you application is fully replicated, or just some models are replicated. For default, Octopus will assume that you application isn’t fully replicated. if you want to make your application fully replicated, the following line needs to be added to shards.yml:
octopus: fully_replicated: true
If the application isn’t fully replicated, you need to specify on your models what will be replicated, with this syntax:
#This class is replicated, writes to master and reads to slave. class Cat < ActiveRecord::Base replicated_model() end
Basically, Octopus supports multiples slaves. Octopus will pick one shard using a round robin algorithm.
Also, if you want to send some queries to a specific slave or to a master, you could use normal sharding feature, examples:
#sends the query to master
User.using(:master).count#Sends the query to specific slave
User.using(:slave_1).countOctopus.using(:slave_1) do
User.count
end