RonJay
04/20/2026, 3:16 AMRocky
04/20/2026, 3:16 AMCREATE TABLE, ALTER TABLE) and cluster management. It coordinates the BE (Backend) nodes.
* Followers (2 Pods): The other two pods act as Followers. They synchronize metadata from the Leader in real-time. They participate in Leader Election and provide high availability.
* Quorum Mechanism: With 3 replicas, StarRocks requires a majority (2 out of 3) to be alive to elect a Leader and perform metadata writes. This ensures no data is lost even if one FE pod goes down.
2. Consensus Protocol (BDBJE)
StarRocks uses Berkeley DB Java Edition (BDBJE) for metadata replication.
* All metadata changes are written to an "Edit Log" on the Leader.
* These logs are sent to the Followers.
* A change is only considered "committed" when a majority of the Follower/Leader group acknowledges the write.
3. Kubernetes Deployment Mechanism
When using the StarRocks Operator or Helm chart:
* StatefulSet: FE pods are deployed as a StatefulSet (e.g., starrocks-fe-0, starrocks-fe-1, starrocks-fe-2). This provides each pod with a stable network identity (DNS name) and persistent storage for metadata.
* Headless Service: A Headless Service (usually named fe-search or similar) is created. This allows pods to find each other using DNS like starrocks-fe-0.fe-search.svc.cluster.local. BDBJE uses these stable DNS names to form the cluster.
* Service Discovery: The main FE Service (ClusterIP or LoadBalancer) will point to all FE pods. When a MySQL client connects, it can hit any of the 3 FE pods.
4. How Scaling Works (Replica > 2)
When you increase the replicas from 1 to 3:
1. Bootstrapping: The first pod (fe-0) starts as the initial Leader.
2. Joining: The StarRocks Operator automatically executes the ALTER SYSTEM ADD FOLLOWER "host:port" command inside the cluster to register the new pods.
3. Synchronization: New pods (fe-1, fe-2) start with a --helper flag pointing to fe-0. They pull a metadata image from the Leader and then start replaying the Edit Log to catch up.
5. Request Handling
* Write Requests: If you send a DDL (like CREATE TABLE) to a Follower FE, it will automatically proxy the request to the Leader FE.
* Read/Query Requests: Queries can be handled by any FE pod (Leader or Follower). This allows you to scale your query planning capacity by adding more FE replicas.
Summary of Benefits for Multi-Pod FE
Feature | Behavior with 3+ Replicas
High Availability | Can survive the failure of $N/2$ nodes (1 node in a 3-node cluster).
Persistence | Metadata is replicated across 3 different Persistent Volumes (PVs).
Read Scaling | Query parsing and planning are distributed across all FE pods.
Auto-Recovery | If the Leader pod fails, a Follower is promoted to Leader automatically in seconds.
Rocky's Tip: For a production environment, always use at least 3 FE replicas. Using only 2 is not recommended because if one fails, the remaining node cannot form a majority (quorum), and the cluster will become read-only or metadata-write-locked.
References
• quick_start/helm.md
• deployment/sr_operator.md
• administration/Meta_recovery.md
• faq/Deploy_faq.mdRonJay
04/20/2026, 6:08 AMRocky
04/20/2026, 6:09 AMstorage_root_path in cn.conf. StarRocks will use approximately 80-90% of this disk space for cache by default.
2. Spill Storage Sizing
Spill storage is used when a query's intermediate results (like large Joins or Aggregations) exceed the available RAM. Instead of failing with an "Out of Memory" (OOM) error, StarRocks "spills" that data to disk.
* Recommended Size:
* Formula: 1x to 2x the RAM allocated to the CN pod.
* Example: If your CN pod has 64GB RAM, provide a 64GB to 128GB spill disk.
* How to choose: This depends on the complexity of your queries. If you frequently perform massive "Shuffle Joins" on billions of rows that don't fit in memory, you should lean toward 2x RAM.
* Configuration: Set via spill_local_storage_dir in cn.conf.
_ _Tip:* In v3.3+, you can also enable enable_spill_to_remote_storage to use S3 as a "safety net" if local spill disks fill up.
3. Storage Type & Kubernetes Best Practices
The type of storage is often more important than the size:
* Disk Type: Always use SSD/NVMe. Using HDD for cache or spill will significantly degrade performance (often 10x slower).
* K8s Implementation:
* Use Local Persistent Volumes (Local PVs) or high-performance cloud disks (e.g., AWS gp3 or io2, Azure Premium_LRS).
* Separate Disks: If possible, put Cache and Spill on different physical disks (or separate PVCs) to prevent I/O contention.
* StarRocks Operator Example:
In your StarRocksCluster YAML, you can define these storage volumes:
yaml
starRocksCnSpec:
storageSpec:
• name: cn-cache
storageSize: 500Gi
mountPath: /opt/starrocks/cn/storage
storageClassName: local-path # Example for local NVMe
• name: cn-spill
storageSize: 128Gi
mountPath: /opt/starrocks/cn/spill
storageClassName: gp3
Summary Table
Storage Type | Purpose | Recommended Size | Storage Medium
Data Cache | Speed up Data Lake queries | 20-50% of "hot" data | NVMe SSD (Local PV preferred)
Spill Storage | Prevent OOM for big queries | 1x to 2x Pod RAM | SSD (Local or Cloud)
Rocky's Tip: Monitor the fslib_star_cache_hit_ratio metric. If your hit ratio is consistently low (e.g., < 50%), you likely need to increase your Data Cache size!**
References
• administration/management/resource_management/spill_to_disk.md
• sql-reference/System_variable.md
• administration/management/BE_configuration.mdRonJay
04/20/2026, 9:06 AM