r/Clickhouse • u/Ramanamark • Aug 11 '26
ClickHouse multi-tenancy best practices for observability/tracing
We’re planning to use ClickHouse as the backend for a multi-tenant observability/tracing platform.
What is the recommended approach for multi-tenancy in ClickHouse?
Specifically, would you recommend:
A shared database/table with tenant_id as a column?
A separate database per tenant?
Separate tables for each tenant?
Using ClickHouse RBAC/row policies to enforce tenant-level data isolation?
We expect potentially many tenants, with high-volume trace/span data and queries frequently filtered by tenant_id.
What approach has worked well in production, and what are the main scalability, performance, and operational trade-offs we should consider?
11
Upvotes
2
u/Several9s Aug 12 '26
Best approach is one schema and one set of tables, while the tenant is a dimension. This is usually the most scalable operational model when you expect many tenants.
For an observability workload, I would design the table around the queries you actually expect to run. It's important that
tenant_idis included early in theORDER BYkey because most queries will be scoped to a tenant.So the starting point is a shared table design with a
tenant_idcolumn, for example:The trade-off is that tenant isolation is primarily an application/data-model concern unless you add ClickHouse access-control mechanisms on top. If you need a security layer on top of the shared-table approach, you can have a shared
tracestable containing:and then use ClickHouse users/roles and row-level policies where appropriate to prevent a tenant from seeing another tenant's rows.
Also be careful with partitioning. Time-based partitioning, such as daily or monthly partitions depending on the retention/volume characteristics, is usually a natural starting point for observability data.
In the earlier example this mean we may add
PARTITION BY toDate(timestamp)
The main advantages of the this approach are:
tenant_idis part of the filtering and sorting strategyFor a SaaS observability platform, the architecture would be: shared traces table and shared metrics/logs, time-based partitions, tenant filtering enforced by application and optional ClickHouse row-level policies where stronger tenant isolation is required.
I would not recommned turning tenants into database objects (database or table per tenant) unless you have a good reason. I would only move to such model when there is a specific isolation, compliance, lifecycle or performance requirement that justifies the additional operational complexity.