Pen*_*ryn 5 node.js express axios nestjs
您好,我正在尝试找出导致此内存泄漏的问题
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 部分
当我在本地运行一个小负载测试 (20req/sec) 时,我可以看到很多关于 Nest 对上游 API 的请求的套接字挂断错误
我也试过 maxSockets、maxSocketsMs、keepAliveMsecs 没有任何帮助。
我希望有人能给我一个提示我错过了什么
| 归档时间: |
|
| 查看次数: |
1187 次 |
| 最近记录: |