Originally published on Medium.com

In my previous article, I was looking into how memory settings in AWS Lambda affects CPU time. I came to the conclusion that the sweet spot is around 1408 MB. Beyond that, you won’t get any performance improvements.

There were open questions. For example, if more memory yields better results for multi-threaded code.

Well, I didn’ know, so I ran a little experiment.

Setting up the stage

Here is a simple Function that returns the number of available cores. Try it with you machine. Mine says 12, because it is an 8th Gen. i7 with 6 Physical cores and Hyper-threading enabled.

public class Cores {
  public Integer handle(Object o) {
    return Runtime.getRuntime().availableProcessors();
  }
}

Again, I wrote a little Bash script that calls the function with each of the 46 possible memory configurations starting at 128 MB. Fun fact: the Bash script took longer to write than the Function itself.

After everything was setup all I had to do was to execute the script and get some numbers.

Show me the numbers

First colum is the memory setting, second column is the number of cores.

128 2
192 2
256 2
320 2
384 2
448 2
512 2
576 2
640 2
704 2
768 2
832 2
896 2
960 2
1024 2
1088 2
1152 2
1216 2
1280 2
1344 2
1408 2
1472 2
1536 2
1600 2
1664 2
1728 2
1792 2
1856 2
1920 2
1984 2
2048 2
2112 2
2176 2
2240 2
2304 2
2368 2
2432 2
2496 2
2560 2
2624 2
2688 2
2752 2
2816 2
2880 2
2944 2
3008 2

I skipped making a pretty ASCII table. After all the results are not impressive enough for spending that amount of time.

Conclusion

Two cores is all you get.

Further reading