3 ms·
We run a few .net core lambdas and a few things that make a big difference for latency. 1. pre-jit the package, this reduces cold start times as the JIT doesn't
by jabart 5y ago
We run a few .net core lambdas and a few things that make a big difference for latency. 1. pre-jit the package, this reduces cold start times as the JIT doesn't need to run on most items. Still does later to optimize some items. 2 is sticking to the new .net json seralizer. The reference code uses both the new and old newtsonsoft package. The old package has higher memory allocations as it doesn't make use of the Span type.
- moonchrome 5y agoGreat tip for running the JIT AOT, for anyone interested Microsoft calls this "ReadyToRun" compilation [1]. [1] https://docs.microsoft.com/en-us/dotnet/core/deploying/ready-to-run https://docs.microsoft.com/en-us/dotnet/core/deploying/ready... I wonder did you test if the increased size results in an actual win for the startup time ?
- jabart 5y agoAfter like 256mb it is less of an impact when using readytorun. Some of the lambdas I have are webhooks so latency isn't as important and when it's user facing 512mb seems to be a sweet spot.
- Shadonototra 5y agoand then you need to upgrade the plan because it is disk/memory hungry and doesn't fit within the 128mb plan, so you'll pay 4x more already just use GO and be faster while saving money at the same time
- moonchrome 5y agoLike someone else said lambdas are priced by memory * execution time - if you cut execution time by 1/2 by doubling the memory and using AOT - you got faster lambdas for free (even if it's not as high as 1/2 you'll probably still not be paying x2).
- gokhan 5y agoThe test code is quite small and might not benefit from R2R that much, libs it relies on are already jitted. Ditching Newtonsoft would affect response time though.
- jabart 5y agoI have similar code where it takes some JSON input, and sends it off to SQS with a small bit of formatting. It impacts cold starts even for these smaller functions.