fsx379 opened a new issue #9660:
URL: https://github.com/apache/dubbo/issues/9660
AbstractRegistry#doSaveProperties()用于在notify通知时,将推送内容存在内存properties
中,然后再持久化磁盘。
通过测试,发现如果推送量比较大,doSaveProperties()会比较耗时,影响整个notify处理流程。
具体原因如下:
```
private void saveProperties(URL url) {
.....
try {
StringBuilder buf = new StringBuilder();
Map<String, List<URL>> categoryNotified = notified.get(url);
if (categoryNotified != null) {
......
}
//[1] 保存内存
properties.setProperty(url.getServiceKey(), buf.toString());
long version = lastCacheChanged.incrementAndGet();
//[2]默认异步持久化
if (syncSaveFile) {
doSaveProperties(version);
} else {
registryCacheExecutor.execute(new SaveProperties(version));
}
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
}
}
```
1.在主流程中 调用 properties.setProperty() 更新 properties,此方法中带有 synchronized 修饰符;
2.默认持久化逻辑 doSaveProperties() 虽然是异步的,但是底层 properties.store0()
方法中,有synchronized(this){...} 代码块;
上述两处的 properties 是同一对象,故会相互影响。
3.如果推送量比较大, properties.setProperty() 被卡住的几率就比较大,影响整体处理速度。(特别是dubbo-admin
底层也使用了dubbo 的逻辑,受影响更大)
此时是否可以将properties.setProperty() 处理,也放入
doSaveProperties()异步逻辑中,减少对主流程notify处理的影响?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]