← Graph

Nightmare neighbours caveats of Rails based mutlitenancy

talk 35 connections

Karol Szuster's wroclove.rb 2022 talk on the multi-tenant application pattern in Rails. Covers what multi-tenancy is and why we do it (quick setup, maintainability, cost), and the pivotal concern of isolating tenant data. Walks through three levels of partitioning: (1) row-level — each record has a tenant_id, implemented via default scopes and a per-request Singleton such as ActiveSupport::CurrentAttributes or RequestStore; (2) row-level hardened with Postgres row-level security (ENABLE ROW LEVEL SECURITY, policies comparing tenant_id to a session parameter, FORCE ROW LEVEL SECURITY to catch table owners), including caveats around connection pooling/session parameter reset and PgBouncer transaction pooling; (3) schema-level partitioning using the search_path session parameter (low-effort migration but custom migration process, harder backups — Heroku advises against, apartment authors soured on it); (4) database-level partitioning with a separate database per tenant — noting apartment's unsafe connection re-establishment pattern not thread-safe under Puma, and recommending Rails 6.1 horizontal sharding instead. Concludes with the Noisy Neighbor problem, application-level concerns (Sidekiq, Elasticsearch indices per tenant), and the core takeaway: decide early. Row-level is the default recommendation (Shopify, Salesforce). Q&A covers cross-tenant aggregation, the where-clause risk given acts_as_tenant's default, multi-column indexes scoped by tenant, and database views / read models per tenant.

type
talk
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Multi-Tenancy concept
Central topic of the talk.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Contrasted with multi-tenancy as the traditional approach.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
First of three partitioning levels covered.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Second partitioning level covered.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Third partitioning level covered.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Covered as a Postgres mechanism to harden row-level partitioning.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Recommended as the native Rails 6.1 replacement for apartment-style database-per-tenant switching.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Raised as a risk when tenants share resources in sharded deployments.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Shown as the native Rails mechanism to store the current tenant per request.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Mentioned as an older gem implementing per-request storage for the current tenant.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Recommended gem for row-level multi-tenancy; discussed in Q&A about WHERE-clause risk.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Alternative gem for row-level multi-tenancy.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Apartment tool
Discussed as the historical de-facto standard for schema- and database-per-tenant multi-tenancy and its thread-safety issues.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
PgBouncer tool
Covered as the typical external connection pooler when scaling Rails.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Explained as PgBouncer's default mode and its interaction with session-scoped tenant state.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
PostgreSQL tool
Row-level security and session parameters discussed in the Postgres context.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Talk focuses on Rails-based multi-tenancy implementations.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Puma tool
Cited as the threaded server under which apartment's thread-unsafety surfaces.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Unicorn tool
Cited as the fork server that masks apartment's thread-unsafety.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Heroku tool
Cited as advising against schema-per-tenant due to backup tooling limitations.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Shopify company
Cited as a recognizable multi-tenant Rails architecture using row-level partitioning.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Salesforce company
Cited alongside Shopify as a battle-tested multi-tenant architecture.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Sidekiq tool
Mentioned as an application-level concern requiring per-tenant handling.
talk Nightmare neighbours caveats of Rails based mutlitenancy
about
Mentioned as requiring separate indexes per tenant.
asked_at
Nightmare neighbours caveats of Rails based mutlitenancy talk
Asked in Q&A of the talk.
asked_at
Nightmare neighbours caveats of Rails based mutlitenancy talk
Asked in Q&A of the talk.
asked_at
Nightmare neighbours caveats of Rails based mutlitenancy talk
Asked in Q&A of the talk.
asked_at
Nightmare neighbours caveats of Rails based mutlitenancy talk
Audience remark in Q&A of the talk.
person Karol Szuster
authored
Nightmare neighbours caveats of Rails based mutlitenancy talk
Karol presented this talk at wroclove.rb 2022.
from_talk
Nightmare neighbours caveats of Rails based mutlitenancy talk
Concluding recommendation of the talk.
from_talk
Nightmare neighbours caveats of Rails based mutlitenancy talk
Given as the default recommendation in the Q&A.
from_talk
Nightmare neighbours caveats of Rails based mutlitenancy talk
Warning raised while discussing row-level security.
from_talk
Nightmare neighbours caveats of Rails based mutlitenancy talk
Warning raised while discussing database-per-tenant switching.
from_talk
Nightmare neighbours caveats of Rails based mutlitenancy talk
Recommendation when discussing row-level implementations.
talk Nightmare neighbours caveats of Rails based mutlitenancy
presented_at
Talk delivered at wroclove.rb 2022.

Provenance

Created
2026-04-17 16:17 seed
Read by
25 extractions