"Knowledge has to be improved, challenged, and increased constantly, or it vanishes."

Archives

Archives / 2022 / February
  • Distributed Cache with SQL Server in ASP.Net Core application

    Performance is a key factor for any application, especially for web & mobile applications. Based on various research studies, it has been identified that high performing sites retain users than low performing sites. This means a poor performing site will have impact on the company’s business goals. So, Developers, be aware to make sure your applications are designed for faster response times.

    One of the aspects that affect the performance of an application is Caching. With caching, you store the frequently accessed data and store in some temporary storage, As a developer, you should carefully consider the various caching mechanisms and implement them in your applications.

    Caching in ASP.Net Application

    ASP.Net supports both In-Memory Cache and Distributed Cache. Let me illustrate the basic differences.

    In-Memory Cache

    In-Memory Cache, your application uses Server memory to store the cached data. This works perfectly if you have only one server. In today’s world, where you use cloud services and automatically scale your applications, all your servers need to access the cached data from a single source, and In-Memory cache will not help you here,

    Distributed Cache

    In distributed cache, the cached data is stored and shared across all servers. ASP.Net supports several types of distributed cache implementations such as SQL Server, Redis, NCache etc.

    In this article, I am going to demonstrate how to implement distributed cache with SQL Server. For the purpose of this demo, I created a .Net application using the template “ASP.Net Core Web App”. The screenshot of the app in solution explorer is given below.

    clip_image002