ASP.NET Core Performance Tuning

Introduction

  1. Content that changes rarely (or is used very often) might be cached. Memory, file system, or external cache should be considered (depending on the situation).
  2. There should be no operations duplication where it is possible.
  3. Session-specific data should be stored on the client-side to save server memory (when possible).
  4. There should be as few database (or file system, or any other third-party system, like API etc.) queries as possible (ideal number is 1 or 0 per request).
  5. A database queries should be built it in a way that only the really required data (tables and columns) is selected.
  6. When it is possible, using of the nested queries, join operations, and other resource-intensive operations should be avoided (but usually nested query or join operation is much better than 2 separate queries).
  7. All the columns that are involved in the queries (used in a WHERE or an ORDER BY clauses) should have the corresponding indexes.
  8. Sometimes it is better to implement some logic on the database side (for example, using stored procedures feature). Sometimes the raw SQL queries should be used instead of Linq. Using database views (and corresponding Entity Framework Core entities) for data retrieval often gives good results too (for example, you can have the PopularArticle entity that is mapped to the corresponding database view, which is built using complicated SQL query).

The Database Side

The Web Application Side

Real Life Scenarios

Conclusions

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store