Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thiagopradi/octopus_replication_example

Sample Rails app using Octopus Library to enable support for replicated database with ActiveRecord
https://github.com/thiagopradi/octopus_replication_example

Last synced: 11 days ago
JSON representation

Sample Rails app using Octopus Library to enable support for replicated database with ActiveRecord

Awesome Lists containing this project

README

        

Octopus Replication Example

This is a sample rails application demonstrating replication features in octopus. The application have 1 master, (specified in database.yml) and 4 slaves (specified in shards.yml).

Feature list:

All writes will be sent to master, and the read queries will be sent to the slaves. unless you have a transaction, so , all queries will be sent to master.


The application have two different models: Client and User. User is a replicated model, and Client isn't replicated. So, when you create a new User, you will see a exception, because you don't have configuration for replication and Rails tries to read the user from a slave database, and the write query have been sent to master (Default behaviour when using replication). When you create a new client, everything should works fine, it will read and write in the master database.

Setup:


You will need two commands to setup the application:


 rake db:octopus && rake db:migrate 

More info could be found at Octopus Wiki

Thanks

This project is sponsored by the Ruby Summer of Code,
and my mentors Mike Perham and Amit Agarwal.

Copyright

Copyright (c) 2010 Thiago Pradi, released under the MIT license.