<@U0A71G31CDV> I’m looking for best practices aro...
# questions-and-troubleshooting
a
@Rocky I’m looking for best practices around the number of FE nodes in a StarRocks cluster. Currently, we operate a FE node group with 3 nodes. Would increasing it to 5 nodes cause any issues? Also, are there real-world cases where people operate with 5 FE nodes? From the best practice documents I’ve seen, it seems that 3 FE nodes are generally recommended. However, the reason I’m considering expanding from 3 to 5 is that if 2 FE nodes go down simultaneously in a 3-node setup, quorum is lost and the cluster can become unavailable. With 5 FE nodes, availability can still be maintained even if up to 2 nodes are shut down or fail at the same time. Could you recommend best practices for determining the appropriate number of FE nodes?
r
Increasing the number of FE nodes from 3 to 5 is technically supported, but it is rarely done in practice because 3 nodes are generally sufficient for most high-availability (HA) requirements. Here is a breakdown of the trade-offs and best practices to help you decide. 1. Quorum and Fault Tolerance StarRocks uses a protocol (based on BDB JE) that requires a majority quorum of Follower FE nodes to be alive for the cluster to remain available. * 3 Follower nodes: Quorum is 2. It can tolerate 1 node failure. * 5 Follower nodes: Quorum is 3. It can tolerate 2 node failures simultaneously. Your reasoning is correct: moving to 5 nodes increases the cluster's resilience to simultaneous hardware or network failures. 2. Potential Issues with 5 FE Nodes While 5 nodes provide higher fault tolerance, they introduce a few downsides: * Increased Metadata Write Latency: Every metadata change (e.g., DDL statements like
CREATE TABLE
,
ALTER TABLE
, or even the internal commits for data loading) must be acknowledged by a majority of the Follower nodes. With 5 nodes, the Leader must wait for more network acknowledgments, which can slightly increase the latency of these operations. * Inter-node Communication: The synchronization of the edit log across more nodes increases the internal network traffic among FEs, though this is usually negligible unless your cluster has a very high frequency of schema changes or small-batch loads. * Complexity: Managing more stateful nodes increases the maintenance overhead. 3. Best Practices for FE Node Count For most production environments, the recommended path is: * Standard HA (3 Followers): Deploy 3 Follower nodes. This is the "sweet spot" for metadata reliability and performance. * High Read Concurrency (Observers): If your goal is to handle thousands of concurrent query requests rather than improving fault tolerance, do not add more Followers. Instead, add Observer FE nodes. * Followers: Participate in voting and the write quorum. * Observers: Synchronize logs asynchronously and only handle read requests. They do not increase the write quorum, so they don't slow down the leader. * The "Odd Number" Rule: Always maintain an odd number of Follower nodes (1, 3, or 5) to avoid split-brain scenarios and maximize the fault tolerance for the number of nodes used. 4. Real-World Usage * 3 nodes: Used by >90% of StarRocks users. It protects against a single rack or node failure, which is the most common failure mode. * 5 nodes: Typically only used in extreme scenarios, such as multi-region deployments or very large clusters where the cost of a full cluster restart (due to losing quorum) is exceptionally high and the infrastructure allows for two independent failures. Summary Recommendation * Stick with 3 nodes if your primary concern is standard high availability. Double-node failures are rare enough that the performance and simplicity of 3 nodes usually outweigh the benefits of 5. * Upgrade to 5 nodes only if your business requirements strictly mandate survival during a 2-node simultaneous outage (e.g., a "two-rack failure" scenario). * Use Observers if you are seeing high CPU usage on your 3 FE nodes due to query traffic. Referencesdeployment/deploy_manually.mdfaq/Deploy_faq.mddeployment/plan_cluster.md
This error and the associated FE CPU spike are characteristic of a version discontinuity issue, typically seen in StarRocks Shared-data (存算分离) clusters when the batch publish feature is enabled. 1. What the Error Means The error
partition.getVisibleVersion() + 1 != version.get(0)
indicates a gap or overlap in the metadata versioning for a specific partition. * Visible Version + 1: This is the version the FE expects to commit next. * version.get(0): This is the version of the data batch currently being published. * In your case (
75807 75807
)
: The FE expects the next version to be 75808 (75807 + 1), but the batch it is trying to publish claims to be version 75807. Since 75807 has likely already been committed or is out of order, the FE rejects it to prevent metadata corruption. 2. Why the FE CPU is Spiking The CPU spike is usually caused by: * Log Flooding: The
PublishVersionDaemon
runs in a tight loop. When a publish task fails, it retries frequently, generating a massive volume of "ERROR" logs. Writing these logs to disk and managing the internal retry queue consumes significant CPU. * Metadata Contention: When
lake_enable_batch_publish_version
is on, the FE Leader has to group multiple transaction logs and coordinate their commit. If there is a race condition (often caused by concurrent Schema Changes or high-frequency small-batch imports), the FE spends excessive cycles trying to resolve the versioning conflicts. 3. Immediate Recommended Actions This is a known issue in some versions (notably 3.3.x and early 3.4.x) when using the batch publish optimization. 1. Disable Batch Publishing: Since you mentioned "turning it back on" triggered the spike, the most immediate fix is to revert that setting to stop the loop:
Copy code
sql
    ADMIN SET FRONTEND CONFIG ("lake_enable_batch_publish_version" = "false");
Note: This might cause a temporary increase in the number of versions if you have high-frequency writes, but it will stop the error loop. 2. Check for Stuck Transactions: Look for transactions that are stuck in the "PREPARED" or "COMMITTED" state but haven't been "VISIBLE":
Copy code
sql
    SHOW PROC '/transactions';
If you see very old transactions for the DB/Table ID mentioned in your logs (
32988495
), they may be blocking the version sequence. 3. Check for Schema Changes: This error is frequently triggered if a
SCHEMA CHANGE
(ALTER TABLE) was running while batching was enabled. Check if any jobs are stuck:
Copy code
sql
    SHOW ALTER TABLE COLUMN;
4. Long-term Fix This behavior was identified as a bug in the shared-data version management logic (specifically regarding how the FE handles the transition between individual and batch publishing). * Upgrade: Ensure you are on the latest patch release of your major version (e.g., 3.3.7+, 3.4.1+), as several fixes for
PublishVersionDaemon
race conditions were introduced in late 2024 and 2025. * Consolidate Loads: If your FE is struggling with versions, consider increasing the amount of data per load (batching at the source) rather than relying on the FE-side
lake_enable_batch_publish_version
to group thousands of tiny transactions. If the CPU remains high after disabling the config, you may need to restart the FE Leader to clear the pending task queue.