Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Technically, a talk | RailsConf 2020

Technically, a talk | RailsConf 2020

Peer deep into Rails' database handling and you may find the code overly complex, hard to follow, and full of technical debt. On the surface you're right - it is complex, but that complexity represents the strong foundation that keeps your applications simple and focused on your product code. In this talk we'll look at how to use multiple databases, the beauty (and horror) of Rails connection management, and why we built this feature for you.

Eileen M. Uchitelle

May 05, 2020
Tweet

More Decks by Eileen M. Uchitelle

Other Decks in Programming

Transcript

  1. Hello! I’m
    Eileen M. Uchitelle!
    Work @GitHub
    Member of Rails Core
    Find me @eileencodes

    View full-size slide

  2. Technically,
    a Talk

    View full-size slide

  3. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #32075
    #32271
    #32396
    #32274
    #33637
    #33770
    #34495 #34969
    #35102
    #35242
    #36560
    #36565
    #36756
    #36770
    #36814
    #37185
    #37182
    #37231
    #37276
    #37277
    #37279
    #37280
    #37695
    #37873
    #37963
    #38008
    #38004
    #34495
    #38536
    #38609
    #32774 #33748 #35479
    #35663
    #36023
    #36039
    #36237 *d83ab
    #36824
    #37223
    #37242
    #37291
    #37230
    #37365
    *48d58
    *0a353
    #35073
    #35130
    #35237
    #36469 #36834
    #36868
    #38042
    #37298
    #37364
    #37368
    #37443
    #38011
    #37280
    #38209
    #33877
    #34052
    #34505
    #34054
    #34491
    #34632
    #34753
    #35042
    #35123
    #35089
    #35899 #36394 #37065 #37180
    #37199
    #37503
    #37296
    #37408
    #37622
    #37874
    #38258
    #38339
    #39190
    #38531
    #38580
    #38581
    #38672
    #38670
    #38920
    #38684
    #38770

    View full-size slide

  4. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #38684

    View full-size slide

  5. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #32075
    #32271
    #32396
    #32274
    #33637
    #33770
    #34495 #34969
    #35102
    #35242
    #36560
    #36565
    #36756
    #36770
    #36814
    #37185
    #37182
    #37231
    #37276
    #37277
    #37279
    #37280
    #37695
    #37873
    #37963
    #38008
    #38004
    #34495
    #38536
    #38609
    #37298
    #37364
    #37368
    #37443
    #38011
    #37280
    #38209
    #38670
    #38920
    #38684

    View full-size slide

  6. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #32774 #33748 #35479
    #35663
    #36023
    #36039
    #36237 *d83ab
    #36824
    #37223
    #37242
    #37291
    #37230
    #37365
    *48d58
    *0a353
    #38770
    #32075
    #32271
    #32396
    #32274
    #33637
    #33770
    #34495 #34969
    #35102
    #35242
    #36560
    #36565
    #36756
    #36770
    #36814
    #37185
    #37182
    #37231
    #37276
    #37277
    #37279
    #37280
    #37695
    #37873
    #37963
    #38008
    #38004
    #34495
    #38536
    #38609
    #37298
    #37364
    #37368
    #37443
    #38011
    #37280
    #38209
    #38684
    #38670
    #38920

    View full-size slide

  7. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #32774 #33748 #35479
    #35663
    #36023
    #36039
    #36237 *d83ab
    #36824
    #37223
    #37242
    #37291
    #37230
    #37365
    *48d58
    *0a353
    #33877
    #34052
    #34505
    #34054
    #34491
    #34632
    #34753
    #35042
    #35123
    #35089
    #35899 #36394 #37065 #37180
    #37199
    #37503
    #37296
    #37408
    #37622
    #37874
    #38258
    #38339
    #39190
    #38531
    #38580
    #38581
    #38672
    #32075
    #32271
    #32396
    #32274
    #33637
    #33770
    #34495 #34969
    #35102
    #35242
    #36560
    #36565
    #36756
    #36770
    #36814
    #37185
    #37182
    #37231
    #37276
    #37277
    #37279
    #37280
    #37695
    #37873
    #37963
    #38008
    #38004
    #34495
    #38536
    #38609
    #37298
    #37364
    #37368
    #37443
    #38011
    #37280
    #38209
    #38684
    #38670
    #38920
    #38770

    View full-size slide

  8. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #32075
    #32271
    #32396
    #32274
    #33637
    #33770
    #34495 #34969
    #35102
    #35242
    #36560
    #36565
    #36756
    #36770
    #36814
    #37185
    #37182
    #37231
    #37276
    #37277
    #37279
    #37280
    #37695
    #37873
    #37963
    #38008
    #38004
    #34495
    #38536
    #38609
    #32774 #33748 #35479
    #35663
    #36023
    #36039
    #36237 *d83ab
    #36824
    #37223
    #37242
    #37291
    #37230
    #37365
    *48d58
    *0a353
    #35073
    #35130
    #35237
    #36469 #36834
    #36868
    #38042
    #37298
    #37364
    #37368
    #37443
    #38011
    #37280
    #38209
    #33877
    #34052
    #34505
    #34054
    #34491
    #34632
    #34753
    #35042
    #35123
    #35089
    #35899 #36394 #37065 #37180
    #37199
    #37503
    #37296
    #37408
    #37622
    #37874
    #38258
    #38339
    #39190
    #38531
    #38580
    #38684
    #38670
    #38920
    #38770
    #38581
    #38672

    View full-size slide

  9. What are
    multiple
    databases?

    View full-size slide

  10. Application
    Demo

    View full-size slide

  11. Design &
    Architecture

    View full-size slide

  12. What are
    multiple
    databases?

    View full-size slide


  13. PRODUCTION
    APPLICATION
    Standard setup

    View full-size slide


  14. APPLICATION
    Horizontal sharding
    ROWS A-I
    ROWS J-R
    ROWS S-Z
    PRODUCTION

    View full-size slide


  15. APPLICATION
    Functional partitioning
    PRODUCTION
    MEALS
    PRODUCTION
    SIDES
    PRODUCTION
    DESSERTS

    View full-size slide


  16. APPLICATION
    Read replicas
    PRODUCTION
    REPLICA 1
    REPLICA 2
    REPLICA 3

    View full-size slide

  17. Application
    Demo

    View full-size slide

  18. Recipes Application

    APPLICATION

    View full-size slide


  19. APPLICATION
    Recipes Application
    PRIMARY

    View full-size slide

  20. Recipes Application
    MEALS

    APPLICATION PRIMARY

    View full-size slide

  21. Recipes Application
    MEALS

    APPLICATION PRIMARY
    REPLICA
    REPLICAS

    View full-size slide

  22. Design &
    Architecture

    View full-size slide

  23. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    Migrations
    #38684

    View full-size slide

  24. bin/rails g scaffold DinnerRecipe title:string recipe:text
    --database meals_default

    View full-size slide

  25. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #32075
    #32271
    #32396
    #32274
    #33637
    #33770
    #34495 #34969
    #35102
    #35242
    #36560
    #36565
    #36756
    #36770
    #36814
    #37185
    #37182
    #37231
    #37276
    #37277
    #37279
    #37280
    #37695
    #37873
    #37963
    #38008
    #38004
    #34495
    #38536
    #38609
    #37298
    #37364
    #37368
    #37443
    #38011
    #37280
    #38209
    Database Configurations
    #38670
    #38920

    View full-size slide

  26. development:
    database: recipes_development
    test:
    database: recipes_test
    production:
    database: recipes_production

    View full-size slide

  27. {
    "development" => {
    "database" => "recipes_development"
    },
    "test" => {
    "database" => "recipes_test"
    },
    "production" => {
    "database" => "recipes_production"
    }
    }

    View full-size slide

  28. development:
    primary:
    database: recipes_development
    primary_replica:
    database: recipes_development
    replica: true
    test:
    primary:
    database: recipes_test
    primary_replica:
    database: recipes_test
    replica: true
    production:
    primary:
    database: recipes_production
    primary_replica:
    database: recipes_production
    replica: true

    View full-size slide

  29. {
    "development" => {
    "primary" => { "database" => "recipes_development" },
    "primary_replica" => {
    "database" => "recipes_development", "replica" => true
    },
    }
    "test" => {
    "primary" => { "database" => "recipes_test" },
    "primary_replica" => {
    "database" => "recipes_test", "replica" => true
    },
    },
    "production" => {
    "primary" => { "database" => "recipes_production" },
    "primary_replica" => {
    "database" => "recipes_production", "replica" => true
    },
    }
    }

    View full-size slide

  30. Configuration as
    Objects

    View full-size slide

  31. #@env_name = "production",
    @name = "primary",
    @configuration_hash = {
    :adapter => "mysql2",
    :database => "recipes_app_development"
    }
    >

    View full-size slide

  32. DATABASE_URL=
    "postgres://root:pass123@localhost:9000/my_database"

    View full-size slide

  33. DATABASE_URL="postgres://root:pass123@localhost:9000/my_database"
    #@env_name = "production",
    @name = "primary",
    @configuration_hash = {
    :adapter => "postgres",
    :database => "my_database",
    :host => "localhost",
    :username => "root",
    :password => "pass123"
    },
    @url = "postgres://root:pass123@localhost:9000/my_database"
    >

    View full-size slide

  34. initializer "active_record.initialize_database" do
    ActiveSupport.on_load(:active_record) do
    self.connection_handlers = {
    writing_role => ActiveRecord::Base.default_connection_handler
    }
    self.configurations =
    Rails.application.config.database_configuration
    establish_connection
    end
    end

    View full-size slide

  35. def self.configurations=(config)
    @@configurations = ActiveRecord::DatabaseConfigurations.new(config)
    end
    module ActiveRecord
    class DatabaseConfigurations
    def initialize(configurations = {})
    @configurations = build_configs(configurations)
    end
    end
    end

    View full-size slide

  36. #@configurations=[
    #@env_name = "production",
    @name = "primary",
    @configuration_hash = {
    :adapter => "mysql2",
    :database => "recipes_app_development"
    }
    >,
    #@env_name = "production",
    @name = "meals_one",
    @configuration_hash = {
    :adapter => "mysql2",
    :database => "meals_one_development"
    }
    >
    ]
    >

    View full-size slide

  37. ActiveRecord::Base.configurations.configs_for(
    env_name: "production"
    )

    View full-size slide

  38. ActiveRecord::Base.configurations.configs_for(
    env_name: "production"
    )
    #@configurations=[
    #"production", @name = "primary", @configuration_hash = {
    :adapter => "mysql2", :database => "recipes_app_development"
    }>,
    #"production", @name = "meals_one", @configuration_hash = {
    :adapter => "mysql2", :database => "meals_one_development"
    }>,
    #"production", @name = "meals_two", @configuration_hash = {
    :adapter => "mysql2", :database => "meals_two_development"
    }>
    ]
    >

    View full-size slide

  39. ActiveRecord::Base.configurations.configs_for(
    env_name: "production",
    name: "meals_one"
    )

    View full-size slide

  40. ActiveRecord::Base.configurations.configs_for(
    env_name: "production",
    name: "meals_one"
    )
    #"production", @name = "meals_one", @configuration_hash = { :adapter
    => "mysql2", :database => "meals_one_development" }>

    View full-size slide

  41. ActiveRecord::Base.configurations.configs_for(
    env_name: "production",
    include_replicas: true
    )

    View full-size slide

  42. ActiveRecord::Base.configurations.configs_for(
    env_name: "production",
    name: "meals_one"
    )
    #"production", @name = "meals_one", @configuration_hash = { :adapter
    => "mysql2", :database => "meals_one_development", :replica =>
    true }>

    View full-size slide

  43. Using Objects
    Everywhere

    View full-size slide

  44. >> db_config.configuration_hash[:database]
    => "meals_one_development"

    View full-size slide

  45. >> db_config.configuration_hash[:database]
    => "meals_one_development"
    >> db_config.database
    => "meals_one_development"

    View full-size slide

  46. { "database" => "recipes_development", "replica" => true
    "adapter" => "mysql2", "reaping_frequency" => 60,
    "username" => "user_ro", "password" => ENV["PASSWORD"]}

    View full-size slide

  47. { "database" => "recipes_development", "replica" => true
    "adapter" => "mysql2", "reaping_frequency" => 60,
    "username" => "user_ro", "password" => ENV["PASSWORD"]...}
    Values Rails Needs
    • database
    • host
    • adapter
    • replica
    • pool
    • reaping_frequency
    • checkout_timeout
    • idle_timeout

    View full-size slide

  48. { "database" => "recipes_development", "replica" => true
    "adapter" => "mysql2", "reaping_frequency" => 60,
    "username" => "user_ro", "password" => ENV["PASSWORD"]...}
    • database
    • host
    • adapter
    • replica
    • pool
    • reaping_frequency
    • checkout_timeout
    • idle_timeout
    • database
    • host
    • username
    • password
    • timeout
    • custom settings
    Values Rails Needs Values Clients Need

    View full-size slide

  49. class HashConfig
    ...
    def checkout_timeout
    (configuration_hash[:checkout_timeout] || 5).to_f
    end
    def reaping_frequency
    configuration_hash.fetch(:reaping_frequency, 60)&.to_f
    end
    def idle_timeout
    timeout = configuration_hash.fetch(:idle_timeout, 300).to_f
    timeout if timeout > 0
    end
    ...
    end

    View full-size slide

  50. - @checkout_timeout =
    (spec.db_config.configuration_hash[:checkout_timeout] &&
    spec.db_config.configuration_hash[:checkout_timeout].to_f) || 5
    - if @idle_timeout =
    spec.db_config.configuration_hash.fetch(:idle_timeout, 300)
    - @idle_timeout = @idle_timeout.to_f
    - @idle_timeout = nil if @idle_timeout <= 0
    - end
    - # default max pool size to 5
    - @size = (spec.db_config.configuration_hash[:pool] &&
    spec.db_config.configuration_hash[:pool].to_i) || 5
    + @checkout_timeout = spec.db_config.checkout_timeout
    + @idle_timeout = spec.db_config.idle_timeout
    + @size = spec.db_config.pool

    View full-size slide

  51. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #32774 #33748 #35479
    #35663
    #36023
    #36039
    #36237 *d83ab
    #36824
    #37223
    #37242
    #37291
    #37230
    #37365
    *48d58
    *0a353
    Rails Tasks
    #38770

    View full-size slide

  52. rails db:create
    rails db:drop
    rails db:migrate
    rails db:reset
    rails db:abort_if_pending_migrations
    rails db:migrate:status
    rails db:structure:dump
    rails db:schema:cache:dump

    View full-size slide

  53. task migrate: :load_config do
    original_db_config = ActiveRecord::Base.connection_db_config
    ActiveRecord::Base.configurations.configs_for(
    env_name: ActiveRecord::Tasks::DatabaseTasks.env
    ).each do |db_config|
    ActiveRecord::Base.establish_connection(db_config)
    ActiveRecord::Tasks::DatabaseTasks.migrate
    end
    db_namespace["_dump"].invoke
    ensure
    ActiveRecord::Base.establish_connection(original_db_config)
    end

    View full-size slide

  54. task migrate: :load_config do
    original_db_config = ActiveRecord::Base.connection_db_config
    ActiveRecord::Base.configurations.configs_for(
    env_name: ActiveRecord::Tasks::DatabaseTasks.env
    ).each do |db_config|
    ActiveRecord::Base.establish_connection(db_config)
    ActiveRecord::Tasks::DatabaseTasks.migrate
    end
    db_namespace["_dump"].invoke
    ensure
    ActiveRecord::Base.establish_connection(original_db_config)
    end

    View full-size slide

  55. task migrate: :load_config do
    original_db_config = ActiveRecord::Base.connection_db_config
    ActiveRecord::Base.configurations.configs_for(
    env_name: ActiveRecord::Tasks::DatabaseTasks.env
    ).each do |db_config|
    ActiveRecord::Base.establish_connection(db_config)
    ActiveRecord::Tasks::DatabaseTasks.migrate
    end
    db_namespace["_dump"].invoke
    ensure
    ActiveRecord::Base.establish_connection(original_db_config)
    end

    View full-size slide

  56. task migrate: :load_config do
    original_db_config = ActiveRecord::Base.connection_db_config
    ActiveRecord::Base.configurations.configs_for(
    env_name: ActiveRecord::Tasks::DatabaseTasks.env
    ).each do |db_config|
    ActiveRecord::Base.establish_connection(db_config)
    ActiveRecord::Tasks::DatabaseTasks.migrate
    end
    db_namespace["_dump"].invoke
    ensure
    ActiveRecord::Base.establish_connection(original_db_config)
    end

    View full-size slide

  57. task migrate: :load_config do
    original_db_config = ActiveRecord::Base.connection_db_config
    ActiveRecord::Base.configurations.configs_for(
    env_name: ActiveRecord::Tasks::DatabaseTasks.env
    ).each do |db_config|
    ActiveRecord::Base.establish_connection(db_config)
    ActiveRecord::Tasks::DatabaseTasks.migrate
    end
    db_namespace["_dump"].invoke
    ensure
    ActiveRecord::Base.establish_connection(original_db_config)
    end

    View full-size slide

  58. rails db:create:primary
    rails db:create:meals_default
    rails db:create:meals_one
    rails db:create:meals_two
    rails db:drop:primary
    rails db:drop:meals_default
    rails db:drop:meals_one
    rails db:drop:meals_two
    rails db:migrate:primary
    rails db:drop:meals_default
    rails db:migrate:meals_one
    rails db:migrate:meals_two

    View full-size slide

  59. namespace :migrate do
    ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
    desc "Migrate #{name} database for current environment"
    task name => :load_config do
    original_db_config = ActiveRecord::Base.connection_db_config
    db_config = ActiveRecord::Base.configurations.configs_for(
    env_name: Rails.env, name: name
    )
    ActiveRecord::Base.establish_connection(db_config)
    ActiveRecord::Tasks::DatabaseTasks.migrate
    db_namespace["_dump:#{name}"].invoke
    ensure
    ActiveRecord::Base.establish_connection(original_db_config)
    end
    end
    end

    View full-size slide

  60. namespace :migrate do
    ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
    desc "Migrate #{name} database for current environment"
    task name => :load_config do
    original_db_config = ActiveRecord::Base.connection_db_config
    db_config = ActiveRecord::Base.configurations.configs_for(
    env_name: Rails.env, name: name
    )
    ActiveRecord::Base.establish_connection(db_config)
    ActiveRecord::Tasks::DatabaseTasks.migrate
    db_namespace["_dump:#{name}"].invoke
    ensure
    ActiveRecord::Base.establish_connection(original_db_config)
    end
    end
    end

    View full-size slide

  61. def load_database_yaml
    if path = paths["config/database"].existent.first
    require "rails/application/dummy_erb_compiler"
    yaml = Pathname.new(path)
    erb = DummyERB.new(yaml.read)
    YAML.load(erb.result) || {}
    else
    {}
    end
    end

    View full-size slide

  62. class DummyERB < ERB # :nodoc:
    def make_compiler(trim_mode)
    DummyCompiler.new trim_mode
    end
    end
    class DummyCompiler < ERB::Compiler # :nodoc:
    def compile_content(stag, out)
    if stag == "<%="
    out.push "_erbout << ''"
    end
    end
    end

    View full-size slide

  63. namespace :migrate do
    ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
    desc "Migrate #{name} database for current environment"
    task name => :load_config do
    original_db_config = ActiveRecord::Base.connection_db_config
    db_config = ActiveRecord::Base.configurations.configs_for(
    env_name: Rails.env, name: name
    )
    ActiveRecord::Base.establish_connection(db_config)
    ActiveRecord::Tasks::DatabaseTasks.migrate
    db_namespace["_dump:#{name}"].invoke
    ensure
    ActiveRecord::Base.establish_connection(original_db_config)
    end
    end
    end

    View full-size slide

  64. ❌ rake db:migrate:up
    ❌ rake db:migrate:down
    ❌ rake db:rollback

    View full-size slide

  65. ✅ rails db:migrate:up:primary
    ✅ rails db:migrate:up:meals_one
    ✅ rails db:migrate:up:meals_two
    ✅ rails db:migrate:down:primary
    ✅ rails db:migrate:down:meals_one
    ✅ rails db:migrate:down:meals_two
    ✅ rails db:rollback:primary
    ✅ rails db:rollback:meals_one
    ✅ rails db:rollback:meals_two

    View full-size slide

  66. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    Connection APIs
    #33877
    #34052
    #34505
    #34054
    #34491
    #34632
    #34753
    #35042
    #35123
    #35089
    #35899 #36394 #37065 #37180
    #37199
    #37503
    #37296
    #37408
    #37622
    #37874
    #38258
    #38339
    #39190
    #38531
    #38580
    #38581
    #38672

    View full-size slide

  67. connects_to API

    View full-size slide

  68. initializer "active_record.initialize_database" do
    ActiveSupport.on_load(:active_record) do
    self.connection_handlers = {
    writing_role => ActiveRecord::Base.default_connection_handler
    }
    self.configurations =
    Rails.application.config.database_configuration
    establish_connection
    end
    end

    View full-size slide

  69. class ApplicationRecord < ActiveRecord::Base
    self.abstract_class = true
    connects_to database: {
    writing: :primary, reading: :primary_replica
    }
    end

    View full-size slide

  70. class ApplicationRecord < ActiveRecord::Base
    self.abstract_class = true
    connects_to database: {
    writing: :primary, reading: :primary_replica
    }
    end
    Role

    View full-size slide

  71. class ApplicationRecord < ActiveRecord::Base
    self.abstract_class = true
    connects_to database: {
    writing: :primary, reading: :primary_replica
    }
    end
    Name

    View full-size slide

  72. class ApplicationRecord < ActiveRecord::Base
    self.abstract_class = true
    connects_to database: {
    writing: :primary, reading: :primary_replica
    }
    end

    View full-size slide

  73. class MealApplicationRecord < ApplicationRecord
    self.abstract_class = true
    connects_to shards: {
    default: {
    writing: :meals_default, reading: :meals_default_replica
    },
    shard_one: {
    writing: :meals_one, reading: :meals_one_replica
    }
    shard_two: {
    writing: :meals_two, reading: :meals_two_replica
    }
    }
    end

    View full-size slide

  74. class MealApplicationRecord < ApplicationRecord
    self.abstract_class = true
    connects_to shards: {
    default: {
    writing: :meals_default, reading: :meals_default_replica
    },
    shard_one: {
    writing: :meals_one, reading: :meals_one_replica
    }
    shard_two: {
    writing: :meals_two, reading: :meals_two_replica
    }
    }
    end
    Shard key

    View full-size slide

  75. class MealApplicationRecord < ApplicationRecord
    self.abstract_class = true
    connects_to shards: {
    default: {
    writing: :meals_default, reading: :meals_default_replica
    },
    shard_one: {
    writing: :meals_one, reading: :meals_one_replica
    }
    shard_two: {
    writing: :meals_two, reading: :meals_two_replica
    }
    }
    end
    Role

    View full-size slide

  76. class MealApplicationRecord < ApplicationRecord
    self.abstract_class = true
    connects_to shards: {
    default: {
    writing: :meals_default, reading: :meals_default_replica
    },
    shard_one: {
    writing: :meals_one, reading: :meals_one_replica
    }
    shard_two: {
    writing: :meals_two, reading: :meals_two_replica
    }
    }
    end
    Name

    View full-size slide

  77. connected_to API

    View full-size slide

  78. ActiveRecord::Base.connected_to(role: :reading) do
    User.first
    DinnerRecipe.first
    end

    View full-size slide

  79. ActiveRecord::Base.connected_to(role: :reading) do
    DinnerRecipe.create! # boom
    end
    => ActiveRecord::ReadOnlyError

    View full-size slide

  80. ActiveRecord::Base.connected_to(role: :writing, prevent_writes: true) do
    DinnerRecipe.create! # boom
    end
    => ActiveRecord::ReadOnlyError

    View full-size slide

  81. ActiveRecord::Base.connected_to(shard: :shard_two) do
    DinnerRecipe.create!
    end

    View full-size slide

  82. ActiveRecord::Base.connected_to(
    shard: :shard_two, role: :reading
    ) do
    DinnerRecipe.create!
    end

    View full-size slide

  83. ActiveRecord::Base.connected_to(shard: :shard_two) do
    User.create!
    end
    => ActiveRecord::ConnectionNotEstablished

    View full-size slide

  84. :writing
    ActiveRecord::Base

    View full-size slide

  85. :writing
    ActiveRecord::Base
    PoolConfig

    View full-size slide

  86. :writing
    ActiveRecord::Base
    conn_spec_name
    PoolConfig

    View full-size slide

  87. :writing
    ActiveRecord::Base
    conn_spec_name
    db_config
    PoolConfig

    View full-size slide

  88. :writing
    ActiveRecord::Base
    conn_spec_name
    db_config
    schema_cache
    PoolConfig

    View full-size slide

  89. :writing
    ActiveRecord::Base
    conn_spec_name
    db_config
    schema_cache
    PoolConfig
    ConnectionPool

    View full-size slide

  90. :writing
    ActiveRecord::Base
    PoolConfig
    ConnectionPool
    MealApplicationR...
    PoolConfig
    ConnectionPool

    View full-size slide

  91. :writing
    ActiveRecord::Base
    :writing
    MealApplicationR...
    :reading
    ActiveRecord::Base
    PoolConfig
    MealApplicationR...
    PoolConfig
    ConnectionPool ConnectionPool
    PoolConfig
    ConnectionPool
    PoolConfig
    ConnectionPool

    View full-size slide

  92. :writing
    ActiveRecord::Base MealApplicationR...
    PoolConfig
    ConnectionPool
    PoolConfig
    ConnectionPool

    View full-size slide

  93. :writing
    ActiveRecord::Base
    PoolConfig
    MealApplicationR...
    PoolConfig
    ConnectionPool ConnectionPool
    MealApplicationR...
    PoolConfig
    ConnectionPool

    View full-size slide

  94. :writing
    ActiveRecord::Base MealApplicationR... MealApplicationR...
    PoolConfig
    ConnectionPool
    MealApplicationR...
    PoolConfig
    ConnectionPool
    PoolConfig
    ConnectionPool
    PoolConfig
    ConnectionPool

    View full-size slide

  95. :writing
    ActiveRecord::Base
    Pool Config
    Connection Pool
    :default
    PoolConfig
    ConnectionPool
    ActiveRecord::Base

    View full-size slide

  96. :writing
    :default
    PoolConfig
    ConnectionPool
    :shard_one
    PoolConfig
    ConnectionPool
    :shard_two
    PoolConfig
    ConnectionPool
    MealApplicationBase
    ActiveRecord::Base
    Pool Config
    Connection Pool
    :default
    PoolConfig
    ActiveRecord::Base
    ConnectionPool

    View full-size slide

  97. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #35073
    #35130
    #35237
    #36469 #36834
    #36868
    #38042
    Automatic connection
    swapping

    View full-size slide

  98. Rails.application.configure do
    config.active_record.database_selector = { delay: 2.seconds }
    config.active_record.database_resolver =
    ActiveRecord::Middleware::DatabaseSelector::Resolver
    config.active_record.database_resolver_context =
    ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
    end

    View full-size slide

  99. class DatabaseSelector
    def initialize(app, resolver_klass = nil,
    context_klass = nil, options = {})
    @app = app
    @resolver_klass = resolver_klass || Resolver
    @context_klass = context_klass || Resolver::Session
    @options = options
    end
    ...
    end

    View full-size slide

  100. class DatabaseSelector
    def call(env)
    request = ActionDispatch::Request.new(env)
    select_database(request) do
    @app.call(env)
    end
    end
    ...
    end

    View full-size slide

  101. class DatabaseSelector
    def select_database(request, &blk)
    context = context_klass.call(request)
    resolver = resolver_klass.call(context, options)
    response = if reading_request?(request)
    resolver.read(&blk)
    else
    resolver.write(&blk)
    end
    resolver.update_context(response)
    response
    end
    end

    View full-size slide

  102. class DatabaseSelector
    def select_database(request, &blk)
    context = context_klass.call(request)
    resolver = resolver_klass.call(context, options)
    response = if reading_request?(request)
    resolver.read(&blk)
    else
    resolver.write(&blk)
    end
    resolver.update_context(response)
    response
    end
    end

    View full-size slide

  103. class Resolver # :nodoc:
    ...
    def read(&blk)
    if read_from_primary?
    read_from_primary(&blk)
    else
    read_from_replica(&blk)
    end
    end
    end

    View full-size slide

  104. class Resolver
    ...
    def read_from_primary?
    !time_since_last_write_ok?
    end
    def time_since_last_write_ok?
    Time.now - context.last_write_timestamp >= delay
    end
    end

    View full-size slide

  105. class Resolver
    ...
    def read_from_primary(&blk)
    ActiveRecord::Base.connected_to(
    role: ActiveRecord::Base.writing_role,
    prevent_writes: true
    ) do
    instrumenter.instrument("database_selector") do
    yield
    end
    end
    end
    end

    View full-size slide

  106. class Resolver
    ...
    def read_from_replica(&blk)
    ActiveRecord::Base.connected_to(
    role: ActiveRecord::Base.reading_role,
    prevent_writes: true
    ) do
    instrumenter.instrument("database_selector") do
    yield
    end
    end
    end
    end

    View full-size slide

  107. class Resolver
    ...
    def write_to_primary(&blk)
    ActiveRecord::Base.connected_to(
    role: ActiveRecord::Base.writing_role,
    prevent_writes: false
    ) do
    instrumenter.instrument("database_selector") do
    yield
    ensure
    context.update_last_write_timestamp
    end
    end
    end
    end

    View full-size slide

  108. class Resolver
    class Cookie
    def self.call(request)
    new(request.cookies)
    end
    def initialize(cookies)
    @cookies = cookies
    end
    def update_last_write_timestamp
    @cookies[:last_write] =
    self.class.convert_time_to_timestamp(Time.now)
    end
    end
    end

    View full-size slide

  109. Rails.application.configure do
    config.active_record.database_selector = { delay: 2.seconds }
    config.active_record.database_resolver =
    ActiveRecord::Middleware::DatabaseSelector::Resolver
    config.active_record.database_resolver_context =
    ActiveRecord::Middleware::DatabaseSelector::Resolver::Cookies
    end

    View full-size slide

  110. Thank You

    View full-size slide

  111. Abe Uchitelle

    View full-size slide

  112. And all of you

    View full-size slide

  113. Extracting
    to Upstream
    a

    View full-size slide

  114. Migrations didn’t run,

    View full-size slide

  115. Migrations didn’t run,
    configurations were broken,

    View full-size slide

  116. Rails
    tasks didn’t work correctly,
    Migrations didn’t run,
    configurations were broken,

    View full-size slide

  117. Migrations didn’t run,
    configurations were broken, Rails
    tasks didn’t work correctly, no
    way for models to establish
    multiple connections,

    View full-size slide

  118. no
    API or pattern for auto-switching
    connections...
    Migrations didn’t run,
    configurations were broken, Rails
    tasks didn’t work correctly, no
    way for models to establish
    multiple connections,

    View full-size slide

  119. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #38684

    View full-size slide

  120. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #32075
    #32271
    #32396
    #32274
    #33637
    #33770
    #34495 #34969
    #35102
    #35242
    #36560
    #36565
    #36756
    #36770
    #36814
    #37185
    #37182
    #37231
    #37276
    #37277
    #37279
    #37280
    #37695
    #37873
    #37963
    #38008
    #38004
    #34495
    #38536
    #38609
    #37298
    #37364
    #37368
    #37443
    #38011
    #37280
    #38209
    #38670
    #38920
    #38684

    View full-size slide

  121. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #32075
    #32271
    #32396
    #32274
    #33637
    #33770
    #34495 #34969
    #35102
    #35242
    #36560
    #36565
    #36756
    #36770
    #36814
    #37185
    #37182
    #37231
    #37276
    #37277
    #37279
    #37280
    #37695
    #37873
    #37963
    #38008
    #38004
    #34495
    #38536
    #38609
    #37298
    #37364
    #37368
    #37443
    #38011
    #37280
    #38209
    #32774 #33748 #35479
    #35663
    #36023
    #36039
    #36237 *d83ab
    #36824
    #37223
    #37242
    #37291
    #37230
    #37365
    *48d58
    *0a353
    #38770
    #38684
    #38670
    #38920

    View full-size slide

  122. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #32774 #33748 #35479
    #35663
    #36023
    #36039
    #36237 *d83ab
    #36824
    #37223
    #37242
    #37291
    #37230
    #37365
    *48d58
    *0a353
    #32075
    #32271
    #32396
    #32274
    #33637
    #33770
    #34495 #34969
    #35102
    #35242
    #36560
    #36565
    #36756
    #36770
    #36814
    #37185
    #37182
    #37231
    #37276
    #37277
    #37279
    #37280
    #37695
    #37873
    #37963
    #38008
    #38004
    #34495
    #38536
    #38609
    #37298
    #37364
    #37368
    #37443
    #38011
    #37280
    #38209
    #33877
    #34052
    #34505
    #34054
    #34491
    #34632
    #34753
    #35042
    #35123
    #35089
    #35899 #36394 #37065 #37180
    #37199
    #37503
    #37296
    #37408
    #37622
    #37874
    #38258
    #38339
    #39190
    #38531
    #38580
    #38581
    #38672
    #38684
    #38670
    #38920
    #38770

    View full-size slide

  123. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #32075
    #32271
    #32396
    #32274
    #33637
    #33770
    #34495 #34969
    #35102
    #35242
    #36560
    #36565
    #36756
    #36770
    #36814
    #37185
    #37182
    #37231
    #37276
    #37277
    #37279
    #37280
    #37695
    #37873
    #37963
    #38008
    #38004
    #34495
    #38536
    #38609
    #32774 #33748 #35479
    #35663
    #36023
    #36039
    #36237 *d83ab
    #36824
    #37223
    #37242
    #37291
    #37230
    #37365
    *48d58
    *0a353
    #37298
    #37364
    #37368
    #37443
    #38011
    #37280
    #38209
    #33877
    #34052
    #34505
    #34054
    #34491
    #34632
    #34753
    #35042
    #35123
    #35089
    #35899 #36394 #37065 #37180
    #37199
    #37503
    #37296
    #37408
    #37622
    #37874
    #38258
    #38339
    #39190
    #38531
    #38580
    #35073
    #35130
    #35237
    #36469 #36834
    #36868
    #38042
    #38684
    #38670
    #38920
    #38770
    #38581
    #38672

    View full-size slide

  124. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #32075
    #32271
    #32396
    #32274
    #33637
    #33770
    #34495 #34969
    #35102
    #35242
    #36560
    #36565
    #36756
    #36770
    #36814
    #37185
    #37182
    #37231
    #37276
    #37277
    #37279
    #37280
    #37695
    #37873
    #37963
    #38008
    #38004
    #34495
    #38536
    #38609
    #32774 #33748 #35479
    #35663
    #36023
    #36039
    #36237 *d83ab
    #36824
    #37223
    #37242
    #37291
    #37230
    #37365
    *48d58
    *0a353
    #35073
    #35130
    #35237
    #36469 #36834
    #36868
    #38042
    #37298
    #37364
    #37368
    #37443
    #38011
    #37280
    #38209
    #33877
    #34052
    #34505
    #34054
    #34491
    #34632
    #34753
    #35042
    #35123
    #35089
    #35899 #36394 #37065 #37180
    #37199
    #37503
    #37296
    #37408
    #37622
    #37874
    #38258
    #38339
    #39190
    #38531
    #38580
    #38581
    #38672
    #38670
    #38920
    #38684
    #38770
    Public APIs /
    User Experience

    View full-size slide

  125. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #32075
    #32271
    #32396
    #32274
    #33637
    #33770
    #34495 #34969
    #35102
    #35242
    #36560
    #36565
    #36756
    #36770
    #36814
    #37185
    #37182
    #37231
    #37276
    #37277
    #37279
    #37280
    #37695
    #37873
    #37963
    #38008
    #38004
    #34495
    #38536
    #38609
    #32774 #33748 #35479
    #35663
    #36023
    #36039
    #36237 *d83ab
    #36824
    #37223
    #37242
    #37291
    #37230
    #37365
    *48d58
    *0a353
    #35073
    #35130
    #35237
    #36469 #36834
    #36868
    #38042
    #37298
    #37364
    #37368
    #37443
    #38011
    #37280
    #38209
    #33877
    #34052
    #34505
    #34054
    #34491
    #34632
    #34753
    #35042
    #35123
    #35089
    #35899 #36394 #37065 #37180
    #37199
    #37503
    #37296
    #37408
    #37622
    #37874
    #38258
    #38339
    #39190
    #38531
    #38580
    #38581
    #38672
    #38670
    #38920
    #38684
    #38770
    Private APIs /
    Internals

    View full-size slide

  126. Rails already has
    a strong foundation

    View full-size slide

  127. Don't build for perfect,
    imaginary cases

    View full-size slide

  128. We built Rails
    for you

    View full-size slide

  129. We optimize for
    your happiness

    View full-size slide

  130. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #32075
    #32271
    #32396
    #32274
    #33637
    #33770
    #34495 #34969
    #35102
    #35242
    #36560
    #36565
    #36756
    #36770
    #36814
    #37185
    #37182
    #37231
    #37276
    #37277
    #37279
    #37280
    #37695
    #37873
    #37963
    #38008
    #38004
    #34495
    #38536
    #38609
    #32774 #33748 #35479
    #35663
    #36023
    #36039
    #36237 *d83ab
    #36824
    #37223
    #37242
    #37291
    #37230
    #37365
    *48d58
    *0a353
    #35073
    #35130
    #35237
    #36469 #36834
    #36868
    #38042
    #37298
    #37364
    #37368
    #37443
    #38011
    #37280
    #38209
    #33877
    #34052
    #34505
    #34054
    #34491
    #34632
    #34753
    #35042
    #35123
    #35089
    #35899 #36394 #37065 #37180
    #37199
    #37503
    #37296
    #37408
    #37622
    #37874
    #38258
    #38339
    #39190
    #38531
    #38580
    #38581
    #38672
    #38670
    #38920
    #38684
    #38770

    View full-size slide

  131. Technically,
    a Talk

    View full-size slide

  132. But actually,
    a love letter

    View full-size slide

  133. Jan 18
    Feb 18
    Mar 18
    Apr 18
    May 18
    Jun 18
    Jul 18
    Aug 18
    Sep 18
    Oct 18
    Nov 18
    Dec 18
    Jan 19
    Feb 19
    Mar 19
    Apr 19
    May 19
    Jun 19
    Jul 19
    Aug 19
    Sep 19
    Oct 19
    Nov 19
    Dec 19
    Jan 20
    Feb 20
    Mar 20
    Apr 20
    May 20
    #31727
    #33760 #36439
    #36371
    #36886 #38235
    #38444
    #32075
    #32271
    #32396
    #32274
    #33637
    #33770
    #34495 #34969
    #35102
    #35242
    #36560
    #36565
    #36756
    #36770
    #36814
    #37185
    #37182
    #37231
    #37276
    #37277
    #37279
    #37280
    #37695
    #37873
    #37963
    #38008
    #38004
    #34495
    #38536
    #38609
    #32774 #33748 #35479
    #35663
    #36023
    #36039
    #36237 *d83ab
    #36824
    #37223
    #37242
    #37291
    #37230
    #37365
    *48d58
    *0a353
    #35073
    #35130
    #35237
    #36469 #36834
    #36868
    #38042
    #37298
    #37364
    #37368
    #37443
    #38011
    #37280
    #38209
    #33877
    #34052
    #34505
    #34054
    #34491
    #34632
    #34753
    #35042
    #35123
    #35089
    #35899 #36394 #37065 #37180
    #37199
    #37503
    #37296
    #37408
    #37622
    #37874
    #38258
    #38339
    #39190
    #38531
    #38580
    #38581
    #38672
    #38670
    #38920
    #38684
    #38770

    View full-size slide