<@U0A71G31CDV> what is the best way to deploy shar...
# questions-and-troubleshooting
d
@Rocky what is the best way to deploy shared nothing architecture with latency and concurrency benefits with low cost
r
The best way to balance latency, concurrency, and low cost in StarRocks is often to leverage the Shared-Data (compute-storage separation) architecture with local caching, rather than a traditional Shared-Nothing setup. While Shared-Nothing provides excellent performance via local disks, it is generally higher in cost because storage and compute scale together, and you must pay for multi-replica storage on expensive local disks. 1. The "Best of Both Worlds": Shared-Data with Data Cache In StarRocks 3.x, the shared-data architecture is often the most cost-effective way to achieve shared-nothing performance. * Low Cost: All data is stored in low-cost object storage (S3, GCS, Azure Blob). You only pay for one copy of the data (plus object storage redundancy), rather than 3x replicas on local SSDs. * Latency: By enabling Data Cache, hot data is cached on the local disks of Compute Nodes (CNs). In benchmarks (e.g., SSB 1TB), StarRocks shared-data with cache enabled has been shown to outperform shared-nothing by up to 1.2x. * Concurrency: You can scale CN nodes (compute) up or down in seconds to handle concurrency spikes without the time-consuming data rebalancing required in shared-nothing. 2. If You Must Use Shared-Nothing (Optimizing for Cost) If your environment requires a Shared-Nothing (BE-based) deployment, use these strategies to keep costs down: * Storage Optimization: Use ZSTD compression to minimize disk footprint. Ensure you use Partitioning and Bucketing correctly to prune data, which reduces the CPU/IO load per query, allowing more concurrent users on smaller hardware. * Materialized Views (MV): Use asynchronous MVs to pre-aggregate data. This significantly reduces the compute resources needed for complex dashboard queries, allowing you to handle higher concurrency with fewer nodes. * Primary Key Model: For real-time updates, use the Primary Key model. It uses a "delete-and-insert" strategy that is much faster for queries than the Unique Key model (which requires a merge-on-read), leading to better latency and concurrency. 3. Performance Tuning for High Concurrency Regardless of the architecture, apply these settings to maximize concurrency on limited hardware: * Set `pipeline_dop`: For high-concurrency small queries, set
pipeline_dop = 1
. This prevents a single query from "hogging" all CPU cores, allowing more queries to run in parallel. * Row-Store Cache (v3.2.3+): If your use case involves high-concurrency point lookups (finding one row by ID), enable the Column-Row hybrid storage on Primary Key tables. This provides sub-millisecond point-lookup latency and drastically reduces CPU usage compared to pure columnar scans. * Short-query optimization: Use Prepared Statements to reduce FE (Frontend) overhead for repetitive high-frequency queries. Summary Recommendation Goal | Recommended Approach Lowest Storage Cost | Shared-Data (Object Storage) Highest Concurrency | Shared-Data (for elastic scaling) +
pipeline_dop=1
Lowest Latency | Shared-Data + Data Cache (on NVMe) OR Shared-Nothing Best Balance | StarRocks 3.x Shared-Data with local SSD Cache For most modern deployments aiming for low cost, Shared-Data is the superior choice as it provides the elasticity of the cloud without sacrificing the "ultra-fast" performance of the Shared-Nothing model. References • introduction/Architecture.md • knowledge/usage/load/shared_data_batch_ingestion.md • knowledge/usage/best-practice.md • deployment/shared_data/feature-support-shared-data.md
d
so i can achieve sub second latency like shared nothing on shared data?
@Rocky why decreasing infra capacity of FE change reduce the QPS
r
Decreasing the infrastructure capacity of the Frontend (FE) reduces QPS (Queries Per Second) because the FE is the "brain" of the StarRocks cluster. It is responsible for several CPU and memory-intensive tasks that occur before a query ever reaches the storage nodes (BEs). Here is why reducing FE capacity (either node count or hardware specs) leads to a drop in QPS: 1. Query Planning Bottleneck The FE is responsible for Parsing, Analyzing, and Optimizing every SQL query. * CPU Intensive: StarRocks uses a cost-based optimizer (CBO) to generate the most efficient execution plan. This process is CPU-bound. If you reduce the FE's CPU capacity, the time it takes to "plan" a query increases, creating a backlog. * Memory Intensive: Complex queries with many joins or large metadata requirements (thousands of partitions/tablets) require significant heap memory. Low memory leads to frequent Garbage Collection (GC) pauses, which freeze the FE and halt query processing entirely. 2. Reduced Horizontal Scalability (Entry Points) StarRocks FEs are horizontally scalable for read queries. * Followers and Observers: While there is only one Leader FE for metadata writes, all Follower and Observer FEs can handle query planning and client connections. * Load Balancing: If you reduce the number of FE nodes, you reduce the total number of parallel "planners" available. If you have 3 FEs and move to 1, you have effectively cut your query planning throughput by 66%. 3. Connection Management Limits Each FE manages its own pool of client connections (MySQL protocol). * Max Connections: There is a limit to how many concurrent connections a single FE can maintain. Reducing the number of FEs directly reduces the maximum concurrent users that can be connected to the cluster. * Thread Overhead: Each connection and active query consumes threads. Lower-spec hardware (fewer CPU cores) cannot handle high thread concurrency efficiently. 4. Metadata Synchronization & RPC Overhead The FE must communicate with all Backends (BEs) to schedule tasks. * BRPC Pool: The FE uses a BRPC connection pool (
brpc_connection_pool_size
) to send fragments of the execution plan to BEs. If the FE is underpowered, it cannot dispatch these plans fast enough to keep the BEs busy. * Tablet Reports: FEs constantly process "tablet reports" from BEs to maintain cluster health. On a capacity-constrained FE, this background task can compete with user queries for CPU cycles. 5. The "Query Queue" Effect StarRocks has internal mechanisms (like Query Queues) to prevent the system from crashing under load. If the FE detects it is running low on resources (CPU/Mem), it may proactively queue queries. Reduced capacity triggers these limits much earlier, resulting in lower observed QPS as queries wait in line for a "slot." Summary Recommendation * For High QPS: Add Observer FEs. They add planning capacity and connection limits without increasing the overhead of the Raft metadata consensus. * For Complex Metadata: Ensure FEs have at least 16GB-64GB of RAM (depending on tablet count) to avoid GC-related latency spikes. * Infrastructure Balance: A common mistake is over-provisioning BEs while under-provisioning FEs. If your BEs have low CPU usage but QPS is low, the FE is likely your bottleneck. References • administration/management/resource_management/Load_balance.md • introduction/Architecture.md • administration/management/FE_configuration.md • deployment/deploy_manually.md
d
@Rocky so we can use shared data and enable autoscaling in place of going shared nothing model? And in that can when should shared nothing be preferred
r
Yes, you can absolutely use the Shared-Data model with autoscaling as a replacement for Shared-Nothing in most modern StarRocks deployments. In fact, for 90% of use cases, Shared-Data is now the recommended path due to its lower cost and elasticity. However, there are specific technical and operational "niches" where Shared-Nothing (the traditional BE-based architecture) is still the preferred or necessary choice. When to prefer Shared-Nothing While Shared-Data with Data Cache is often faster in benchmarks, Shared-Nothing remains the best choice in these scenarios: 1. Ultra-High Concurrency Point Lookups (Hybrid Storage) If your primary use case is "point lookups" (finding a single row by its ID among billions of rows at a rate of thousands of queries per second), Shared-Nothing is superior. * Why: Shared-Nothing supports Column-Row Hybrid Storage (introduced in v3.2.3), which provides sub-millisecond point lookup performance. As of current versions, this hybrid storage model is not yet supported in Shared-Data mode. 2. Deterministic Performance (No "Cold Start" Jitter) In Shared-Data, if a Compute Node (CN) scales out or restarts, its local cache is empty. The first few queries will hit remote storage (S3/HDFS), causing a "latency spike" until the cache warms up. * Why: In Shared-Nothing, the data is permanently stored on local disks across 3 replicas. Even if one node fails, the other 2 replicas already have the data on their local SSDs. You never experience a "cold start" where data has to be fetched from a remote network. 3. Restricted Environments (No Object Storage) If you are deploying in an on-premises data center that does not have a high-performance Object Store (like MinIO or Ceph) or a fast HDFS cluster. * Why: Shared-Data relies entirely on the stability and throughput of the remote storage layer. If your network to the storage is slow or the storage itself is unreliable, a Shared-Nothing architecture using local NVMe drives will be significantly more stable. 4. Absolute Maximum Reliability/Redundancy Shared-Nothing stores 3 physical copies of the data on 3 different servers' disks. * Why: While object storage is highly durable, some regulated industries or high-security environments prefer the "physical control" of knowing exactly which disks hold their data replicas without depending on a third-party storage service. ────────── Comparison Summary Feature | Shared-Data (with Cache) | Shared-Nothing Storage Cost | Low (1x copy on S3) | High (3x copies on SSD) Scaling Speed | Seconds (No data movement) | Hours/Days (Requires rebalancing) Point Lookups | Good | Best (Supports Hybrid Row-Store) Elasticity | High (Best for variable workloads) | Low (Fixed capacity) Cache Reliability | Lost on node restart/scale | Persistent (data is always local) Recommendation * Go Shared-Data if: You want to save money, scale up/down for peak hours (e.g., business hours vs. night), and your storage is on AWS/GCP/Azure. * Go Shared-Nothing if: You have a fixed, steady workload with extremely strict SLAs for sub-millisecond point lookups, or you are running on-prem without a robust object storage layer. References • introduction/Architecture.md • deployment/shared_data/feature-support-shared-data.md • table_design/table_types/primary_key_table.md References • deployment/shared_data/feature-support-shared-data.md • table_design/table_types/primary_key_table.md
d
@Rocky but it will also add read write ops cost for GCS
r
You are correct that the Shared-Data model introduces GCS API operation costs (Class A for writes/PUTs and Class B for reads/GETs), which aren't present in the Shared-Nothing model. In some high-frequency real-time ingestion scenarios, these API costs can become significant if not managed. However, StarRocks provides several mechanisms to keep these costs lower than the expense of maintaining 3x replicas on local SSDs. 1. Reducing Read (GET) Costs: The Data Cache The most effective way to minimize GCS read operation costs is the Data Cache. * How it works: When a Compute Node (CN) fetches a block of data from GCS, it stores it on its local disk (SSD/NVMe). Subsequent queries for that same data are served entirely from the local disk. * Impact: For a warm cluster (hot data already cached), GCS GET requests drop to near zero. You only pay for the initial "cold" read. * Optimization: You can set the cache TTL (
datacache.partition_duration
) to ensure hot partitions stay local as long as needed. 2. Reducing Write (PUT) Costs: Batching & Compaction Write operations (PUT/POST) are typically more expensive than reads. StarRocks uses these strategies to minimize them: * Batch Ingestion: Instead of many tiny
INSERT
statements, use larger batch loads (via Stream Load or Pipe). Fewer loads = fewer PUT calls. * Compaction: StarRocks' FE schedules background compaction tasks that merge many small segment files into larger ones. This not only speeds up queries but also reduces the metadata overhead and the number of future GET requests. * Batch Publish (v3.3.3+): StarRocks now enables
lake_enable_batch_publish_version
by default, which batches metadata updates to the object store, significantly reducing the number of small metadata file writes. 3. When the Math Favors Shared-Data (GCS) While GCS API calls cost money, the total cost of ownership (TCO) is usually lower because: * No Multi-Replica Storage Cost: In Shared-Nothing, you must store 3 copies of data on expensive persistent disks (e.g., GCP Extreme PD). In Shared-Data, you store one copy on GCS (which is ~1/10th the cost per GB) and let GCS handle the underlying 99.999999999% durability. * Stateless Scaling: You can turn off Compute Nodes during off-peak hours. In Shared-Nothing, you must keep all nodes running just to keep the data available. Best Practices for Low Cost on GCS If you are worried about API costs, follow these tips: 1. Optimize Tablet Size: Aim for tablets between 1GB and 10GB. Larger tablets mean fewer files and fewer API calls for both metadata and data. 2. Use
Partitioned Prefix
(v3.2.4+):
This distributes data into sub-paths in the bucket, which helps avoid GCS rate limits and improves throughput. 3. Avoid "Micro-batching": If you are ingesting data every second, you will generate high PUT costs. Try to batch your ingestion to every 10–30 seconds if your latency requirements allow. 4. Monitor via `information_schema`: Use
be_cloud_native_compactions
to ensure compaction is healthy and not leaving behind thousands of small "orphaned" files. Summary: The Shared-Data architecture shifts your cost from "Static Disk/Compute" to "Variable Storage/API." For large datasets with a clear "hot/cold" divide, the savings on storage replicas far outweigh the GCS API costs. References • deployment/shared_data/gcs.md • faq/shared_data_faq.md • deployment/shared_data/feature-support-shared-data.md • administration/management/compaction.md References • faq/shared_data_faq.md
d
@Rocky concurrency of 100 and qps of 160 for cold start and 350 for cached query and 430 for cached + MV on shared data model with n2d2 CN and n2d4 FE is with sub second latency is expected or can be further improved.
r
For a cluster running on n2d-standard-2 (2 vCPU, 8GB RAM) for the Compute Node (CN), the performance you are seeing is excellent and actually exceeds typical expectations for that hardware tier. To put it in perspective, reaching ~430 QPS with 100 concurrent users on a single 2-vCPU node means each core is handling over 200 queries per second while maintaining sub-second latency. This is a testament to the efficiency of the StarRocks pipeline engine and Materialized Views (MV). However, you are currently running on "micro" specs for an OLAP database. Here is how these numbers compare to benchmarks and where you can further improve: 1. Is this "Expected"? * For the Hardware: No, this is above average. StarRocks documentation typically recommends a minimum of 16 vCPUs and 64GB RAM per CN/BE for production. Running at 100 concurrency on 2 vCPUs usually leads to high CPU queuing (Ready Queue), which pushes latency into the multi-second range. * For the Model: It shows your Data Cache and MV are working perfectly. The jump from 160 QPS (Cold) to 430 QPS (Cached + MV) indicates that you have successfully removed the I/O bottleneck from GCS. 2. Can it be further improved? Yes, significantly. Because your current hardware is so small, you are likely hitting "soft" bottlenecks that prevent you from reaching the 1,000+ QPS range. A. Scale Up the CN (The "2-vCPU" Bottleneck) The StarRocks Pipeline Engine is designed to parallelize query fragments across as many cores as possible. * Why: On a 2-vCPU node, there is almost no room for the pipeline engine to execute multiple drivers in parallel. * Improvement: Moving from
n2d-standard-2
to
n2d-standard-8
or
16
will likely result in a non-linear performance gain. You will see latencies drop from "sub-second" (e.g., 500ms) to "near-instant" (e.g., 20ms-50ms) because queries won't be waiting for a CPU time slice. B. Scale Out the FE (The "Planning" Bottleneck) With 100 concurrent users, your single n2d-standard-4 FE is likely busy parsing and optimizing SQL. * Observation: Check the
FE
CPU usage. If it's over 50%, the FE is becoming a bottleneck for QPS. * Improvement: Add 1-2 Observer FEs. In StarRocks, Observer FEs can handle query planning and client connections, allowing you to scale QPS horizontally even if the data volume stays the same. C. Memory Constraints (The "8GB RAM" Bottleneck) 8GB is very tight for a StarRocks CN. * The Risk: StarRocks uses memory for the Data Cache metadata, the Query Intermediate results, and the MemTable. On an 8GB node, you likely have a very small
storage_page_cache_limit
. * Improvement: Increasing RAM to at least 16GB or 32GB will allow you to increase the
query_mem_limit
, preventing queries from spilling to disk or failing under high concurrency. D. Software Tuning If you stay on this hardware, ensure these are set: * Enable Pipeline Engine: (Usually on by default in v3.x) Ensure
enable_pipeline_engine = true
. * Short Query Optimization: If these are simple queries, ensure
enable_short_circuit_query = true
to bypass the full planning phase for primary key lookups. * Adjust Concurrency: Tune
pipeline_dop
(Degree of Parallelism). For a 2-vCPU node, set this to
2
. If you scale up, set it to
0
(auto-adjust). Summary Recommendation Your current metrics are a great "Green Signal" that your schema and MVs are optimized. To move from "good" to "high-performance production," upgrade your CNs to at least n2d-standard-8. You will likely see your QPS double or triple while maintaining much more stable latencies during peak bursts. References • deployment/plan_cluster.md • administration/management/resource_management/Pipeline_execution_framework.md
d
@Rocky i thought 3 x FE2 + 2 x CN2 would increase the qps and lower latency but it has decreased as compared to FE4+CN2 . why?
r
Moving from a single 4-vCPU FE to three 2-vCPU FEs while adding a second CN should theoretically improve reliability and execution capacity, but in your specific case, it has created a Query Planning Bottleneck. Here is why your performance decreased despite having "more" total nodes: 1. The Leader FE is a "Vertical" Bottleneck In a StarRocks cluster, even with 3 FEs, the Leader FE performs the bulk of the work: * Planning is Single-Node: A single query's execution plan is generated by one FE. It cannot be "split" across multiple FEs. * Resource Contention: By dropping from 4 vCPUs to 2 vCPUs, you have halved the processing power available to plan any individual query. * CPU Queuing: At 100 concurrency, your Leader FE is now trying to parse, analyze, and optimize 100 SQL statements simultaneously with only 2 cores. This leads to massive CPU context switching and "Ready Queue" delays, where queries sit waiting just to be planned before they ever reach the CNs. 2. High-Availability (Raft) Overhead In a 3-FE setup, StarRocks uses the Raft protocol (via BDB JE) to synchronize metadata. * Synchronization Cost: The FEs must now spend CPU cycles communicating with each other to keep metadata in sync and maintain heartbeats. * Impact on Small Nodes: On an 8-vCPU node, this overhead is negligible. On a 2-vCPU node, the background Raft threads can consume 20–30% of your total CPU, leaving even less power for query planning compared to your previous single 4-vCPU setup which had zero sync overhead. 3. Java GC Pressure FEs run on the JVM. With only 8GB of RAM (typical for an n2d2), the memory available for the "Heap" is very small. * 3-node Metadata: Each FE must keep a full copy of the metadata in memory. * Concurrent Planning: 100 concurrent query objects in the JVM heap can trigger frequent Garbage Collection (GC). On 2 vCPUs, GC takes longer and happens more often, "freezing" the FE and spiking your query latency. 4. Distributed Coordination Cost With 2 CNs instead of 1, the FE now has to: * Manage more RPC connections. * Coordinate fragment scheduling across two different physical endpoints. * Aggregate results from two nodes instead of one. While this is what StarRocks is built for, doing this coordination on a 2-vCPU machine is significantly slower than on a 4-vCPU machine. Summary of the "Regress" Setup | FE Planning Power | Coordination Overhead | Result FE4 + CN2 | 4 vCPUs (Strong) | Zero (Single FE) | Fast planning, feeds CN well. 3 x FE2 + 2 x CN2 | 2 vCPUs (Weak) | High (Raft sync + 2 CNs) | Planning Bottleneck. Recommendation to Fix For StarRocks, Vertical scaling is better than horizontal scaling for FEs until you reach very high QPS (thousands). 1. Revert to FE4: If you need High Availability, use 3 x FE4 (or ideally FE8). 2 vCPUs is below the recommended minimum for a production StarRocks FE. 2. Check FE CPU: Run
top
on the Leader FE during your load test. If CPU usage is near 180-200%, the FE is definitely your bottleneck. 3. Check Planning Latency: Run
SHOW PROFILE FOR <query_id>
for one of your slow queries. Look at the
QueryPlan
time. If it has increased significantly compared to your old setup, the FE is the culprit. References • deployment/plan_cluster.md • administration/management/FE_configuration.md • introduction/Architecture.md • faq/Others.md References • deployment/plan_cluster.md • introduction/Architecture.md • administration/management/FE_configuration.md
d
StarRocks documentation typically recommends a minimum of 16 vCPUs and 64GB RAM per CN/BE for production.
@Rocky but if i don't need qps and concurrency in even thousand. then I can keep it low?
r
Yes, you can keep the hardware specs low if your QPS and concurrency requirements are modest. However, when you run StarRocks on "micro" specs (like 2-vCPU and 8GB RAM), the system becomes fragile. StarRocks is designed as a high-performance engine that expects to "own" the hardware. On 2-vCPU nodes, the background tasks (compaction, heartbeats, metadata sync) compete heavily with your queries. If you decide to stick with low specs, you must tune the system to "think small." Here is how to make a low-spec cluster stable: 1. Protect against OOM (Out of Memory) On an 8GB node, the OS and StarRocks' own overhead leave very little room for query execution. * Limit Query Memory: By default, StarRocks might try to use too much RAM for a single complex query. Set a session or global limit:
Copy code
sql
    SET GLOBAL query_mem_limit = 2147483648; -- Limit each query to 2GB per node
* Reduce Load Memory: If you are ingesting data, reduce the memory buffer to prevent the CN from crashing during a load:
Copy code
conf
    # In cn.conf
    load_process_max_memory_limit_percent = 20
2. Throttling Background "Noise" On a 2-vCPU machine, the default background thread counts are often too high, causing CPU thrashing. * Reduce Compaction Threads: Compaction (merging files) is CPU-intensive. Limit it so it doesn't starve your queries:
Copy code
sql
    -- Run via MySQL client
    UPDATE information_schema.be_configs SET value = "1" WHERE name = "compact_threads";
* Pipeline Degree of Parallelism (DOP): On a 2-vCPU node, the engine might try to run 2 or 4 parallel tasks per query. Force it to be conservative:
Copy code
sql
    SET GLOBAL pipeline_dop = 2;
3. Why it feels "Slower" even at Low QPS Even if you only send 1 query per second, a low-spec node may have higher tail latency (P99) because: * Context Switching: With only 2 cores, the CPU spends significant time switching between the FE's Java Garbage Collection, the CN's storage engine, and your SQL execution. * FE Planning: As you saw, a 2-vCPU FE is significantly slower at generating a query plan than a 4-vCPU FE. No amount of "low QPS" changes the fact that each plan takes longer to compute on a weak core. The "Stable Minimum" Recommendation If you don't need 1000+ QPS but want a stable production environment that won't crash during a routine background merge: * CN/BE: 4 vCPU / 16GB RAM. This provides enough "breathing room" for the OS, the data cache, and background compaction to run alongside your queries. * FE: 4 vCPU / 16GB RAM. This ensures the Java Heap is large enough to handle metadata and planning without constant GC pauses. Summary: You can go lower than the official "16-core/64GB" recommendation, but dropping to 2-vCPU puts you in the "experimental/dev" zone where stability is hard to guarantee. If you stay at 2-vCPU, ensure you apply the throttling mentioned above to prevent the node from over-extending itself. References • deployment/plan_cluster.md • administration/management/resource_management/Memory_management.md • faq/Others.md • administration/management/BE_configuration.md • knowledge/admin_and_operation/shared_data_compaction.md References • administration/management/resource_management/Memory_management.md • loading/loading_introduction/loading_considerations.md
d
@Rocky I am able to get qps of 380 at concurrency of 200 with 3 x n2d4 fe and 2 x n2d4 CN. but my qps requirement is 72 and concurrency is 100. how can i save my costs. my arch is shared data.
r
Since your actual requirements (72 QPS and 100 concurrency) are significantly lower than what your current cluster (380 QPS) can handle, you are over-provisioned. In a Shared Data architecture, you have high flexibility to reduce costs because the Compute Nodes (CN) are stateless. Here is how you can optimize your costs while maintaining the performance you need: 1. Scale Down to 1 CN (The "Compute" Cost) Your earlier tests showed that a single n2d-standard-2 (2 vCPU) CN could handle 160 QPS at 100 concurrency. * Action: Reduce your CN count from 2 nodes to 1 node. * Machine Type: Since 72 QPS is well within the limits of a 2-vCPU node, you can use an n2d-standard-2 or n2d-standard-4. * Why: In shared data, scaling CNs is "instant" and doesn't require data rebalancing. If your traffic spikes, you can add the second CN back in seconds. 2. Optimize the FE Strategy (The "Planning" Cost) You previously discovered that 1 x FE4 performed better than 3 x FE2 because of the planning bottleneck on small cores. * Cost-Saving Option (No HA): If this is a non-critical or dev environment, run a single n2d-standard-4 FE. This is the cheapest way to maintain low planning latency for 100 concurrent users. * Production Option (High Availability): If you must have HA, you need 3 FEs. Since you only need 72 QPS, you could try 3 x n2d-standard-2 FEs again but enable Query Cache (see below) to reduce the planning load on the FE. However, if the latency was already unacceptable with FE2s, sticking with 3 x n2d-standard-4 is the price of stability. 3. Use Preemptible/Spot Instances for CNs Since you are on GCP (n2d series) and using Shared Data: * Action: Run your CN nodes on Spot VMs. * Benefit: Spot instances are 60-91% cheaper. Because CNs in StarRocks Shared Data are stateless and data is safe in GCS, if a Spot VM is reclaimed, the FE will simply route queries to other CNs (or you can have a script to spin up a new one). This is the single biggest cost-saver for Shared Data. 4. Enable "Query Cache" to reduce FE/CN Load To make your 72 QPS even "lighter" on the hardware: * Action: Enable the global query cache:
Copy code
sql
    SET GLOBAL enable_query_cache = true;
* Benefit: This caches the final result set. If many of your 100 concurrent users are running similar queries (e.g., a dashboard), the FE will return the result without even hitting the CN. This reduces the CPU pressure on both the FE and CN significantly. 5. Review "Idle" Costs * Storage: Since you are on Shared Data, your storage cost is already minimized by using GCS instead of expensive local SSDs. * Shutdown: If your workload is only active during business hours, you can shut down all CNs at night. The metadata remains safe on the FEs. Summary Comparison Component | Current Setup (High Cost) | Recommended Setup (Low Cost) | Savings FE | 3 x n2d-standard-4 | 1 x n2d-standard-4 (or 3x Spot n2d4) | ~66% CN | 2 x n2d-standard-4 | 1 x n2d-standard-2 (Spot VM) | ~80%+ Total | ~20 vCPUs | 6 vCPUs | ~70% reduction Recommendation: Start by dropping to 1 x n2d4 FE and 1 x n2d2 CN (Spot). Monitor the latency for your 72 QPS. If it remains sub-second, you have found your "goldilocks" cost-performance zone. References • deployment/shared_data/feature-support-shared-data.md • introduction/Architecture.md • administration/query_cache.md • deployment/plan_cluster.md
To achieve a requirement of 72 QPS and 100 concurrency while minimizing costs on a Shared Data architecture, you can significantly downsize your cluster. Your current setup (3x FE4 + 2x CN4) is providing ~5x the performance you actually need. Here are the three best ways to save costs: 1. Consolidate to a "1+1" Configuration (Highest Savings) Since you are using Shared Data, compute and storage are decoupled. You do not need multiple CNs to store data. * Recommended Nodes: 1 x n2d-standard-4 (FE) + 1 x n2d-standard-4 (CN). * Why this works: * A single
n2d-standard-4
CN should easily handle 72 QPS given that your previous tests showed a single
n2d-standard-2
could handle ~160 QPS (cold). * By having 4 vCPUs on the single FE, you avoid the planning bottleneck and Raft synchronization overhead you experienced with the 3x FE2 setup. * Savings: This reduces your node count from 5 to 2 (~60% cost reduction). 2. Use Spot (Preemptible) Instances for CNs In the Shared Data architecture, CN nodes are stateless. If a CN node disappears, no data is lost because everything is in GCS. * Strategy: Keep your FE on a Standard VM (to protect metadata), but run your CN on a Spot/Preemptible VM. * Savings: GCP Spot instances are typically 60-91% cheaper than standard instances. If the CN is preempted, StarRocks will simply wait for a new one to join, and it will reload the cache from GCS. 3. Vertical over Horizontal for FEs If you must have High Availability (HA), you need 3 FEs. However, as you discovered, three weak FEs (2 vCPU) are slower than one strong FE (4 vCPU) due to the overhead of the Leader-Follower metadata synchronization (Raft). * If HA is mandatory: Use 3 x n2d-standard-2 but only for the 72 QPS workload. It failed at 380 QPS, but it will likely handle 72 QPS just fine. * If HA is not mandatory: Stick to 1 x n2d-standard-4. It is cheaper and more performant than three small nodes. Summary Comparison Table Setup | QPS Capacity (Est.) | HA? | Cost Level | Recommendation 3x FE4 + 2x CN4 | 380+ | Yes | $$$$$ | Overkill 3x FE2 + 1x CN4 | ~100-150 | Yes | $$$ | Use if you need HA 1x FE4 + 1x CN4 | ~180-200 | No | $$ | Best for 72 QPS 1x FE4 + 1x CN4 (Spot) | ~180-200 | No | $ | Cheapest Option Critical Configuration Tuning When moving to fewer nodes with 100 concurrent users, apply these settings to prevent memory errors: 1. Protect Memory: Since you have 100 users hitting one CN, limit the memory each query can take so they don't crash the node:
Copy code
sql
    SET GLOBAL query_mem_limit = 2147483648; -- 2GB per query
2. Enable Result Cache: If your 72 QPS includes repetitive queries, the FE Result Cache can serve those without even hitting the CN:
Copy code
sql
    SET GLOBAL enable_query_cache = true;
References • deployment/plan_cluster.md • introduction/Architecture.md • deployment/shared_data/feature-support-shared-data.md • administration/management/resource_management/Memory_management.md • administration/query_cache.md References • introduction/Architecture.md • deployment/shared_data/feature-support-shared-data.md • quick_start/shared-data.md
d
@Rocky if if we use - github.com/StarRocks/starrocks-kubernetes-operator can the Starrocks cost be minimized
r
Yes, using the StarRocks Kubernetes Operator is one of the most effective ways to minimize costs, especially for a Shared Data architecture. In a Kubernetes environment, you can move away from a "fixed" cluster size to a "fluid" one that only pays for what it uses. Here is how the Operator specifically helps you save costs: 1. Automatic Scaling for CNs (HPA) The Operator allows you to define an
autoScalingPolicy
. Because you are using Shared Data, the Compute Nodes (CNs) are stateless—they don't store the primary data, they just pull it from your Object Storage (S3/GCS). * Scale down to 1: You can set
minReplicas: 1
. During low-traffic periods, the Operator will automatically terminate all but one CN node. * Scale up on demand: When your traffic spikes towards that 72 QPS, Kubernetes will instantly spin up additional CN pods to handle the load. * Cost Impact: Instead of paying for 2 x CN nodes 24/7, you pay for 1 CN most of the time, and only scale to 2+ when necessary. 2. Utilizing Spot Instances for CNs Since CN nodes in Shared Data mode are disposable (if one dies, the data is safe in S3/GCS), they are perfect candidates for Spot/Preemptible Instances. * How to do it: In your
StarRocksCluster
YAML, you can add
nodeSelector
or
tolerations
to ensure CN pods only run on Spot nodes. * Cost Impact: Spot instances are typically 60-90% cheaper than standard VMs. Even if a node is reclaimed by the cloud provider, the Operator will simply start a new one, and the cluster will keep running. 3. "Scale-to-Zero" (Advanced) While the standard StarRocks Operator HPA defaults to a minimum of 1 node, you can use KEDA (Kubernetes Event-driven Autoscaling) alongside the Operator. * KEDA can monitor your actual query traffic or a Prometheus metric and scale the CN deployment to 0 replicas if there have been no queries for a certain period. * Cost Impact: You pay $0 for compute when no one is using the database. 4. Precise Resource Packing In your current VM setup, if you have an
n2d-standard-4
(4 vCPU), you pay for all 4 cores even if StarRocks is only using 0.5 cores. * With the Operator, you can set
requests
and
limits
at a granular level (e.g.,
cpu: 2.5
). * Kubernetes can then "bin-pack" other small services onto the same physical hardware, ensuring you aren't paying for "dead air" in your VMs. Recommended "Cost-Minimizer" YAML Snippet If you move to the Operator, use a configuration similar to this for your CNs:
Copy code
yaml
starRocksCnSpec:
  replicas: 1 # Starts with 1
  requests:
    cpu: 2
    memory: 8Gi
  autoScalingPolicy:
    minReplicas: 1
    maxReplicas: 3
    hpaPolicy:
      metrics:
        - type: Resource
          resource:
            name: cpu
            target:
              averageUtilization: 70
              type: Utilization
  nodeSelector:
    <http://cloud.google.com/gke-spot|cloud.google.com/gke-spot>: "true" # Forces CNs onto cheap Spot nodes
Summary for your 72 QPS Goal: By using the Operator on Kubernetes, you can keep 1 On-Demand FE for stability and 1 Spot CN that autoscales. This will likely be the cheapest possible way to run StarRocks while still meeting your performance targets. References • deployment/sr_operator.md • deployment/helm.md • administration/management/resource_management/Resource_group.md • administration/management/resource_management/Memory_management.md References • deployment/sr_operator.md • deployment/helm.md
d
@Rocky I am able to get qps of 380 at concurrency of 200 with 3 x n2d4 fe and 2 x n2d4 CN. but the additional disk is gcp Balanced persistent disk . Starrocks suggests to use SSD. can you predict What performance benefit will i get
r
In your Shared Data architecture, the disk on the Compute Node (CN) is used as a Data Cache (Block Cache). It serves as the bridge between your high-speed RAM and your high-latency GCS storage. Switching from GCP Balanced Persistent Disk to SSD (pd-ssd) or Local SSD will yield the following performance benefits: 1. Significant Reduction in Tail Latency (P99) While "Balanced" disks are SSD-backed, they have higher latency and lower IOPS caps than
pd-ssd
. * Predictable Performance: At 200 concurrency, StarRocks performs thousands of small, random reads from the Block Cache. Standard SSDs have significantly lower access latency (sub-millisecond) compared to Balanced disks. * Benefit: Your P99 response times will drop and become more stable. You will see fewer "outlier" queries that take 2–3x longer than the average. 2. Faster "Warm-up" and Loading In Shared Data mode, if data isn't in the cache, StarRocks must fetch it from GCS, decompress it, and write it to the local disk cache. * Faster Cache Population: A faster SSD allows the CN to write incoming data from GCS to the cache much faster. * Ingestion Speed: During heavy data loads, StarRocks spills intermediate data to the local disk before committing to GCS. A faster SSD prevents the local disk from becoming a bottleneck during these "spills," increasing overall ingestion throughput. 3. Higher Concurrent Scanning Throughput Your test showed 380 QPS at 200 concurrency. At this level of pressure, the "IO Wait" on Balanced disks often starts to climb. * IOPS Ceiling: Balanced disks scale IOPS based on size (usually 6 IOPS per GB). If you have a small disk (e.g., 100GB), you are capped at 600–1,200 IOPS. * SSD Advantage:
pd-ssd
or
Local SSD
provides much higher IOPS per GB. This allows more concurrent "scan" threads to read different data blocks simultaneously without waiting for the disk head (virtually) to keep up. Comparison Table: Predicted Gains Feature | Balanced PD | SSD (pd-ssd) | Local SSD (NVMe) Random Read Latency | Moderate (~1-2ms) | Low (<1ms) | Ultra-Low (μs) Max IOPS (per node) | Up to 60k | Up to 100k | Up to 800k+ QPS Impact | Baseline | +15% to 25% | +30% to 50% Tail Latency (P99) | Higher jitter | Very stable | Rock solid Is it worth it for 72 QPS? Given your new requirement is only 72 QPS (down from your 380 QPS test): * Balanced PD is actually "Enough": For 72 QPS, your disk is unlikely to be the primary bottleneck. You could save money by staying on Balanced disks. * SSD is "Insurance": If your 72 QPS involves large scans (scanning millions of rows per query) or if you want to ensure users never experience a "slow" query due to disk contention, move to
pd-ssd
. * The Best Performance Choice: If your VM type supports it, use Local SSD. In Shared Data mode, CNs are stateless, so if a node dies, losing the Local SSD cache doesn't matter (the data is safe in GCS). Local SSD provides the absolute best performance for StarRocks at a lower cost than
pd-ssd
. Recommendation: For 72 QPS, stick with Balanced PD to save costs. If you notice your "IO Wait" (check
top
or StarRocks metrics) is high during peaks, upgrade to Local SSD for the best price-to-performance ratio. References • deployment/shared_data/feature-support-shared-data.md • introduction/Architecture.md • faq/Others.md • knowledge/usage/load/shared_data_batch_ingestion.md • administration/management/BE_configuration.md