<@U0A71G31CDV> can you tell me how fe pod work in ...
# questions-and-troubleshooting
r
@Rocky can you tell me how fe pod work in starrocks cluster if there are multi pod for example replicaset over 2
r
In a StarRocks cluster on Kubernetes, when you set the FE replica count to more than 2 (typically 3 for high availability), the FE pods work together using a consensus-based architecture. Here is how the FE pods operate when there are multiple replicas: 1. Role Distribution (Leader vs. Follower) StarRocks FE nodes use a Leader-Follower-Observer architecture. In a setup with `replicas: 3`: * Leader (1 Pod): One FE pod is elected as the Leader. It is responsible for all metadata writes (e.g.,
CREATE 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. Referencesquick_start/helm.mddeployment/sr_operator.mdadministration/Meta_recovery.mdfaq/Deploy_faq.md
r
@Rocky hey rockey , can you recomend cn spill and cache storace size on k8s cluster? how can i choos size of that?
r
For Compute Nodes (CN) in a StarRocks Kubernetes cluster, sizing the Data Cache and Spill Storage is critical for both performance (avoiding remote object storage latency) and stability (avoiding OOM crashes). Here are Rocky's recommendations for sizing these two storage types: 1. Data Cache (Block Cache) Sizing The Data Cache is used in Shared-Data (Data Lake) mode to store data locally on the CN pods so that subsequent queries don't need to fetch it from S3/HDFS. * Recommended Size: * Rule of Thumb: Aim to cache your "Hot Data" working set. This is typically 20% to 50% of your total active dataset size. * Minimum: At least 100 GB per CN node to be effective for metadata and small table lookups. * Typical Production: 500 GB to 2 TB per CN node, depending on your disk budget and dataset size. * How to choose: Look at your most frequently queried data volume over a 24-hour window. If you query 5TB of unique data daily, and you have 5 CNs, allocating 1TB per CN ensures most queries hit the cache. * Configuration: Set via
storage_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:
Copy code
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!** Referencesadministration/management/resource_management/spill_to_disk.mdsql-reference/System_variable.mdadministration/management/BE_configuration.md
r
@Rocky can you tell me what minimum size of fe, cn pod initialize on k8s? just pod running ok