クックパッドにおける最近のActiveRecord運用事情


@mirakui

Rails OR ActiveRecord 

ActiveRecord 使 SQL  RDB 

 ActiveRecord 使

 rake stats 
+----------------------+-------+-------+---------+---------+-----+-------+
| Name                 | Lines |   LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
...
| Models               | 87190 | 68871 |    1525 |    7568 |   4 |     7 |
...
+----------------------+-------+-------+---------+---------+-----+-------+

 ActiveRecord 

 Rails 4.1  ActiveRecord 4.1 

使


使

Rails schema_migrations 11

Rails  db:migrate ALTER TABLE DB


11  db:migrate  Rails 

2014 Ridgepole 使

Ridgepole


Ridgepole  Ridgepole  Schemafile  Ruby DSL  ridgepole --apply 

Ridgepole 使 github  README 

https://github.com/winebarrel/ridgepole

Ridgepole  DSL  ActiveRecord  Ridgepole 

 ridgepole --apply  Ridgepole  Schemafile DBDB Schemafile DB ALTER TABLE DB

 Ridgepole 

Ridgepole 


(一)DB ALTER TABLE 

(二) ridgepole --export  Schemafile  pull request 

(三)Schemafile  pull request  Jenkins DB ALTER TABLE ALTER TABLE CI Fail 

(四)CIDB ridgepole --apply  ALTER TABLE 


CI ALTER TABLE CIDBDB Jenkins  kumogata 

 Rails  2008 

DBR/W splitting


DBDB1 Rails way
 Issei Naruta (@mirakui) 2014, 624

ActiveRecord DB

 ActiveRecord  gem 2014 gem  octopus  Rails   acts_as_readonlyable 使 gem  2007  Rails 1.2  Rails 3.2 

 Rails 4  @eagletmt  switch_point 

acts_as_readonlyable 6使100octopus  db_charmer  Rails 

switch_point  Rails  ActiveRecord 




1DB

DBR/W Splitting






 switch_point 使

https://github.com/eagletmt/switch_point




ActiveRecord Rails 151 RDB 使 MHA   ActiveRecord  reconnect  MHA  gem 

http://so-wh.at/entry/2014/01/05/activerecord-mysql-reconnect_0.2.0

 ActiveRecord  gem  gem Amazon RDS 使DNS 

MHA  RDS  Rails 

 2014/08/28


@sonots 

ActiveRecord  connection pooling  > [Ruby]  ActiveRecord  connection_pool  - sonots:blog http://t.co/ubRKvHo3O8
  (SEO Naotoshi) (@sonots) 2014, 828

[Ruby]  ActiveRecord  connection_pool  - sonots:blog

sonots/activerecord-refresh_connection

 rack middleware  ActiveRecord::Base.clear_all_connections!  DeNA  ActiveRecord 4.1 + switch_point 使