• In the last few months, we have been facing many performances related issues on production servers and we have made many fixes/optimization of existing code. I have summarized all in the below listed points. I hope this will help you too.

    1. Detailed code review.

    The code written can itself tell you about how/what it can break on the server. It is very much important to do detailed code review of each and every related method /components when you are fixing any page performance.

    You should keep following points in mind while doing detailed code review.
    1. Review fewer than 400 lines of code at a time
    2. Use checklists
    3. Establish a process for fixing defects found
    4. Know What to Look for in Code Reviews
    5. Add comments before each lines you have understood

    2. Optimize queries.

    Most of the times, server performance degrades because of some long running queries are called. Many timeout cases happen because of non-index based/locking db queries are written.

    You should keep the following points in mind while checking such queries and optimize them.

    1. Avoid * in SELECT statement. Give the name of columns which you require. Selecting all the columns means more bandwidth/memory usage.

    2. Avoid like operations as much as possible.

    3. Use WITH (NOLOCK) while querying the data from any table.

    4. Create Clustered and Non-Clustered Indexes. Fix up query to use existing created indexes.

    5. Drop unused Indexes. It will speedup insertion and updation.

    6. Use joins instead of sub-queries.

    7. Use WHERE expressions to limit the size of result tables that are created with joins.

    8. Use SET NOCOUNT ON and use TRY- CATCH to avoid deadlock condition.

    9. Avoid Cursors since cursor are very slow in performance.

    10. Use Table variable in place of Temp table. Use of Temp tables required interaction with TempDb database which is a time taking task.

    11. Use UNION ALL instead of UNION if possible.

    12. Use Schema name before SQL objects name.

    13. Use Stored Procedure for frequently used data and more complex queries.

    14. Keep transaction as small as possible since transaction lock the processing tables data and may results into deadlocks.

    3. Use for loop instead of foreach.

    I will now explain a very interesting fact. I think all of you are familiar with both for and foreach loops. Now if I ask you which one is faster? Hmm... Don't know. Right? Guys, a for loop is much faster than a foreach loop. Let's look at the following example.

    List Count = new List();  
    List lst1 = new List();  
    List lst2 = new List();  
      
    for (int i = 0; i < 10000; i++)  
    {  
       Count.Add(i);  
    }  
      
     Stopwatch sw =new Stopwatch();  
     sw.Start();  
     for (int i = 0; i < Count.Count; i++)  
      {  
             lst1.Add(i);  
      }  
      sw.Stop();  
      
     Console.Write("For Loop :- "+ sw.ElapsedTicks+"\n");  
      sw.Restart();  
      
     foreach (int a in Count)  
    {  
         lst2.Add(a);  
     }  
    sw.Stop();  
    Console.Write("Foreach Loop: - " +  sw.ElapsedTicks);  
     Console.ReadLine();
    

    4. Sometimes it is easier to replace than to fix up.

    5. Optimize UI.
    1. Clean up the HTML
    2. Proper JavaScript Placement
    3. Optimize CSS Performance
    4. Reduce External HTTP Requests
    5. Minify CSS, JS and HTML
    6. Increase Speed with a CDN and Caching
    7. Compress Your Files
    8. Optimize Your Images

    6. Implement Caching, but carefully

    Caching enables you to store data in memory for rapid access. When the data is accessed again, applications can get the data from the cache instead of retrieving it from the original source. This can improve performance and scalability.

    Below are the advantages of implementing caching.
    1. Reduce the processing Time
    2. Reduce the Network Traffic
    3. Improve the Performance of web application
    4. Enhance the user Experience
    5. Lower Data used (Internet)
    6. Improve the site performance
    7. Large data management

    Note: It is important to know cache size limit for asp.net. Setting too large dataset into cache is equal to setting no cache!

    8. Start using a performance profiler

    Performance profilers are software development tools designed to help you analyze the performance of your applications and improve poorly performing sections of code. ... There are different ways to measure the performance of an application while it runs.

    A profiler can be used to understand code from a timing point of view, with the objective of optimizing it to handle various runtime conditions or various loads. Profiling results can be ingested by a compiler that provides profile-guided optimization.

    Red Gate ANTS Performance Profiler and ANTS Memory Profiler are another set of commercial tools that profile .NET executables, ASP.NET applications and Web services in IIS, IIS Express, and Web Development Server, SharePoint 2007 or 2010 collections, Silverlight applications, Windows services, and COM+ applications.

    Go through below link for how to use ANTS performance profiler.

    https://www.red-gate.com/products/dotnet-development/ants-performance-profiler/walkthrough

0 Years in
Operation
0 Loyal
Clients
0 Successful
Projects

Words from our clients

 

Tell Us About Your Project

We’ve done lot’s of work, Let’s Check some from here