From a9fe036ddc54b0a1d0d77191f8ab7482a64d7c2d Mon Sep 17 00:00:00 2001 From: Yanlong Wang Date: Wed, 7 May 2025 18:24:19 +0800 Subject: [PATCH] fix: set maxConcurrentStreams for http2 so it can be load-balanced reasonably --- src/stand-alone/crawl.ts | 4 ++++ src/stand-alone/search.ts | 4 ++++ src/stand-alone/serp.ts | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/stand-alone/crawl.ts b/src/stand-alone/crawl.ts index 4a6e84c..4c0a2bb 100644 --- a/src/stand-alone/crawl.ts +++ b/src/stand-alone/crawl.ts @@ -44,6 +44,10 @@ export class CrawlStandAloneServer extends KoaServer { const ar = new AsyncResource('HTTP2ServerRequest'); ar.runInAsyncScope(fn, this.koaApp, req, res); }); + // HTTP2 p2p may break the load balancing + this.httpServer.updateSettings({ + maxConcurrentStreams: 8, + }); // useResourceBasedDefaultTracker(); return this; diff --git a/src/stand-alone/search.ts b/src/stand-alone/search.ts index 673a3cb..c2ec152 100644 --- a/src/stand-alone/search.ts +++ b/src/stand-alone/search.ts @@ -44,6 +44,10 @@ export class SearchStandAloneServer extends KoaServer { const ar = new AsyncResource('HTTP2ServerRequest'); ar.runInAsyncScope(fn, this.koaApp, req, res); }); + // HTTP2 p2p may break the load balancing + this.httpServer.updateSettings({ + maxConcurrentStreams: 8, + }); // useResourceBasedDefaultTracker(); return this; diff --git a/src/stand-alone/serp.ts b/src/stand-alone/serp.ts index 76c91fc..1691c4b 100644 --- a/src/stand-alone/serp.ts +++ b/src/stand-alone/serp.ts @@ -45,6 +45,10 @@ export class SERPStandAloneServer extends KoaServer { const ar = new AsyncResource('HTTP2ServerRequest'); ar.runInAsyncScope(fn, this.koaApp, req, res); }); + // HTTP2 p2p may break the load balancing + this.httpServer.updateSettings({ + maxConcurrentStreams: 50, + }); // useResourceBasedDefaultTracker(); return this;