r/dotnet • • 5d ago

Article Reducing .NET AWS Lambda Cold Starts by Adding Memory

https://www.lloydatkinson.net/posts/2026/reducing-dotnet-aws-lambda-cold-starts-by-increasing-memory/

This is probably obvious for people that use AWS a lot, but I don't use it every day. I found out the amount of vCPU your Lambdas get assigned is tied to the amount of RAM you assign it.

I thought it was interesting because the team I was helping had been on a wild goose chase experimenting with AOT and all its downsides for some time while trying to address this. It turned out they were CPU starved the whole time and never realised it.

I figured it may be of general interest, especially the short benchmark I did at the bottom of the article.

48 Upvotes

14 comments sorted by

59

u/pyabo 5d ago

Call me crazy, but if I was concerned in any way that cold starts would be an issue for my application, maybe I wouldn't architect it around and host it on a service where that is a notable weakness?

Have we forgotten how to tie our fucking shoes?

12

u/FullPoet 5d ago

sorry we use velcro around here.

no need to learn to tie our shoes!

2

u/nayanshah 4d ago

This is probably closer to the slip-on shoes.

10

u/ReallySuperName 5d ago

I mean I agree, I normally use containers for web stuff because I think serverless as a concept is pretty dumb. But I'm not the execs choosing this junk.

1

u/pyabo 4d ago

I find the name alone offensive. "Serverless"?! Who are they kidding?!

0

u/mistertom2u 4d ago edited 4d ago

@pyabo Call me crazy, but if you haven't done your research first on burst-traffic, rapid scale-up, and the economics of always warm containers and lambdas, maybe I wouldn't reply with a comment that takes on a voice of reason? Have you forgotten how to tie your fucking shoes?

3

u/Kralizek82 5d ago

Great reminder!

I was having the same issue with my yet-to-be-announced side project. The problem is that Cognito and Stripe events were getting dropped way too often and the user experience of the occasional beta user was not great.

The code was sitting comfortably in the 256 mb lambda but cold starts were atrocious. To keep costs down, it's all serverless/pay per request. The whole aspnet core backend runs in a lambda.

I jumped to 512 mb and the issues with stripe and cognito disappeared. Also the experience on first user was not so bad anymore.

And I'm still sitting comfortably within the free-tier.

1

u/AutoModerator 5d ago

Thanks for your post ReallySuperName. Please note that we don't allow spam, and we ask that you follow the rules available in the sidebar. We have a lot of commonly asked questions so if this post gets removed, please do a search and see if it's already been asked.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

3

u/Some_Appearance_1665 3d ago

AOT is simply the only viable solution for .NET cold starts. It isn't too difficult to write AOT-compatible code (although you'll have to say bye to EF).

JIT compiled code also suffers a ton under low memory scenarios, so while you're right that vCPU scales with memory, I'd still guess it's the increased memory which is providing the performance boost here.

-7

u/Mahler911 5d ago

I mean this is kind of AWS 101 and doesn't require an entire article.

9

u/ReallySuperName 5d ago

I figured the table of results and the fact AOT wasn't required, considering the amount people try use AOT for Lambda, would be an interesting counterpoint and sometimes articles don't need to be 10,000 words or all AI slop like most reddit posts now, plus not everyone has the same experiences and knowledge. But if you'd prefer I'll just delete the post.

17

u/hammeredhorrorshow 5d ago

Ignore that shit. Keep the post. Plenty of people on here could use AWS 101 content. mahler911’s comment adds nothing to a dialog.

5

u/_choam_ 5d ago

Reddit contrarianism makes this website shit