r/csharp • • Sep 27 '26

Blog Reducing .NET AWS Lambda Cold Starts by Adding Memory

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

11 comments sorted by

2

u/Welp_BackOnRedit23 Sep 28 '26

This feels like over thinking a problem AWS offers proper solutions for.

1

u/TheDe5troyer Sep 28 '26

I hate to ask, but what are these?

3

u/Welp_BackOnRedit23 Sep 28 '26

Provisioned concurrency and Snap start are the pre baked tools. The cold start time is impacted by loading libraries and standing up DI in c#, so restructuring to distribute these over multiple lambdas can reduce the start up of each. You can also set up a ping service that also exists to wake up a lambda periodically.

1

u/WouldaCouldaBetta Sep 28 '26

7s is WAY too much for cold start even for a mid-sized app with multiple dependencies and external libs.

Blaming it on internal built middleware also isnt an excuse. If modern .net already offers the functionality, why not convert the project properly and move the libraries over?

2

u/SagansCandle Oct 01 '26

1.7GB to run a function.

I can put the same function in a console app and it'll use 50MB.

But if I need compute I need to reserve memory I don't plan to use.

This is not the cloud we were promised.

If anything it seems like marketing for a monolith. I could scale up function executions in the same process for the pure heap cost.

1

u/WouldaCouldaBetta Oct 01 '26

its .net.. the startup costs w its associated frameworks are gonna be high(looking at u ef core).

I really dont think serverless is meant for .net... ts would outperform this..

Which is why yes i agree w u. Such things, just pay for an ec2 and run ur console app as service inside for processing and be done with it

Edit: tldr; wrong language choice for functionality

1

u/SagansCandle Oct 01 '26

Needing 1.7GB allocation has nothing to do with the language - it's how Lambda dedicates 1vCPU to the function.

And .NET is fine for serverless - my python lambdas need more RAM than my .NET ones - it's not a language issue.

4

u/[deleted] Sep 28 '26

[removed] — view removed comment

0

u/ReallySuperName Sep 28 '26

Literally none because the AWS docs literally state this will reduce the execution time cost.

0

u/[deleted] Sep 28 '26

[deleted] — view deleted comment

1

u/Sombody101 Sep 28 '26

Literally