For a shared-nothing architecture in StarRocks, getting your partition and tablet (bucket) sizes right is crucial for balancing parallel execution and system overhead. Here are the general rules of thumb:
1. Tablet (Bucket) Size
Tablets are the smallest unit of data distribution and replication.
*
Recommended Size (Compressed): Aim for
100 MB to 1 GB of compressed data per tablet.
*
Recommended Size (Raw): Approximately
10 GB of raw data per tablet.
*
Maximum Limit: Avoid letting tablets exceed
10 GB (compressed). Large tablets can lead to slow compaction, difficult data recovery, and imbalanced node migration.
*
Minimum Limit: Avoid "too many small tablets" (e.g., only a few MBs). This creates excessive metadata overhead for the FrontEnd (FE) and slows down metadata synchronization.
2. Partition Size
Partitions are used for coarse-grained data pruning (usually by time).
*
General Rule: Keep each partition under
100 GB.
*
Granularity: Choose a granularity (Daily, Hourly, Monthly) that keeps your active query range within a manageable number of partitions while keeping the data volume per partition healthy.
3. Number of Tablets and Partitions
*
Tablets per BE: Ideally, keep the total number of tablets per Backend (BE) under
200,000. Exceeding this can lead to high memory usage and slow heartbeat responses.
*
Partitions per Table: Typically
100 to 1,000 partitions per table is the sweet spot. While StarRocks can handle more, exceeding
100,000 total partitions across the cluster can significantly increase the FE's memory footprint.
*
Buckets per Partition: A common range is
10 to 120 buckets per partition. This ensures there are enough tablets to utilize the CPU cores across your cluster for parallelism.
4. Best Practices for Configuration
*
Enable Parallel Scanning: Ensure
enable_tablet_internal_parallel
is set to
true
. This allows StarRocks to use multiple threads to scan a single tablet, reducing the need to over-shard your data into many tiny buckets just for parallelism.
*
Use Automatic Bucketing: Since version 2.5, you can omit the
BUCKETS
keyword or let StarRocks manage it automatically. It will determine the bucket count based on the data volume, which is highly recommended for most use cases.
*
Avoid Data Skew: When using
DISTRIBUTED BY HASH(column)
, choose a column with high cardinality (like a user ID or order ID) to ensure data is spread evenly across tablets.
Rocky's Pro-Tip: If you are just starting out, prioritize keeping your tablet sizes around 1 GB compressed. It’s much easier to scale out later than it is to fix a "small files/tablets" problem once the cluster is under heavy load!
References
•
best_practices/bucketing.md
•
table_design/data_distribution/Data_distribution.md
•
knowledge/usage/best-practice.md
•
best_practices/partitioning.md
•
best_practices/query_tuning/schema_tuning.md
•
deployment/plan_cluster.md