imbajin commented on code in PR #2972:
URL: https://github.com/apache/hugegraph/pull/2972#discussion_r2964794747
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/LoadDetectFilter.java:
##########
@@ -70,7 +88,12 @@ public void filter(ContainerRequestContext context) {
int maxWorkerThreads = config.get(ServerOptions.MAX_WORKER_THREADS);
WorkLoad load = this.loadProvider.get();
// There will be a thread doesn't work, dedicated to statistics
- if (load.incrementAndGet() >= maxWorkerThreads) {
+ int currentLoad = load.incrementAndGet();
+ if (currentLoad >= maxWorkerThreads) {
+ LOG.warn("Rejected request due to high worker load, method={},
path={}, " +
+ "currentLoad={}, maxWorkerThreads={}",
+ context.getMethod(), context.getUriInfo().getPath(),
+ currentLoad, maxWorkerThreads);
Review Comment:
> The new WARN logs will be emitted for every rejected request; under
overload this can produce a log storm and further degrade the server (I/O,
disk, log rotation). Consider rate-limiting/sampling these rejection logs
(similar to the existing RateLimiter usage elsewhere) or logging once per
interval with aggregated counters.
⚠️ 每次请求都会打印 `WARN`,可能产生大量日志 I/O,进一步放大系统抖动(导入/批量写入期间更明显)。
可以给“拒绝日志”加一个轻量限速(只限日志,不限请求处理),这样不会阻塞线程:
```suggestion
if (REJECT_LOG_RATE_LIMITER.tryAcquire()) {
LOG.warn("Rejected request due to high worker load, method={}, path={},
" +
"currentLoad={}, maxWorkerThreads={}",
context.getMethod(), context.getUriInfo().getPath(),
currentLoad, maxWorkerThreads);
}
```
// 每秒最多 1 条日志记录
参考:`private static final RateLimiter REJECT_LOG_RATE_LIMITER =
RateLimiter.create(1.0);`
--
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]