跪拜 Guibai
← All articles
Database

Order Read/Writes Expose Where KingbaseES Centralized and Distributed Architectures Diverge

By 一只牛博 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Evaluating distributed databases by node count instead of request paths produces POC failures and wasted migrations. Mapping transactional writes, tenant-keyed reads, and global reports early tells you whether shared-storage RAC, distributed TDC, or a single centralized instance is the right baseline.

Summary

A payment debits an account, writes a ledger row, and updates order status in one transaction; a month-end report aggregates all tenants by time. The first needs atomic multi-table commit, the second needs a wide scan. Splitting these two access shapes before counting nodes clears up architecture evaluation.

KingbaseES core is centralized, RAC adds shared-storage multi-write nodes, and TDC distributes data and compute. Each changes what you must verify: RAC puts storage bandwidth at the center, TDC demands that distribution keys match real request parameters. The article walks through payment SQL, tenant-key queries, full-tenant reports, and hot-spot analysis, showing how each workload determines whether a single tenant key, composite indexes, or a mixed-load POC makes sense.

The core method is to test with the same request set, adjust one variable at a time, and measure P95/P99, lock waits, connection recovery, and resource usage while checking business results for duplicates. Only then do numbers justify a centralized, RAC, or TDC choice.

Takeaways
— KES core is a centralized relational database; RAC shares storage among multi-write nodes, while TDC separately scales compute and storage for horizontal capacity.
— Payment involves three tables that must commit atomically; the balance update should include a sufficient-balance condition and row-count checks to trigger rollback.
— Idempotency requires both a unique constraint on ledger rows and a server-side request-ID check to handle retries after ambiguous commit timeouts.
— A distribution key like tenant_id narrows order-detail reads but forces full-tenant reports to scan across all nodes; whether they do depends on table distribution and query plan, not just SQL syntax.
— Order count is not request count: a tenant with many orders may still have low write concurrency, and a hot account remains a hot spot even under a distributed architecture.
— CPU alerts need separate handling: check SQL plans and indexes for scans, resolve lock contention on a single account, and measure report impact on payment separately.
— Testing must keep data, SQL, concurrency, and client connections identical; change one variable at a time and record table definitions, indexes, and statistics to attribute results.
— Fault drills must measure time from failure to app reconnection, handle in-flight payments and committed transactions, and verify backup recovery at near-target capacity.
Conclusions

The centralized-versus-distributed decision is framed as a data-organization and access-path question, making node count a secondary metric that often misleads capacity planning.

Putting tenant-key validation and hot-spot analysis before any POC turns an architectural debate into a concrete checklist, which is more reliable than relying on vendor claims about node scaling.

The insistence on testing mixed workloads and idempotent retry paths reflects a mature understanding that distributed databases shift cost from query execution to routing and cross-node coordination.

Concepts & terms
Shared-storage multi-write cluster (KES RAC)
Multiple compute nodes access the same physical data set concurrently, allowing peer writes; adding nodes scales computing power but not data capacity, and storage becomes the bottleneck.
Distribution key (分布键)
A table column, commonly tenant_id, used to route rows to specific nodes in a distributed database; requests that carry this key can be restricted to a narrow data range, while those without it must scan broadly.
Peer multi-write (对等多写)
A cluster where each node can accept write operations on the same data, requiring coordination for concurrency and availability rather than a primary-secondary split.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗