Back to all posts

Updating to .NET 9 Has Benefits! Performance!

Posted on Dec 10, 2024

Posted in category:
Development
.NET

The .NET Support Cycle has been making the rounds within various online circles in recent months with such major changes each, and every, year introducing more burden on development teams that some organizations have been able to support.  I truly feel the pain of the updates with the large number of applications that I support it can be hard to keep up to date or make the decision as to when to update.

To this point, I had been a bit behind on my normal schedule of updating the day of release for a few of my key properties, including this website.  I've finally gotten around to doing my first batch of updates to .NET 9 and I have to say that the improvements in performance with nothing other than a few small tweaks has been impressive!

The Starting Point

Just as a point of reference, my current performance benchmarking has been for applications that are ASP.NET Core MVC running .NET 8, within Azure on App Services and Azure SQL.  These applications are all utilizing Entity Framework Core, and have data models and databases of various sizes from those with DB Contexts having under 20 tables to a few with tables in the mid-hundreds, with lots of backing data.

My baseline performance standard was focusing on a few key metrics.

  • Startup Performance - How long it takes from a cold start to the first response
  • "Feel" Performance  - How the application feels browsing as a regular user
  • Lighthouse performance standards (Mobile)

These applications all perform well, however, startup has been one of those areas that we were constantly looking at improving.

Basic Upgrades First

For the basic upgrade, I followed the standard steps of updating the runtime target to .NET 9.0 and updating all packages to the latest version. With no changes beyond this, I have realized the following average metrics across 10 upgraded applications.

  • Startup Performance - Improved by 23%
  • "Feel" performance - Very noticeable improvements, various tooling showing decent performance.
  • Lighthouse - Improved performance scores by an average of 15 points

Now, It should be noted that I did NOT for this test replace UseStaticFiles with the new MapStaticAssets process, so I may be able to see even more performance.

Supercharging with EF Core Changes

Entity Framework 9.0 was released with a number of key changes as well, including better native support for AzureSQL by simply changing the UseSqlServer method to UseAzureSql.  Additionally, there is much better support for the compilation/optimization of your DB context with a few small changes outlined in the linked changes.

For my applications, I took the first step, updating to support Azure SQL, and that provided another overall boost to my performance numbers with final results showing.

  • Startup Performance - Improved by 28%
  • "Feel" performance - Complex query performance substantially improved, request monitoring at the server level shows a 40-75% reduction in execution time for reports, dashboards, and other complex queries
  • Lighthouse - Improved performance scores by an average of 22 points

I stopped here with the initial round of updates, to ensure that I could do things quickly and with limited risks; I think there is more to come.

Next Steps & Thoughts

In the coming weeks, I will be working to implement Auto-Compiled models and continue to monitor the overall application performance to see how things trend.  I know how hard it is to justify constant updates, but quick-win performance improvements go a long way to helping customers see the value in what is being done and continue supporting updates.

Have you had a good experience updating?  I'd love to hear about it in the comments!