Performance in .net MVC core application

Today we are living in the era of Internet, with the help of Internet we can easily access the data, communicate with each other, share our knowledge with outer world , boost our business and many more day to day task we can do easily using the Internet. The major things came in picture is performance and security on Internet as well as for our hosted applications on Internet.
If you are a Software Engineer or team of engineers wants to build an application then Performance and Security plays a major role.

Performance :- Performance of any application is the measure of how quickly and efficiently any application responses to any specific functionalities. It also includes the availability of the application and how friendly its access mechanism in context of Software Development.
It is one of the measure of any software product to accept or reject. Performance includes the number of computational resources consumptioned by any software application during a task, application responses during the heavy traffic and their load management stategies.
Performance also includes the Volume of transactions any application to be processed and Number of requests per second, number of transactions per second and number of page views per second.

Do's and Don'ts for increasing the Performance :-

  • Use Caching :- Caching is a technique in which we can store data temporarily and used it within a time so that it reduces the server call again and again and it helps to increase the application performance. There are mainly three types of caching that is Response Caching, In-Memory and Distributed caching.
  • Perform I/O calls Asynchronously :- Input output opeartions should be Asynchronous. In simple words we have limited resources and want to read a file using synchronous calls and if it is big enough then it will take time to execute main thread so that all other tasks gets blocked so we can read it Asynchronously and other threads will do other tasks as well.
  • Use Bundling and Minification :- Minification means minimize the files(CSS,JS,Bootstrap) and then bundle them together and send them in one go so it will reduce the number of Http requests for each file and load it faster.
  • Use Javascript at Last in page :- Always keep javascript at last in the page or body so that all the elements gets load and work properly.
  • Reduce the Image Sizes :- As we known Images are very large in size and it will take time to render and use the more bandwidth and degrade the performance so reducing the image size and keeping only required images will improve the performance.
  • Use Content Delivery Network :- CDN is a good choice for large size script files because it has multiple servers at different locations so it will deliver the content from nearest one and will increase the execution speed as well as performance of application.
  • Use Compression algorithms :- When you have large files to upload and download then use the compression techniques to reduce the content size and then use it.
  • Optimize the database queries :- It includes Query optimization that is try to filter data at database side and retrieved only required records.
  • Reduce the Network traffic using the stored procedures :- Use the strored procedures in code instead of in-ine queries and it will reduce the network traffic.
  • Reduce the number of Client-Server calls :- Build your application with good design techniques and reduced the Server calls as possible as. Use code reusability so that it will increase the memory as well as Application performance.
  • Remove unused and redundant Middile-ware components :- If your application has redundant functionalities using the Middile ware or we can say that for same functionality has been implemented by more than one Middileware then delete the redundant one and also that is not in used.
  • Minimize the custom Middile-ware components :- If possible then minimize the custom Middile-ware components because they are custom components and using in every Http request for checking a customised functionality (like Authentication and logging) every time so that it will increase the processing time of pipeline and due to that performance has extra overhead.
  • Use Dependency Injections :- If you are developing applications using ASP Core then use Dependency Injections. DI is the technique which provides the central access for services and their injcetion mechanism so that applications gets loosely coupled.
  • Minimize Exceptions :- It is bad practice to use Throw and catch for every logic because it will slow down the system performance.
  • Avoid Task.Wait and Task.Result :- Task.Wait will wait for the current thread to complete and block all the threads and system will be in deadlock mode most of the times then it is better to avoid them. Exception handling with this is very difficult.


Image is not available

About the Author
Sudheer Singh Chouhan is a Software Engineer having Expertise in Development Design and Architecting the applications , Project Management , Designing Large Scale Databases in SQL Server since last 17 Years.
Skill Sets :- Microsoft .NET technologies like ASP.Net Core, Web API, LINQ, Web Forms, WinForms, SQL Server, EntityFramework, Design Patterns, Solid Principles, Microservices, AWS Cloud.