imbajin commented on code in PR #2972:
URL: https://github.com/apache/hugegraph/pull/2972#discussion_r2964790436


##########
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={}, " +

Review Comment:
   ⚠️ 在高并发拒绝场景下,这里每次请求都会打印 `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);
   }
   ```
   
   参考:`private static final RateLimiter REJECT_LOG_RATE_LIMITER = 
RateLimiter.create(1.0);`(每秒最多 1 条)



-- 
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]

Reply via email to