Scaling policies
RisingWave supports adaptive and fixed parallelism for each streaming job, including materialized view, sink, and table.-
Adaptive parallelism
Adaptive parallelism is the default setting for newly created streaming jobs since v1.7. In this mode, RisingWave automatically adjusts parallelism to utilize all CPU cores across the compute nodes in the cluster. When nodes are added or removed, parallelism adjusts accordingly based on the current number of CPU cores.
To modify the scaling policy to adaptive parallelism, use the SQL command:
To modify on a materialized view:
-
Fixed parallelism
Fixed parallelism is the advanced mode that allows manually specifying a parallelism number that remains constant as the cluster resizes. It’s commonly used to throttle stream bandwidth and ensures predictable resource allocation. For example:
When there are many streaming jobs running in the cluster, it’s recommended to use fixed parallelism to avoid overloading the system.
Configuring maximum parallelism
Streaming jobs used to have a maximum parallelism of 256. Starting from RisingWave version 2.2, you can configure the maximum parallelism for streaming jobs. This is controlled by thestreaming_max_parallelism
session variable, which determines the upper limit for parallelism that can be set for a streaming job.
- With adaptive parallelism, the parallelism of a streaming job will be capped at the configured maximum parallelism, even if the number of CPU cores in the cluster increases.
- With fixed parallelism, it’s not allowed to set a parallelism greater than the configured maximum parallelism.
rw_streaming_parallelism
. See Monitor parallelism for more details.
When deciding on a value, please note that:
- The maximum parallelism for a job cannot be changed after creation, unless you drop and recreate it.
- Higher values enable compute-intensive jobs to utilize more resources.
- Lower values may provide better range scan performance on the result table/materialized view.
Scale-out
Scale-out here refers to the process of adding more compute nodes to the cluster. For frontend nodes, you can simply scale out/in by adding more frontend nodes to the cluster, because they are stateless and can be automatically discovered by the meta nodes.- First, add more compute nodes with
kubectl
.
- If you are using fixed parallelism, you may need to manually adjust the parallelism of the streaming jobs to utilize the new compute nodes. For adaptive parallelism, the system will automatically adjust the parallelism to utilize the new compute nodes.
Scale-in
Scale-in here refers to the process of decreasing compute nodes from the cluster. By default, there’s a 5-minute delay in scale-in operations. The delay is intentional to prevent unnecessary heavy recovery operations caused by transient failures like network jitters and CPU stalls.- Since v2.0, to trigger an immediate scale-in, apply the following yaml files to decrease the number of compute nodes:
- If you are using fixed parallelism, you may need to manually adjust the parallelism of the streaming jobs. For adaptive parallelism, the system will automatically adjust the streaming jobs to use less parallelism.
Upgrade to v1.7
After upgrading to v1.7 from prior versions, if the parallelism is unset, streaming jobs will automatically upgrade to adaptive parallelism (adaptive
). If the parallelism is set, streaming jobs will use fixed
parallelism.
Monitor parallelism
You can use a system table to view the current scaling policy of tables, materialized views, and sinks:rw_fragment_parallelism
instead: