<@U0A71G31CDV> Could you please help us understand...
# questions-and-troubleshooting
m
@Rocky Could you please help us understand how StarRocks works in a shared-data architecture (FE + CN), where the actual data is stored in S3? Specifically, I would like to understand how database-level isolation works in this architecture and whether creating separate databases for each customer, with only a few tables in each database, is considered a good practice. Does creating multiple databases provide actual data isolation at the storage level in S3, or is the isolation primarily logical and managed through StarRocks metadata and permissions? It would be helpful to understand the recommended approach, along with any potential advantages or drawbacks, so we can make the right architectural decision. Thanks!
r
How shared-data works • FE holds the whole catalog (databases, tables, partitions, tablets) in memory /
meta_dir
, exactly as in shared-nothing. CNs are stateless: they execute query plans and cache hot data on local disk (
datacache.enable
, default
true
). • Data lives in a storage volume (S3/GCS/Azure/MinIO/HDFS). Per tablet, the CN writes
meta/
(
<tablet_id>_<version>.meta
),
data/
(
<txn_id>_<uuid>.dat
segment files) and
log/
. • From v3.1.4 data is organized by partition: table root path → partition-ID subdirectories →
data/
+
meta/
. You can see the exact S3 path with
SHOW PROC '/dbs/<db>'
(returns a
StoragePath
column). • Compaction and vacuum are scheduled by the FE over shared CN compute. Does db-per-customer give real isolation in S3? Partly — and you should be clear about which layer you mean: Physical separation exists but is path-level only. In the FE code a table's root path is allocated with the suffix
db<dbId>/<tableId>
, so each database does land under its own
db<dbId>
prefix in the bucket. That is useful for cost attribution, lifecycle policies and "which bytes belong to whom", but it is not a security boundary: all CNs access the bucket with the single credential set configured on the storage volume, so any CN can physically read any path in that volume. Actual access control is enforced by the FE (GRANT on database/table, roles, the USAGE privilege on the storage volume) — i.e. logical isolation over a shared physical namespace. The one way to get stronger storage-level separation is one storage volume per customer (different bucket/prefix, and different credentials — separate IAM user, assumed role or instance profile). Caveats, per the docs/source: • `CREATE DATABASE ... PROPERTIES ("storage_volume" = ...)`; tables inherit the database's volume, else the default volume. Users need USAGE on the named volume. • The volume binding is fixed at creation:
ALTER TABLE ... SET ("storage_volume"=...)
is not supported.
ALTER DATABASE ... SET ("storage_volume"=...)
only changes the database binding and affects only tables created afterwards. Moving existing data means rewriting it into new tables. • Beware the trap: if you
CREATE DATABASE
without the property, it binds to whatever default volume exists at that moment — a later
SET <vol> AS DEFAULT STORAGE VOLUME
does not move it. Compute isolation: open-source StarRocks has exactly one warehouse (
default_warehouse
);
CREATE WAREHOUSE
/ CNGROUP forms fail with "Multi-Warehouse is not implemented". So you cannot dedicate CNs to a customer or database inside one cluster. The documented per-database lever is resource groups + classifiers (
db='db1,db2'
,
user=
,
role=
with `cpu_weight`/`exclusive_cpu_cores` and
mem_limit
), i.e. CPU/memory fairness, not node pinning. Hard node-level separation means separate clusters (this last part is my inference from the above, the docs don't say it explicitly). Is db-per-customer a good practice? Docs don't prescribe "one database per tenant", and there are real costs you should weigh. What the material does support: Drawbacks of many small databases (a few tables each): 1. FE is the shared bottleneck. All metadata is in FE heap; the documented sizing is driven by tablet count (<1M tablets → 16 GB FE, 1–2M → 32 GB, 2–5M → 64 GB, 5–10M → 128 GB). Databases × tables × partitions × buckets all add up. In shared-data each tablet also has a metadata file in object storage, and the FAQ lists "too many buckets / many small files" and slow table creation as shared-data pain points. 2. DDL-heavy churn is documented as a problem: an FE memory case study covers customers creating dozens of tables per second; they needed
DROP TABLE ... FORCE
to release metadata, and lower DDL concurrency.
3. Config/ops duplication: storage volume bindings, roles, resource-group classifiers, backup/snapshot scope, MV refresh — all per database, and the volume can't be changed later. 4. You still don't get credential-level or compute-level isolation from it, so the main thing you buy is admin convenience and cross-tenant query prevention. Advantages that are real: • Different table schemas / retention / table types per customer without awkward shared tables. • Different storage volume per customer (region, bucket, IAM credential, cost tracking). • Clean
DROP DATABASE
for offboarding, and simpler privilege grants (
GRANT ALL ON DATABASE db_x
,
GRANT SELECT ON ALL TABLES IN DATABASE db_x
— wildcard grants also cover tables created later). • A
db=
resource-group classifier gets weight ×10× the number of listed dbs, so per-database CPU/memory groups are straightforward. The alternative pattern the docs do describe is a shared table with
tenant_id
: the partitioning best-practice page says to "add
tenant_id
into the key when you need to manage the data in tenant basis", with
PARTITION BY tenant_id, date_trunc('MONTH', dt)
+
DISTRIBUTED BY HASH(tenant_id)
for large tenants, and warns about partition explosion (#tenants × #partitions, keep total under ~100k). Isolation there is logical (privileges + whatever the app enforces); I did not find doc evidence of a built-in row-level security filter, so don't assume one exists — worth verifying against current docs before designing around it. Suggested decision rule • Many small customers, similar schema, cost-sensitive → one (or a few) databases,
tenant_id
column, tenant-aware partitioning/bucketing, per-tenant roles; isolate compute with resource groups. • Need per-customer credentials/regions/buckets, differing schemas, regulatory deletion → one database per customer, each explicitly bound to its own storage volume. Just size FE by tablet count and set an expectation for large customer counts. • Need hard compute/security separation → separate clusters (or CelerData Cloud, which offers warehouse-level isolation), since OSS multi-warehouse isn't implemented. If you tell me the expected number of customers and rough table/partition/tablet counts per customer, I can be more concrete about FE sizing — but I'd verify storage-volume-per-tenant behavior on your actual version, since the
storage_volume
binding rules above come from source inspection of 3.5/4.0/4.1 and the CREATE TABLE page is worded slightly differently ("default volume is used" vs. inheriting the database's volume). Points I'm not certain about and wouldn't rely on: any hard limit on number of databases in the FE, and whether row-level/masking policies exist in the OSS build — ask in the StarRocks Slack/forum or check the GitHub repo for those. References • quick_start/shared-data.md • deployment/feature-support-shared-data.md • introduction/Architecture.md • table_design/table_design.md • deployment/deploy_shared_data_manually.md • knowledge/qa/warehouses_and_isolation_in_open_source.md (StarRocks knowledge base)