-
Notifications
You must be signed in to change notification settings - Fork 1.1k
improve the runtimeController performance in large-scale scenarios #4509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve the runtimeController performance in large-scale scenarios #4509
Conversation
50768b5 to
bb2e883
Compare
3082e72 to
1f4e010
Compare
Signed-off-by: jiuyu <guotongyu.gty@alibaba-inc.com>
1f4e010 to
bb0ebbd
Compare
|
| return | ||
| } | ||
|
|
||
| duration, err := strconv.Atoi(RuntimeReconcileDurationEnvVal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this function is called frequently (such as during each Reconcile), repeatedly parsing the string can waste CPU resources. I suggest doing this once in init function.
| return finishTime.Sub(creationTime).Round(time.Second).String() | ||
| } | ||
|
|
||
| func GenerateRandomRequeueDurationFromEnv() (needReconcile bool, d time.Duration) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GenerateRandomRequeueDurationFromEnv -> GenerateRandomRequeueDuration
| return | ||
| } | ||
| r := rand.New(rand.NewSource(time.Now().UnixNano())) | ||
| randomDurationValue := (r.Intn(2*offset+1) + duration - offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not reusing the global math/rand instance to avoid repeatedly creating rand.Source?Reuse the global math/rand instance directly to avoid repeatedly creating rand.Source and rand.Rand.
|
@Syspretor Thank you providing the useful solution. I think it's better to also provide documents for the end users. |
cheyang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cheyang The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |



As Fluid is increasingly being adopted by more users in production environments, the number of datasets within clusters has reached the order of thousands. This places higher demands on the overall performance of the RuntimeController. The most critical factor here is the time taken for a dataset to become bounded after its creation, as this directly affects the readiness time of business operations. Through extensive testing, it has been observed that the time for a dataset to become bound increases exponentially with the number of datasets. In a cluster environment with thousands of datasets, the average time for a single dataset to become bound has reached 40 seconds. Therefore, this PR aims to optimize the performance of the RuntimeController in large-scale dataset clusters.
Testing has revealed that the main factor affecting the RuntimeController's ability to bind a runtime and dataset is the significant amount of repeated enqueuing of runtimes/datasets. This causes the reconcile-worker to remain in an active state continuously, resulting in queue blockage and delays. There are two major sources of repeated enqueuing:
This PR focuses on optimizing the controller's performance in handling runtimes by addressing these two issues. It introduces two configurable environment variables for the controller:
FLUID_RUNTIME_RECONCILE_DURATIONandFLUID_RUNTIME_RECONCILE_DURATION_OFFSET.For runtimes that do not require immediate dataset cache status updates,
FLUID_RUNTIME_RECONCILE_DURATION(in seconds, default is 90) can be used to control the default reconcile interval. Increasing this interval appropriately can help reduce the pressure on the reconcile queue.When
FLUID_RUNTIME_RECONCILE_DURATIONis set to -1, runtimes like Thinruntime, which do not support reporting cache stats, will not be reconciled periodically. However, updates to the dataset, runtime, or runtime workload will still trigger the runtime to be enqueued for reconciliation.These changes are intended to significantly reduce queue pressure and improve performance.
The
FLUID_RUNTIME_RECONCILE_DURATION_OFFSETis designed to optimize the batch creation of datasets/runtimes. In batch creation scenarios, all runtimes are enqueued simultaneously, and after processing, they are re-enqueued at the same time interval set byFLUID_RUNTIME_RECONCILE_DURATION. This can lead to suboptimal utilization of reconcile workers. To address this, we can configureFLUID_RUNTIME_RECONCILE_DURATION_OFFSETalong withFLUID_RUNTIME_RECONCILE_DURATIONto set a random enqueuing time within a specified range. For instance, the following configuration allows runtimes to be enqueued at a random interval between 80 to 160 seconds. This aims to stagger the re-enqueuing times of batch-created datasets/runtimes, thereby improving the utilization of reconcile workers.On the other hand, this PR optimizes the logic for updating the state of a dataset during the sync process, thereby preventing runtimes from being passively enqueued due to frequent dataset updates.
Testing has shown that, after optimization, the time taken for a dataset to become bound in a cluster with thousands of datasets has been reduced from an average of over 40 seconds to just over 1 second. Furthermore, this performance is maintained even in larger cluster sizes.