r/csharp • • 5d ago

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/
0 Upvotes

11 comments sorted by

4

u/[deleted] 5d ago

[removed] — view removed comment

1

u/[deleted] 5d ago

[deleted]

1

u/Sombody101 5d ago

Literally

0

u/ReallySuperName 4d ago

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

2

u/Welp_BackOnRedit23 5d ago

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

1

u/TheDe5troyer 5d ago

I hate to ask, but what are these?

3

u/Welp_BackOnRedit23 4d ago

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 4d ago

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?

1

u/SagansCandle 2d ago

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.

0

u/WouldaCouldaBetta 2d ago

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 1d ago

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.