Hi. I deploy a remix app which should support video uploads. I noticed that when uploading files of around 100MB, my instance just dies with these logs:
2024-06-21T23:59:11.429 app[d8913e6f6e17d8] qro [info] [ 51.841459] Out of memory: Killed process 338 (node) total-vm:13230264kB, anon-rss:1879876kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:6300kB oom_score_adj:0
2024-06-21T23:59:11.511 proxy[d8913e6f6e17d8] qro [error] [PU02] could not complete HTTP request to instance: connection error: Connection reset by peer (os error 104)
2024-06-21T23:59:11.513 app[d8913e6f6e17d8] qro [info] Killed
2024-06-21T23:59:12.295 app[d8913e6f6e17d8] qro [info] INFO Main child exited normally with code: 137
2024-06-21T23:59:12.308 app[d8913e6f6e17d8] qro [info] INFO Starting clean up.
2024-06-21T23:59:12.310 app[d8913e6f6e17d8] qro [info] WARN could not unmount /rootfs: EINVAL: Invalid argument
2024-06-21T23:59:12.310 app[d8913e6f6e17d8] qro [info] [ 52.723394] reboot: Restarting system
You might think that my instance ran out of memory but I heavily doubt that. My instance has 2GB and metrics show that it hasn’t used even 500MB. So I don’t think that’s the case.
What is weird is that app is usually running at 300MB and uploading a file of 100MB shouldn’t take so much memory… could something be wrong in my app? or is it normal for NodeJS apps to take so much memory?
Taken together, Node will reclaim memory before you run out, and provide a buffer in case it is needed. Garbage collection and swap space impact performance, but in general that’s preferred over crashing.