NextJS - 生产中打开的文件太多错误

NextJS - Too Many Open Files Error in Production

在交通高峰时段,我的生产环境遇到了问题。非常感谢任何有关识别此错误来源的帮助。

错误日志-

[Error: EMFILE: too many open files, open '/app/.next/static/chunks/48573ff84b35da845925e086d08de2d8e5ac654c.49c46a48c467dff66cb4.js'] 
[Error: EMFILE: too many open files, open '/app/.next/static/chunks/8f319b75d6c4fca96c1042484fc0ad01e1047720.aa22673b9cc07604ffb2.js']

我们正在使用 getServerSideProps 进行服务器端渲染。

尝试搜索这个问题,但大多数遇到这个问题的人都在 NodeJS 中遇到这个问题,所以不确定 NextJS 在幕后是如何管理这个问题的。

生产环境- ECS Fargate(10GB RAM,4 个 vCPU),Docker 容器,Node-12 Alpine,Next@10.2.2

Fargate 默认将 nofile 资源限制覆盖为 1024。增加此值可以解决 too many open files 问题。

https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Ulimit.html