So you have multiple database instances on Engineyard and you want to use the additional instances for reads, but you dont know where to start? Google "master slave engineyard" sometime. Report back if you ever find anything useful beyond this post about Using Masochism which is very helpful if you never plan to expand beyond a single slave.
- Install the seamless database pool plugin and follow the setup instructions, making sure to include the appropriate code in your ApplicationController.
class ApplicationController < ActionController::Base
include SeamlessDatabasePool::ControllerFilter
use_database_pool :all => :persistent, [:create, :update, :destroy] => :master
end
- Add the extra N instances of database slaves to your EngineYard environment.
- Grab my seamless_database_pool cookbook from github and add to your cookbooks directory. I am not 100% sure this is correct or accepted, but i like to keep my cookbooks with the app they are associated with, so i have a /cookbooks directory at the root of my applicaton. you will want to rename it "seamless_database_pool". i added ey-chef- to make it easier to find.
- Add the seamless_database_pool recipe to you main cookbook at /cookbooks/main/recipes/default.rb
require_recipe "seamless_database_pool"
- Add the following to your /deploy/before_migration.rb
run "ln -nfs #{release_path}/config/database_cluster.yml #{release_path}/config/database.yml"
- Commit and push everything
- Load the recipe onto your environment via the engineyard cli, waiting
$ ey recipes upload
$ ey recipes apply
$ ey deploy
- Hammer your server with your performance testing tool (I recommend Siege) and verify that the slaves are getting read requests. The "Graphs" for the instances is a great place to verify without SSH Spelunking.
Got a better way? See something wrong? Let me know below.