I'm running Node 14 on an AWS ECS machine with has 5120 CPU
and 8192 Memory
.
At times when running on heavy load (either compressing large number of images using imagemin
or copying files from S3 to the local machine using S3 sync) I get the ENOMEM
error.
This causes the ECS instance to crash.
The S3 sync command is executed via child_process spawn, while imagemin package also spawns a child process in order to compress images. Both errors are displayed below
(node:23) UnhandledPromiseRejectionWarning: Error: spawn ENOMEM
at ChildProcess.spawn (internal/child_process.js:403:11)
at spawn (child_process.js:553:9)
at new SpawnTimeout (/app/src/utils/SpawnTimeout.ts:33:25)
at s3Cp (/app/src/utils/s3.utils.ts:62:24)
at copyFile (/app/src/utils/s3.utils.ts:52:10)
at executeImageCompression (/app/src/processors/Processor.ts:63:9)
I tried increasing the ECS resources and adding custom -max-old-space-size
but it did not help.
I saw this post - Node.js catch ENOMEM error thrown after spawn
But I cannot configure --memory-swap
param in the docker as the deployment is controlled by someone else.
Please advise on how I can resolve this?