将 rails 应用指向所有数据库读取操作的只读数据库

pointing rails app to read only db for all DB read operations

我有一个 rails 4.2.8 应用程序,它有大量 SQL 读取命中主数据库(在 AWS RDS Aurora 上是 MySQL 5.7 运行引擎),而只读副本(不断从主数据库复制数据)处于空闲状态。

配置 rails 代码以使用只读数据库,同时继续使用主数据库进行所有写入操作(例如插入、更新、删除)的正确方法是什么?

看看 https://github.com/thiagopradi/octopus -- 它似乎是为解决您的问题而设计的。

Octopus is a better way to do Database Sharding in ActiveRecord. Sharding allows multiple databases in the same rails application. While there are several projects that implement Sharding (e.g. DbCharmer, DataFabric, MultiDb), each project has its own limitations. The main goal of octopus project is to provide a better way of doing Database Sharding.