SVS344: Modernizing .NET to Serverless: Native AOT and SnapStart, live.

Resources for SVS344: Modernizing .NET to Serverless: Native AOT and SnapStart, live.

Cold starts and JIT warmup have long made .NET on AWS Lambda a harder fit for serverless execution patterns. Native AOT and SnapStart on .NET 10 close that gap, but modernization isn't flip-a-switch. In this code talk we modernized a .NET function to Native AOT live, watched it fail, and fixed it on stage: serialization with source generators, reflection-based DI replaced, and trimming warnings resolved.

This page has the slides, plus documentation, blog posts, videos and tools for each topic of the talk.

Session code repository

GitHub repo

Sample code for the session: .NET Lambda cold start optimization with Native AOT and SnapStart.

Lambda SnapStart for .NET

Snapshots, priming and runtime hooks

Enabling SnapStart moves the JIT cost into the first invocation after a restore rather than removing it. Priming with runtime hooks is what delivers the win, and state captured at init needs care.

AWS Lambda Power Tuning

GitHub repo

Find the memory setting with the best cost or speed for a function. The benchmark harness from the session runs it against each variant.

Native AOT on .NET 10

Serialization, DI and trimming

Turning on PublishAot surfaced three failures: reflection-based serialization, reflection-based DI, and trimming warnings from the AWS SDK. Source-generated JsonSerializerContext, explicit DI registration and trim annotations fix them.

Related videos

Earlier sessions and talks

More on SnapStart for .NET, including the re:Invent 2024 session and ASP.NET Core pre-warming.

Presented by:

Doug Perkes

Doug Perkes

Senior Solutions Architect at AWS, focused on .NET and serverless.

Lasse Christiansen

Lasse Christiansen

Lasse is a Senior Solutions Architect with AWS.