Elements Service Load Balancer #2552
Replies: 2 comments 3 replies
-
Hi @luoluoyuyu, |
Beta Was this translation helpful? Give feedback.
-
Hi @luoluoyuyu, thank you very much for your proposal! This is really outstanding and shows a lot of dedication ❤️ I was wondering how the pipeline separation is supposed to work within StreamPipes. Should user-defined pipelines be separated in "technical" pipelines under the hood? Do you already have an idea how this could look like? If not, I'm fine - we'll find out 🙂 Do you already have a rough idea how we can plan the implementation effort? Where do we want to start? Do we want to address one use case first (e.g., pipeline allocation) and then focus on the remaining? With respect to the actual implementation: Do we want/need to build everything from scratch? Are there some libraries/frameworks we may adopt? Does it make sense to have a look how other tools handle load balancing of DAG execution? Maybe something like Airflow? How does pipeline separation work? |
Beta Was this translation helpful? Give feedback.
-
Proposal: Elements Service Load Balancer
Motivation
As Apache StreamPipes serves as an IoT data stream processing system, providing robust computational capabilities is necessary. The extensions service primarily handling data stream processing may require scalable support to optimize its performance. Therefore, I propose adding an extensible load balancer to StreamPipes.
Goals
User-Facing Goals
Logging/Metrics
Configuration
Internal Implementation Goals
Logic
Logging/Metrics
Configuration
Testing
Load Balancer Implementation
Pipeline Allocation
Pipelines are allocated based on continuous pipelines (which can also be continuous pipeline branches, hereafter referred to as pipelines). If future optimizations for message transmission are required, such as better adaptation to memory as a medium for transmission, it should also better support the affinity feature.
Affinity
To better support the characteristics of edge computing, labels can be set for extensions services and pipelines. Priority is given to allocate pipelines to extensions services that match the pipeline label, which may also cause resource skewness due to affinity.
For example, Service A sets label [Asia], Service sets label [North America], and the pipeline sets label [Asia], then the pipeline will be allocated to Service A first.
Data Model
ServiceLoadData
For example {cpu, memory, io, msgIn/Out, ...}
Stored in metadata storage.
PipelineLoadData
{PipelineName, msgIn/Out, ...}
Stored in metadata storage.
Data Read/Write Flow
ServiceLoadData
Write:
Core periodically reads ServiceLoadData and puts it into metadata storage.
Read:
When load balancing needs to be determined, current data and historical data need to be read.
PipelineLoadData
Write:
Core periodically collects PipelineLoadData and puts it into metadata storage.
Read:
When pipeline offloading needs to be determined, current data needs to be read.
Pipeline Allocation
Pipeline allocation needs to consider how to select available extension services because each extension service may support different elements. Therefore, when faced with this issue, attention should be paid to how to separate pipelines into branches so that they can be more effectively allocated to extension services. Thus, pipeline segmentation is required. It is advisable for each extension services to have an equal number of runnable elements, facilitating allocation on a per-pipeline basis.
Pipeline Segmentation
Deep-first traversal is adopted. If the number of available element services decreases when traversing to the next element, then this pipeline branch is treated as a unit for allocation.
As shown in the above diagram, the adapter is allocated as a separate pipeline. Below is the pipeline segmentation, with [A,B] as one pipeline branch and [C] as another pipeline branch for allocation.
[A,B] pipeline can allocate 2 extension element services, but when element C is added, the pipeline can only allocate one extension service, reducing the available extension element services. Therefore, it is segmented into allocation units [A,B], [C].
Allocation Algorithms
Pipeline branches need to be allocated to extension services, and the following algorithms can be provided.
Affinity
For services with affinity, the default load balancing strategy is used.
Pipeline Separation
Calculate the throughput rate of the pipeline. When the throughput rate of all elements exceeds a threshold, the pipeline is separated. Priority is given to separating pipeline branches with no affinity.
Separation Algorithm
The pipeline is divided into two branches with equal throughput or message rates, and one of the branches is further allocated pipelines.
Pipeline Migrator
Calculate the load of services and provide three strategies. However, due to disparities in each extensions service, such as inconsistent runnable elements or unequal physical resources, the specific situation needs to be analyzed to determine which trigger for pipeline migration to use. When a pipeline needs to be migrated, it needs to be pre-allocated to the corresponding extension service before stopping the original pipeline branch. Note that recently migrated pipeline branches will not be migrated again, and non-affinity pipelines are prioritized for offloading.
ThresholdMigrator
ThresholdMigrator uses a historical scoring algorithm to compute scores for each broker to address performance fluctuations. The usage rate of extension services and the average usage rate are calculated as follows: if the usage rate of an extension service exceeds the average usage rate plus ThresholdMigratorPercentage, the load balancer removes enough pipeline branches to ensure that the usage rate of each extension service is less than ThresholdMigratorPercentage + avgUsage.
For example, if the usage rates of three extension services are 90%, 50%, and 10% respectively, and the average is 50%, with ThresholdMigratorPercentage being 30%, balancing is required because 90% > 50% + 30%.
Advantages
Disadvantages
Configuration
OverloadMigrator
Sets thresholds for CPU, network, and memory usage rates. If any of these thresholds are reached in an extension service, pipeline offloading is triggered.
Disadvantages
If the threshold is set to 90 and the current load situation for a service is (80, 0, 0), no load balancing will occur.
Configuration
UniformLoadMigrator
Calculates the message event rate for all extension services. If (max-min)/min > Threshold, pipeline migration is triggered. The load of each node does not exceed (max-min)/min.
Configuration
TransferMigrator
The Transfer Migrator strategy offloads pipelines from the highest-loaded extension service to the lowest-loaded extension service until all the following conditions are met:
After arranging according to TransferMigrator as shown above, 40% of the load is migrated to the service with the lowest load, and the second service assigns 25% of the load to the second-to-last load.
Configuration
Beta Was this translation helpful? Give feedback.
All reactions