Available RAM is not the only thing that's influenced by the Memory setting, which is a bit counterintuitive at first. The memory setting in a Lambda function influences:
- The amount of compute (vCPUs) that's available to the function
- The amount of network throughput that's available
- The amount of system memory / RAM that's available
All of these scale based on the memory. You can think of it like this: If you provision 128MB RAM, you also get about 1/8 of a vCPU, if you go to 256 MB, you get a quarter of a vCPU. These are not exact numbers, but it's a useful mental model. Somewhere between 1024 and 1280 MB you get a full vCPU and afterwards a second vCPU is added.
Your workload seems CPU intensive (since there's not GPU to offload it to), so I'd try to increase the Memory to give Lambda more compute power to see how it behaves.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…