You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

哪种导入方式可降低NestJS微服务的内存占用?

NestJS + ts-node 微服务导入方式与内存占用优化疑问

最近在研究Node.js 20 + NestJS 10环境下,微服务的最优依赖导入方式。之前单个Pod内存占用高达300MB,仅修改main.ts里的导入代码后,内存占用直接降到了10MB,差异非常明显。

两种导入方式对比

原导入方式

import { NestFastifyApplication, FastifyAdapter } from '@nestjs/platform-fastify';

优化后导入方式

import { NestFastifyApplication } from '@nestjs/platform-fastify/interfaces/nest-fastify-application.interface';
import { FastifyAdapter } from '@nestjs/platform-fastify/adapters/fastify-adapter';

想问下有没有人做过不同导入方式的性能/内存测试?目前事务繁忙,下周会分享我的详细测试结果。

内容的提问来源于stack exchange,提问作者Shemm11

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 02:43:09