Loading

Octopus -- Master-Slave Database Connections in Ruby on Rails Configuration

octopus is a ruby gem that allows an ActiveRecord application (including ActiveRecord 3/Rails 3 applications) to connect to one master and multiple slave databases. Most of the documentation centers on its sharding features, but I am using it to send writes to the master and reads to the slaves. This is called “replication” in octopus parlance. Since there was no full example of a shards.yml file for full replication, here’s what I’m using:

octopus:
  replicated: true
  fully_replicated: true
  production:
    slave1:
      adapter: mysql
      encoding: utf8
      username: user
      password: password
      host: "db-reader-0"
      database: somedb
    slave2:
      adapter: mysql
      encoding: utf8
      username: user
      password: password
      host: "db-reader-1"
      database: somedb

What was confusing to me is that it needs replicated and fully_replicated. The master database is the one listed in your standard config/database.yml.


Related Posts

  1. High Availability on a Shoestring -- Postgresql 9.0 Streaming Replication
  2. iPhone/iPad UISearchBar and UISearchDisplayController Asynchronous Example
  3. High Availability on a Shoestring -- Database Replication and Failover Alternatives
  4. High Availability on a Shoestring -- MMM Mysql Multi-master Replication Manager
  5. High Availability on a Shoestring -- PgPool-II Installation Woes
You should follow me on Twitter: @patrickxb