# AWS Lambda Memory Scaling

# NodeJS

# General concepts and ideas

  • The Maximum amount of Memory available for one Lambda instance is 10,240 MB which leads to the maxamount of cores which is 6 CPU cores
    • CPU Cores are scaled proportional to the configured memory. 1769MB RAM assign exactly 1 CPU core
  • NodeJS is single threaded, therefore it cannot benefit from more than one CPU core by design
    • Even calling child processes does not change that (forking would but is discouraged)
    • Meaning: There is no performance improvement expected when configuring more than 1769MB RAM!

# Rule(s) of thumb

# Configure at least the amount of memory your function needs at max/peak.

Not doing so will lead to function beeing killed due to OOM (Out Of Memory)

# Configure at least 1769MB RAM for CPU bound lambda functions

What does your Lambda actually do? Is it CPU bound? (Is it capable of loading a CPU core most of the runtime duration?)

Examples for CPU bound functions

  • Image processing
  • Compression
  • Encryption

Examples for non CPU bound functions

  • Database APIs (getter/setter)
  • All functions spending most of the time idling and waiting for responses from other "Systems"

# Do not use less than 885MB Memory

There is no hard evidence on why this value seems to be the "minimal sweet spot" for low CPU usage functions. The only thing that was shown in our testing, which prevents us from going below that, are seemingly random lag spikes in cold start situations.

If latency really does not matter for your application you can try to go lower. But in general 885MB should be a good starting point.

Note: 885MB means 0.5 CPU Cores

Page Info: Created by GitHub on Jun 9, 2023 (last updated a minute ago by GitHub)