Auto-scaling flow deployments

Flow deployments can be configured to automatically scale up or down the number of NiFi nodes depending on the resource utilization in the cluster.

With Auto-scaling, you get the following benefits:

  • You can choose a minimum and maximum number of nodes to ensure that the required resources are available while controlling cost.

  • Flow deployments support CPU based auto-scaling as well as flow metrics based auto-scaling.

  • When a flow deployment scales down, the affected NiFi nodes are being offloaded before they are removed from the cluster to ensure that no data is lost.

  • After new nodes have been added to the cluster, new data is automatically distributed to all cluster nodes including the recently provisioned ones.

HPA monitors CPU utilization across all NiFi pods of a flow deployment. When CPU utilization reaches 75%, a new NiFi pod gets created and is added to the NiFi cluster. HPA continues to add additional NiFi pods until the aggregated CPU utilization for a deployment becomes stable around the 75% threshold. Once the new NiFi pod has joined the NiFi cluster, it starts receiving and processing data.

A similar logic is applied to automatically scale down and decrease the number of NiFi pods. HPA monitors CPU utilization and when it falls below 75% for five minutes it starts removing NiFi pods. Before the NiFi pod is terminated, Cloudera Data Flow offloads all existing data from the NiFi pod that has been selected for termination. Offloading data distributes data that is currently being processed by the affected node to the remaining nodes in the cluster. This offloading procedure ensures that NiFi pods are terminated gracefully and avoids data loss.

CPU based auto-scaling

When you turn this feature on, Cloudera Data Flow uses the Kubernetes Horizontal Pod Autoscaler (HPA) to increase or decrease the number of NiFi pods in a deployment based on resource utilization.

HPA monitors CPU utilization across all NiFi pods of a flow deployment. When CPU utilization reaches 75%, a new NiFi pod gets created and is added to the NiFi cluster. HPA continues to add additional NiFi pods until the aggregated CPU utilization for a deployment becomes stable around the 75% threshold. Once the new NiFi pod has joined the NiFi cluster, it starts receiving and processing data.

CPU based auto-scaling is great for data flows that require CPU intensive transformations like compressing or decompressing data and have to deal with bursts of data every now and then.

Flow metrics based auto-scaling

Flow metrics based auto-scaling predicts future load on a connection to trigger scaling decisions.

In contrast to CPU based auto-scaling where scaling decisions are made based on infrastructure utilization, flow metrics based auto-scaling works by predicting backpressure on a source connection queue. Source connections are connections attached to processors where data is first introduced into the flow. Backpressure occurs when such a connection becomes 100% full. Source connections are automatically detected through static analysis of the flow definition. Queue percentage of each source connection is tracked and a linear regression is performed on the histogram for each to predict the fullness of the queue in 20 minutes. Scaling up occurs when that prediction is greater than 80% for 5 minutes.

Flow metrics based auto-scaling can be used to detect the need to scale based on flow performance metrics. In cases where queues fill up without CPU utilization going over the threshold, flow metrics based auto-scaling still triggers a scaling operation.