hlteoh37 commented on code in PR #24598:
URL: https://github.com/apache/flink/pull/24598#discussion_r1551105900
##########
flink-runtime-web/web-dashboard/src/app/services/metrics.service.ts:
##########
@@ -71,45 +77,73 @@ export class MetricsService {
);
}
- /** Get aggregated metric data from all subtasks of the given vertexId. */
- public loadAggregatedMetrics(
+ /** Get aggregated metric data from all subtasks of the given vertexId.
Example output:
+ { "numRecordsIn": { "min": 0.0, "max": 10.0, "sum": 15.0, "avg": 5.0,
"skew": 66.0 } } */
+ public loadMetricsWithAllAggregates(
jobId: string,
vertexId: string,
- listOfMetricName: string[],
- aggregate: string = 'max'
- ): Observable<MetricMap> {
+ listOfMetricName: string[]
+ ): Observable<MetricMapWithAllAggregates> {
const metricName = listOfMetricName.join(',');
return this.httpClient
- .get<Array<{ id: string; min: number; max: number; avg: number; sum:
number }>>(
+ .get<Array<{ id: string; min: number; max: number; avg: number; sum:
number; skew: number }>>(
`${this.configService.BASE_URL}/jobs/${jobId}/vertices/${vertexId}/subtasks/metrics`,
{ params: { get: metricName } }
)
.pipe(
map(arr => {
- const result: MetricMap = {};
+ const result: MetricMapWithAllAggregates = {};
arr.forEach(item => {
- switch (aggregate) {
- case 'min':
- result[item.id] = +item.min;
- break;
- case 'max':
- result[item.id] = +item.max;
- break;
- case 'avg':
- result[item.id] = +item.avg;
- break;
- case 'sum':
- result[item.id] = +item.sum;
- break;
- default:
- throw new Error(`Unsupported aggregate: ${aggregate}`);
- }
+ result[item.id] = { min: NaN, max: NaN, avg: NaN, sum: NaN, skew:
NaN };
+ result[item.id].min = +item.min;
+ result[item.id].max = +item.max;
+ result[item.id].avg = +item.avg;
+ result[item.id].sum = +item.sum;
+ result[item.id].skew = +item.skew;
});
return result;
})
);
}
+ /** Get metric data from all subtasks of the given vertexId, aggregated by a
given aggregation type
+ Default aggregation type: max */
+ public loadAggregatedMetrics(
+ jobId: string,
+ vertexId: string,
+ listOfMetricName: string[],
+ aggregate: string = 'max'
+ ): Observable<MetricMap> {
+ const result: MetricMap = {};
+ return this.loadMetricsWithAllAggregates(jobId, vertexId,
listOfMetricName).pipe(
Review Comment:
Behavior has changed here. It's not immediately clear from the method name
that all aggregates get loaded, then filtered out to the aggregate we want.
Could we instead make `loadMetricsWithAllAggregates` more generic to just
load the selected aggregates?
##########
flink-runtime-web/web-dashboard/src/app/pages/job/dataskew/data-skew.component.html:
##########
@@ -0,0 +1,72 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<nz-card nzType="inner" nzTitle="What is Data Skew?">
+ <p>
+ Your Flink job has data skew when a subset of subtasks in any of the
operators receives a
+ disproportionate number of records, potentially overloading a subset of
task managers while the
+ rest remain idle, leading to inefficient processing and potentially
backpressure and other
+ related problems.
+ </p>
+</nz-card>
+
+<nz-card nzType="inner" nzTitle="Data Skew" [nzLoading]="isLoading"
[nzExtra]="extraTemplate">
+ <nz-table
+ class="no-border small"
+ [nzSize]="'small'"
+ [nzData]="listOfVerticesAndSkew"
+ [nzFrontPagination]="false"
+ [nzShowPagination]="false"
+ >
+ <tbody>
+ <tr>
+ <th>Vertex</th>
+ <th>Data Skew Percentage</th>
+ </tr>
+ <ng-container *ngFor="let vertexSkew of listOfVerticesAndSkew">
+ <tr>
+ <td>{{ vertexSkew.vertexName }}</td>
+ <td>{{ vertexSkew.skewPct }}%</td>
+ </tr>
+ </ng-container>
+ </tbody>
+ </nz-table>
+</nz-card>
+
+<nz-card nzType="inner" nzTitle="How is Data Skew Calculated?">
+ <p>
+ Data skew is calculated using
+ <a target="_blank"
href="https://en.wikipedia.org/wiki/Coefficient_of_variation">
+ Coefficient of Variation (CV)
+ </a>
+ . The
+ <i>numRecordsIn</i>
+ metric is used to calculate the skew across the subtasks of your
operators. Therefore the source
+ vertices will not show any data skew, since they do not receive any
records. The data skew
+ percentage under the Overview tab shows a more current data skew
percentage by using the
+ <i>numrecordsInPerSecond</i>
+ metric and therefore can be different from the skew percentage shown here.
+ </p>
+</nz-card>
+
+<ng-template #extraTemplate>
+ <button nz-button nzType="primary" class="refresh" nzSize="small"
(click)="refresh()">
Review Comment:
Can we also add a "lastRefreshedAt" timestamp?
##########
flink-runtime-web/web-dashboard/src/app/pages/job/dataskew/data-skew.component.html:
##########
@@ -0,0 +1,72 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<nz-card nzType="inner" nzTitle="What is Data Skew?">
+ <p>
+ Your Flink job has data skew when a subset of subtasks in any of the
operators receives a
+ disproportionate number of records, potentially overloading a subset of
task managers while the
+ rest remain idle, leading to inefficient processing and potentially
backpressure and other
+ related problems.
+ </p>
+</nz-card>
+
+<nz-card nzType="inner" nzTitle="Data Skew" [nzLoading]="isLoading"
[nzExtra]="extraTemplate">
+ <nz-table
+ class="no-border small"
+ [nzSize]="'small'"
+ [nzData]="listOfVerticesAndSkew"
+ [nzFrontPagination]="false"
+ [nzShowPagination]="false"
+ >
+ <tbody>
+ <tr>
+ <th>Vertex</th>
+ <th>Data Skew Percentage</th>
+ </tr>
+ <ng-container *ngFor="let vertexSkew of listOfVerticesAndSkew">
+ <tr>
+ <td>{{ vertexSkew.vertexName }}</td>
+ <td>{{ vertexSkew.skewPct }}%</td>
+ </tr>
+ </ng-container>
+ </tbody>
+ </nz-table>
+</nz-card>
+
+<nz-card nzType="inner" nzTitle="How is Data Skew Calculated?">
+ <p>
+ Data skew is calculated using
+ <a target="_blank"
href="https://en.wikipedia.org/wiki/Coefficient_of_variation">
+ Coefficient of Variation (CV)
+ </a>
+ . The
+ <i>numRecordsIn</i>
+ metric is used to calculate the skew across the subtasks of your
operators. Therefore the source
+ vertices will not show any data skew, since they do not receive any
records. The data skew
+ percentage under the Overview tab shows a more current data skew
percentage by using the
+ <i>numrecordsInPerSecond</i>
Review Comment:
```suggestion
<i>numRecordsInPerSecond</i>
```
##########
flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/metrics/DoubleAccumulatorTest.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.handler.job.metrics;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import java.util.stream.Stream;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import static org.assertj.core.api.AssertionsForClassTypes.within;
+
+class DoubleAccumulatorTest {
+
+ @ParameterizedTest
+ @MethodSource("dataSkewTests")
+ void testDataSkew(double n1, double n2, double n3, double expectedSkew) {
Review Comment:
Can we add more test cases here to prevent accidental algorithm adjustment?
1. Single value
2. Behavior on empty list
3. High skew
4. Low skew
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]