skip to Main Content

To overcome latency, On “Startup.cs” of asp.net core 2.1, I am creating 2 static connections to Azure Redis & reuse those same connection instances during the application entire life cycle.
Is it is good practice to create multiple connections to one Azure redis instance? what is max. no. of connections? will multiple instance have billing implications? Is Azure redis usage charges based number of connections or as per the amount of data transfer? please confirm.

2

Answers


  1. First, it is not a good practice to create two Azure Redis static connections in the application.

    In general projects, Redis is not frequently used, but is instantiated and created when the business needs it, and released after use. If you need to use it frequently, you can instantiate it in Startup.cs when the project starts, and define an instance globally, so that there will be no frequent creation and deletion of instances.

    For Azure Redis billing methods, you can refer to the official documentation. It is not based on the number of connections nor the amount of transmission. It is billed according to time.

    Login or Signup to reply.
  2. It is actually recommend to use different connections to reflect the varying data packet sizes ie you could setup a connection with higher timeout for data that is bigger in size, as opposed to data that is small in size. This is recommended only when you have data packets being stored in redis of varying sizes ex: 1kb to 100 kb and you cannot reduce their size of the packet.

    Having different connection ensures that pipelining that usually happens when fetching data does not result in cascading timeouts. Multi connection is also recommended in Microsoft docs, have a look here by scrolling to the bottom and see point 3

    https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-troubleshoot-client#large-request-or-response-size

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search