Skip to content

Flexible switching for multihost/sharding support #438

@mikecmpbll

Description

@mikecmpbll

Flexible switching

This will make multi-host support a first-class citizen in Apartment. By
flexibly choosing the switching technique we can support tenants across many
hosts. This makes logical sharding at the application level very simple.

  • If config.always_switch_connections = true (or similar), always establish
    a new connection on switch.
  • If the database host matches the current tenant's host, use 'local'
    switching (schemas on pg, use on mysql).
  • If the host does not match the current tenant's host, connect to the
    correct host first, and then do local swiching.
  • Mirror connection_handler.establish_connection's API by accepting a URL,
    a configuration hash, or a database.yml connection symbol.
  • All modes of switching 100% threadsafe.

This will target Rails 5.1 and above only (due to the vastly improved connection handler API) and will not be backported.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions