Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
d8fce128
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 1 年多
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
d8fce128
编写于
12月 05, 2022
作者:
wu-sheng
提交者:
GitHub
12月 05, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cache enhancement - don't read new metrics from database in minute (#10085)
上级
8c31172c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
1 deletion
+72
-1
docs/en/changes/changes.md
docs/en/changes/changes.md
+14
-0
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java
.../server/core/analysis/worker/MetricsPersistentWorker.java
+56
-1
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/status/ServerStatusService.java
...kywalking/oap/server/core/status/ServerStatusService.java
+2
-0
未找到文件。
docs/en/changes/changes.md
浏览文件 @
d8fce128
...
...
@@ -7,6 +7,20 @@
*
Add
`ServerStatusService`
in the core module to provide a new way to expose booting status to other modules.
*
Adds Micrometer as a new component.(ID=141)
*
Refactor session cache in MetricsPersistentWorker.
*
Cache enhancement - don't read new metrics from database in minute dimensionality.
```
// When
// (1) the time bucket of the server's latest stability status is provided
// 1.1 the OAP has booted successfully
// 1.2 the current dimensionality is in minute.
// (2) the metrics are from the time after the timeOfLatestStabilitySts
// (3) the metrics don't exist in the cache
// the kernel should NOT try to load it from the database.
//
// Notice, about condition (2),
// for the specific minute of booted successfully, the metrics are expected to load from database when
// it doesn't exist in the cache.
```
#### UI
...
...
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java
浏览文件 @
d8fce128
...
...
@@ -25,11 +25,15 @@ import java.util.Optional;
import
java.util.Properties
;
import
java.util.stream.Collectors
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.skywalking.oap.server.core.CoreModule
;
import
org.apache.skywalking.oap.server.core.UnexpectedException
;
import
org.apache.skywalking.oap.server.core.analysis.DownSampling
;
import
org.apache.skywalking.oap.server.core.analysis.TimeBucket
;
import
org.apache.skywalking.oap.server.core.analysis.data.MergableBufferedData
;
import
org.apache.skywalking.oap.server.core.analysis.data.ReadWriteSafeCache
;
import
org.apache.skywalking.oap.server.core.analysis.metrics.Metrics
;
import
org.apache.skywalking.oap.server.core.exporter.ExportEvent
;
import
org.apache.skywalking.oap.server.core.status.ServerStatusService
;
import
org.apache.skywalking.oap.server.core.storage.IMetricsDAO
;
import
org.apache.skywalking.oap.server.core.storage.SessionCacheCallback
;
import
org.apache.skywalking.oap.server.core.storage.model.Model
;
...
...
@@ -89,6 +93,16 @@ public class MetricsPersistentWorker extends PersistenceWorker<Metrics> {
* @since 8.7.0 TTL settings from {@link org.apache.skywalking.oap.server.core.CoreModuleConfig#getMetricsDataTTL()}
*/
private
int
metricsDataTTL
;
/**
* @since 9.4.0
*/
private
final
ServerStatusService
serverStatusService
;
/**
* The time bucket is 0 or in minute dimensionality of the system in the latest stability status.
*
* @since 9.4.0
*/
private
long
timeOfLatestStabilitySts
=
0
;
MetricsPersistentWorker
(
ModuleDefineHolder
moduleDefineHolder
,
Model
model
,
IMetricsDAO
metricsDAO
,
AbstractWorker
<
Metrics
>
nextAlarmWorker
,
AbstractWorker
<
ExportEvent
>
nextExportWorker
,
...
...
@@ -145,6 +159,7 @@ public class MetricsPersistentWorker extends PersistenceWorker<Metrics> {
new
MetricsTag
.
Keys
(
"status"
),
new
MetricsTag
.
Values
(
"cached"
)
);
SESSION_TIMEOUT_OFFSITE_COUNTER
++;
serverStatusService
=
moduleDefineHolder
.
find
(
CoreModule
.
NAME
).
provider
().
getService
(
ServerStatusService
.
class
);
}
/**
...
...
@@ -191,6 +206,11 @@ public class MetricsPersistentWorker extends PersistenceWorker<Metrics> {
return
Collections
.
emptyList
();
}
if
(
model
.
getDownsampling
().
equals
(
DownSampling
.
Minute
))
{
timeOfLatestStabilitySts
=
TimeBucket
.
getMinuteTimeBucket
(
serverStatusService
.
getBootingStatus
().
getUptime
());
}
/*
* Hard coded the max size. This only affect the multiIDRead if the data doesn't hit the cache.
*/
...
...
@@ -299,7 +319,7 @@ public class MetricsPersistentWorker extends PersistenceWorker<Metrics> {
List
<
Metrics
>
notInCacheMetrics
=
metrics
.
stream
()
.
filter
(
m
->
{
final
Metrics
cachedValue
=
sessionCache
.
get
(
m
);
final
Metrics
cachedValue
=
requireInitialization
(
m
);
// the metric is tagged `not in cache`.
if
(
cachedValue
==
null
)
{
return
true
;
...
...
@@ -340,6 +360,41 @@ public class MetricsPersistentWorker extends PersistenceWorker<Metrics> {
sessionCache
.
removeExpired
();
}
/**
* Check the metrics whether in the cache, and whether the worker should go further to load from database.
*
* @param metrics the metrics in the streaming process.
* @return metrics in cache or null if try to read the metrics from the database.
*/
private
Metrics
requireInitialization
(
Metrics
metrics
)
{
final
Metrics
cached
=
sessionCache
.
get
(
metrics
);
// All cached metrics, it at least had been written once.
if
(
cached
!=
null
)
{
return
cached
;
}
// When
// (1) the time bucket of the server's latest stability status is provided
// 1.1 the OAP has booted successfully
// 1.2 the current dimensionality is in minute.
// (2) the metrics are from the time after the timeOfLatestStabilitySts
// (3) the metrics don't exist in the cache
// the kernel should NOT try to load it from the database.
//
// Notice, about condition (2),
// for the specific minute of booted successfully, the metrics are expected to load from database when
// it doesn't exist in the cache.
if
(
timeOfLatestStabilitySts
>
0
&&
metrics
.
getTimeBucket
()
>
timeOfLatestStabilitySts
&&
cached
==
null
)
{
// Return metrics as input to avoid reading from database.
return
metrics
;
}
return
null
;
}
/**
* Metrics queue processor, merge the received metrics if existing one with same ID(s) and time bucket.
*
...
...
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/status/ServerStatusService.java
浏览文件 @
d8fce128
...
...
@@ -18,6 +18,7 @@
package
org.apache.skywalking.oap.server.core.status
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
import
org.apache.skywalking.oap.server.library.module.ModuleManager
;
import
org.apache.skywalking.oap.server.library.module.Service
;
...
...
@@ -35,6 +36,7 @@ import org.apache.skywalking.oap.server.telemetry.api.MetricsTag;
@RequiredArgsConstructor
public
class
ServerStatusService
implements
Service
{
private
final
ModuleManager
manager
;
@Getter
private
BootingStatus
bootingStatus
=
new
BootingStatus
();
public
void
bootedNow
(
long
uptime
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录