Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mitigate probability of OOM killer of Nodejs nextjs server, set EB2 environment NODE_OPTIONS with --max-old-space-size=<max-reserved in MB> #4291

Open
tx0c opened this issue Apr 23, 2024 · 1 comment
Assignees

Comments

@tx0c
Copy link
Contributor

tx0c commented Apr 23, 2024

Description

the OOM killer happens more often than imagined,

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
...

[ec2-user@ip-172-31-7-157 ~]$ time node --trace-warnings -p 'v8.getHeapStatistics()'
{
  total_heap_size: 8155136,
  total_heap_size_executable: 524288,
  total_physical_size: 6561792,
  total_available_size: 2058852536,
  used_heap_size: 4564544,
  heap_size_limit: 2063597568,               <= the default max memory allocation is using 2GB, calculated from 50% of 4GB ;
  malloced_memory: 254104,
  peak_malloced_memory: 476312,
  does_zap_garbage: 0,
  number_of_native_contexts: 1,
  number_of_detached_contexts: 0,
  total_global_handles_size: 8192,
  used_global_handles_size: 2688,
  external_memory: 1984899
}
[ec2-user@ip-172-31-7-157 ~]$ time NODE_OPTIONS="--max_old_space_size=$[1024*3]" node --trace-warnings -p 'v8.getHeapStatistics()'
{
  total_heap_size: 8155136,
  total_heap_size_executable: 524288,
  total_physical_size: 6561792,
  total_available_size: 3266828448,
  used_heap_size: 4548216,
  heap_size_limit: 3271557120,               <= set of 4GB - 1GB reserved = 3GB instead;
  ...

in more logs context: https://www.notion.so/matterslab/2bfadb5c134943cb8203beb069a2280a?v=29efa500e7b74158bb6ab0d872eb14ff


Story

@tx0c
Copy link
Contributor Author

tx0c commented Apr 23, 2024

and set Scaling triggers on UnhealthyCount instead: ( the original Metric on CPUUtilization 30~80% did not work )

https://stackoverflow.com/a/28849236

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant