Home > Articles > Details

Performance Tuning Asp.net web app

Performance

  1. Make all your Classes Sealed in C# Asp.Net Core Application if no other classes are inheriting from these classes, this has some benefit
     Read More about Sealed Classes here.

    See the image below for a comparison Benchmark of using Sealed Classes vs Public Open Classes

    Benchmark of using Sealed Classes in Asp.Net
    Attributes: Benchmark by Nick Chapsas

  2. Use the.Include() in your Query to reduce database round trip.

    2. Big Websites like Amazon and IndieHacker.com might not be calling the database on publicly accessed web pages, instead, those are just static pages, generated or even heavily cached for fast access.

    - This is because users do not care whether data is stale or not. They do not even know if it is fresh data or not.
    - But users do really care about speed. They will notice if the page is slow or not. If it is slow they abandon the page which you don't want to happen.

    3. Make sure that you are only selecting columns that you need. Use LINQ include. Utilize redistributed cache. 

    4. Reduce the number of times you call the database 

    5. Reduce the size of product images to under 2000

    6. Combine javascript into one file, and reduce the number of requests.

    7. If you are using EF Core 7, look into TPT introduced in EF Core 7, this design avoids the round trip to the database when inserting into a parent table and need to use the primary key ID as a Foreign Key in other tables. What it does is insert a record into a child's table with respect to the Parent. 

     - Also look into using HiLow in the EF Core 6 to generate a sequence of IDs when inserting into the parent Table the Primary Key is already known. However, it is advised that you should be really careful when using HiLow, use it if you really need it.


    8. Optimize the Server Response time by installing Varnish Cache
        - Use response Caching if you can, be careful not to cache sensitive personal data

    9. Make sure you return the Cache period on all pages

Reference:

This article will explain how to tune performance when developing asp.net app, very interesting.


2. Sealed Classes


If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.


© 2022 - ErnesTech - Privacy