Posts .NET Core Performance Best practices
Post
Cancel

.NET Core Performance Best practices

Recommendations

  • Do call all data access APIs asynchronously.
  • Do not retrieve more data than is necessary. Write queries to return just the data that’s necessary for the current HTTP request.
  • Do consider caching frequently accessed data retrieved from a database or remote service if slightly out-of-date data is acceptable. Depending on the scenario, use a MemoryCache or a DistributedCache. For more information, see Response caching in ASP.NET Core.
  • Do minimize network round trips. The goal is to retrieve the required data in a single call rather than several calls.
  • Do use no-tracking queries in Entity Framework Core when accessing data for read-only purposes. EF Core can return the results of no-tracking queries more efficiently.
  • Do filter and aggregate LINQ queries (with .Where, .Select, or .Sum statements, for example) so that the filtering is performed by the database.
  • Do consider that EF Core resolves some query operators on the client, which may lead to inefficient query execution. For more information, see Client evaluation performance issues.
  • Do not use projection queries on collections, which can result in executing “N + 1” SQL queries. For more information, see Optimization of correlated subqueries.
This post is licensed under CC BY 4.0 by the author.