← Graph

Bucketing

concept 6 connections

Pattern Apply4 used to split a single-region multi-tenant database into per-region databases. An integer 'bucket' column is added to every relevant table (via a shared base-class Rails enum with values not_bucketed / region_1 / region_2 / shared). Records are then assigned a bucket value based on their domain relationship to an Authority (which has a country attribute). The team tried both bottom-up (from leaf records up to the Authority) and top-down (starting from each Authority and walking associations down) — top-down was significantly faster and simpler. A default_scope filtered by bucket lets you preview what each region's data will look like before physically separating. Physical separation is done by creating an empty copy of the table, inserting only records for the target bucket, renaming the originals to `_old`, and swapping names — which proved faster than deleting cross-region rows from the existing table.

category
pattern
Central technique of the talk: tag every record with a target region bucket before splitting.
about
Bucketing concept
Part of the answer explains that data extraction/bucketing happens in the source region.
concept Bucketing
related_to
Multi-Tenancy concept
Bucketing is applied on a multi-tenant schema where tenants are authorities.
related_to
Bucketing concept
Top-down traversal is the specific implementation technique for bucket assignment.
related_to
Bucketing concept
Table swap is the physical separation step that consumes bucket assignments.
related_to
Bucketing concept
File split mirrors the bucketing approach used for database records.

Provenance

Read by
2 extractions