Open Josehower opened 1 year ago
Some updates (done in the Security Vulnerability Examples repo - deployed version):
swap_size_mb = 512
in fly.toml
(commit)Let's continue the discussion about how we want to move forward here: https://github.com/upleveled/courses/issues/1732
We are currently having some issues with memory usage in the example repos deployed to fyl.io. The interesting part is the maintainer's solution is a scale to more memory (which at the same time would mean upgrade to a paid plan).
Possible Root Causes:
Memory leak in Next.js
Fly.io specific problem
Some of our code is not setting things up correctly
Alternatives when a solution has not been found/ is out of range (for example. A bug in Next.js):
Actions taken and further research:
Project updates to improve the memory usage:
Memory tests and data gathered:
After testing with scaling the machine to 512MB, the memory usage goes only up to 285MB which exceeds the limit of 256 MB just for a small amount.
Processes in fly.io VM sorted by memory usage:
This seems to show Postgres database plays a relevant role in memory usage
Local Memory Tests
In a local environment Next.js is using around 210MB of RAM only to render a page, which i think it may be the reason is falling in fly.io
The following screenshot was printed from
process.memoryUsage()
inside of each of the project pages:The app was also tested under different ram conditions using the Node flag
--max-old-space-size
Conclusions summary
Next steps based on research:
Since we can't completely discard the idea of being Postgres in the same machine as the app is causing the memory to be insufficient more tests should be performed. This may lead into a potential solution being the use of Postgres from an external machine in the environment.