您好,我正在尝试找出导致此内存泄漏的问题
ecs 任务的内存使用情况,当我们使用 keepAlive 时,您可以看到内存增加
nestApp 在 Express 应用程序中运行,因为旧的 Express 应用程序已被弃用,我们可以将重构所有现有路由迁移到 nest,而不会破坏前端的更改。
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
export const DEFAULT_CONFIG: AxiosRequestConfig = {
timeout: 1000,
httpAgent,
httpsAgent,
};
export const SOME_CONFIG: AxiosRequestConfig = {
...DEFAULT_CONFIG,
timeout: +process.env.TIMEOUT,
baseURL: process.env.UPSTREAM,
};
@Module({
imports: [HttpModule.register(SOME_CONFIG)],
providers: [SomeUpstreamService],
exports: [SomeUpstreamService],
})
export class SomeAdapterModule {}
Run Code Online (Sandbox Code Playgroud)
这是我们为上游 API 初始化不同功能模块的方式
在 Legacy Express App 中,我们也使用 Axios 和 Http(s)Agent KeepAlive true,因为 2 年没有内存问题,仅在 nestjs 部分 …