It is always a delight to listen to David Fowler and Damian Edwards. Deep five into .NET performance and native AOT is my favorite session of this year’s Build.
Here are my quick notes from the talk:
(Talk was Based on .NET 8 preview binaries) These are still rough notes, and I need to groom them further.
- Evergreen advice- Upgrade the .NET version for free performance. You can also try this in interviews 😁
- If you are working with big API bodies, you should use streams and streaming operations. Stream the response instead of storing the whole response in a string.
- Handling Http APIs response - Using GetFromJsonAsync instead of GetStringAsync.
- Using ReadAsStreamAsync instead of ReadAsByteArrayAsync.
- YARP, the new reverse proxy in the .NET world, can be used in case we want to forward any 3rd party API requests directly to the front end (instead of first to our backend and then to Frontend).
- Turn off tracking in EF (AsNoTracking) if you are just querying (no updates).
- Key-set paging instead of offset paging: A where clause instead of skip for pagination by Using an indexed column for pagination.
- EF Compiled queries!!
- DB Context pooling!!
- Small but cool tip - You can name Windows Terminal tabs 🙏
- Minimal APIs can be faster than traditional MVC. Consider alternate approaches for perf.
- Native AOT - lots of limitations, but faster startup time (and small size). Let’s see how it comes out in November this year.
BTW, here is the official page on ASP.NET Core Performance articles
And here is the youtube video of the session: