Skip to content

AxonOps — AI-Native Control Plane for Open Source Data Platforms

nodetool setconcurrentviewbuilders

Sets the number of concurrent threads used for building materialized views.


Terminal window
nodetool [connection_options] setconcurrentviewbuilders <value>

See connection options for connection options.

nodetool setconcurrentviewbuilders controls how many threads are dedicated to building materialized views. When a materialized view is created or needs to be rebuilt, Cassandra populates it by reading data from the base table and writing corresponding entries to the view. This setting determines how many of these build operations can run in parallel.

Materialized views are automatically maintained copies of base table data, organized by a different primary key to support different query patterns. When data is written to the base table, Cassandra automatically updates all associated materialized views.

-- Base table
CREATE TABLE users (
user_id uuid PRIMARY KEY,
email text,
country text,
created_at timestamp
);
-- Materialized view to query users by email
CREATE MATERIALIZED VIEW users_by_email AS
SELECT * FROM users
WHERE email IS NOT NULL AND user_id IS NOT NULL
PRIMARY KEY (email, user_id);
-- Materialized view to query users by country
CREATE MATERIALIZED VIEW users_by_country AS
SELECT * FROM users
WHERE country IS NOT NULL AND user_id IS NOT NULL
PRIMARY KEY (country, user_id);

View building happens in these scenarios:

ScenarioDescription
New view creationWhen CREATE MATERIALIZED VIEW is executed, existing base table data must be copied to the view
Node bootstrapWhen a new node joins, it builds local view data from streamed base table data
View rebuildAfter corruption or manual truncation of view data
RepairView data may be rebuilt during certain repair operations

Each view builder thread:

  1. Reads partitions from the base table
  2. Transforms the data according to the view definition
  3. Writes entries to the materialized view
  4. Tracks progress for resumption if interrupted

Non-Persistent Setting

This setting is applied at runtime only and does not persist across node restarts. After a restart, the value reverts to the concurrent_materialized_view_builders setting in cassandra.yaml (default: 1).

To make the change permanent, update cassandra.yaml:

concurrent_materialized_view_builders: 2

ArgumentDescription
valueNumber of concurrent view builder threads (default: 1)

Terminal window
nodetool getconcurrentviewbuilders
Terminal window
nodetool setconcurrentviewbuilders 2
Terminal window
nodetool setconcurrentviewbuilders 4

Scenario 1: Creating a New Materialized View on Large Table

Section titled “Scenario 1: Creating a New Materialized View on Large Table”

Situation: Creating a view on a table with billions of rows—initial build will take a long time.

Diagnosis:

Terminal window
# Check current view build status
nodetool viewbuildstatus
# Check current setting
nodetool getconcurrentviewbuilders

Action: Increase builders to speed up initial population:

Terminal window
# Increase during view creation
nodetool setconcurrentviewbuilders 4
# Monitor progress
watch -n 30 'nodetool viewbuildstatus'
# After completion, restore default to conserve resources
nodetool setconcurrentviewbuilders 1

Scenario 2: Multiple Views Being Built Simultaneously

Section titled “Scenario 2: Multiple Views Being Built Simultaneously”

Situation: Several materialized views are being created or rebuilt at the same time.

Diagnosis:

Terminal window
# Check how many views are building
nodetool viewbuildstatus

Example output:

Keyspace View Status
myks users_by_email BUILDING (45%)
myks users_by_country BUILDING (23%)
myks users_by_created STARTED

Action: With multiple views building, more threads can help:

Terminal window
nodetool setconcurrentviewbuilders 4

Scenario 3: View Build Impacting Production Traffic

Section titled “Scenario 3: View Build Impacting Production Traffic”

Situation: View building is consuming too many resources, causing latency spikes.

Diagnosis:

Terminal window
# Check disk I/O
iostat -x 1 5
# Check latencies
nodetool proxyhistograms
# Check if view building is active
nodetool viewbuildstatus

Action: Reduce builders to minimize impact:

Terminal window
# Slow down view building
nodetool setconcurrentviewbuilders 1
# Or pause entirely during peak hours by setting to 0 (if supported)

Scenario 4: Node Bootstrap Taking Too Long

Section titled “Scenario 4: Node Bootstrap Taking Too Long”

Situation: New node is joining and building views is a bottleneck.

Diagnosis:

Terminal window
# On the new node
nodetool viewbuildstatus
nodetool netstats

Action: Increase builders to speed up bootstrap:

Terminal window
nodetool setconcurrentviewbuilders 4

Situation: Want to complete view builds quickly during a maintenance window.

Action:

Terminal window
# During maintenance window - maximize throughput
nodetool setconcurrentviewbuilders 8
# Monitor progress
nodetool viewbuildstatus
# After completion or before peak hours
nodetool setconcurrentviewbuilders 1

ResourceImpact of More Builders
CPUHigher utilization during builds
Disk I/OMore concurrent reads (base table) and writes (view)
MemoryMore data buffered in memory
NetworkMinimal (view building is local)
SettingBuild SpeedProduction ImpactUse Case
1 (default)SlowMinimalNormal operations
2-4ModerateNoticeableOff-peak view creation
4-8FastSignificantMaintenance windows
8+Very fastHighEmergency rebuilds
#!/bin/bash
# monitor_view_build.sh - Watch view build progress and impact
while true; do
clear
echo "=== $(date) ==="
echo ""
echo "--- View Build Status ---"
nodetool viewbuildstatus
echo ""
echo "--- Current View Builders ---"
nodetool getconcurrentviewbuilders
echo ""
echo "--- Disk I/O ---"
iostat -x 1 1 | grep -E "Device|sd|nvme" | tail -2
echo ""
echo "--- Latencies ---"
nodetool proxyhistograms | head -10
sleep 30
done

Terminal window
# Check status of all view builds
nodetool viewbuildstatus

Example output:

Keyspace View Status
myks users_by_email BUILDING (78%)
myks users_by_country SUCCESS
myks users_by_created BUILDING (12%)
Terminal window
# View builder tasks appear in tpstats
nodetool tpstats | grep -i view
MetricHow to CheckConcern Threshold
Build progressnodetool viewbuildstatusStuck at same percentage
Disk I/O utiliostat -x 1Sustained 100%
Read latencynodetool proxyhistogramsP99 significantly elevated
Write latencynodetool proxyhistogramsP99 significantly elevated

ScenarioRecommended ValueNotes
Normal operations1Minimize impact on production
Small table view creation1-2Quick enough, low impact
Large table view creation2-4Balance speed and impact
Maintenance window4-8Maximize throughput
Multiple simultaneous views2-4Parallel progress
HDD storage1-2Limited by disk I/O
SSD/NVMe storage2-8Can handle more parallelism
Storage TypeCPU CoresSuggested Max
HDDAny2
SATA SSD4-82-4
SATA SSD16+4-6
NVMe SSD16+4-8

  1. Initialization - View metadata created, build job scheduled
  2. Scanning - Base table partitions read sequentially
  3. Transformation - Data transformed to view schema
  4. Writing - View entries written to local SSTables
  5. Completion - Build marked complete, view becomes queryable

Build progress is tracked in system.view_builds_in_progress:

SELECT * FROM system.view_builds_in_progress;

If a node crashes during view building:

  • Progress is checkpointed periodically
  • On restart, build resumes from last checkpoint
  • No need to restart from scratch

View building creates new SSTables, which may trigger compaction:

# If view builds cause compaction storms, consider
compaction_throughput: 64MiB/s

View building uses the same read/write paths:

concurrent_reads: 32 # View building reads from base table
concurrent_writes: 32 # View building writes to view

High view builder count can compete with production traffic for these thread pools.

More builders mean more data in memory:

# Ensure adequate heap for concurrent builds
-Xmx8G

set_view_builders_cluster.sh
#!/bin/bash
VALUE="${1:-1}"# Get list of node IPs from local nodetool status
nodes=$(nodetool status | grep "^UN" | awk '{print $2}')
echo "Setting concurrent view builders to $VALUE on all nodes..."
for node in $nodes; do
echo -n "$node: "
ssh "$node" "nodetool setconcurrentviewbuilders $VALUE \"
&& echo "set to $VALUE" \
|| echo "FAILED"
done
echo ""
echo "Verification:"
for node in $nodes; do
echo -n "$node: "
ssh "$node" "nodetool getconcurrentviewbuilders"
done
cassandra.yaml
concurrent_materialized_view_builders: 2

Terminal window
# Check if build is actually progressing
nodetool viewbuildstatus
# Check for errors in logs
grep -i "view\|materialized" /var/log/cassandra/system.log | tail -50
# Check for resource bottlenecks
iostat -x 1 3
nodetool tpstats
Terminal window
# Check current setting
nodetool getconcurrentviewbuilders
# Increase if resources available
nodetool setconcurrentviewbuilders 4
# Check disk is not bottleneck
iostat -x 1 5
Terminal window
# Reduce builders immediately
nodetool setconcurrentviewbuilders 1
# Check latencies improving
nodetool proxyhistograms
# Consider scheduling builds during off-peak
Terminal window
# Check view status
nodetool viewbuildstatus
# If needed, rebuild the view
# Warning: This is disruptive
ALTER MATERIALIZED VIEW myks.my_view WITH rebuild = true;

View Builder Guidelines

  1. Start with default (1) - Minimize production impact
  2. Increase during off-peak - Use maintenance windows for faster builds
  3. Monitor progress - Watch viewbuildstatus and disk I/O
  4. Restore after completion - Return to default when builds finish
  5. Consider storage type - SSDs can handle more parallelism than HDDs
  6. Plan large view creations - Schedule during low-traffic periods
  7. Make permanent if needed - Update cassandra.yaml for consistent behavior

Materialized View Caveats

Materialized views have significant operational overhead:

  • Every base table write triggers view updates
  • Views can become inconsistent and require repair
  • Large views take a long time to build
  • Views add latency to write operations

Consider alternatives like secondary indexes or application-side denormalization for simpler use cases.


CommandRelationship
getconcurrentviewbuildersView current setting
viewbuildstatusCheck view build progress
tpstatsThread pool statistics
compactionstatsMonitor compaction from view builds