title: Redis Cache Number of connected clients increasing
body: <p><a href="https://i.stack.imgur.com/9I9Pr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9I9Pr.png" alt="Azure Portal - Redis Cache - Max Connected Clients "></a></p>
  
  <p>I am developing a microservice architecture application where I am using a Redis Cache to cache frequently used information. The issue is that the number of connected clients is constantly increasing and I don't know why.</p>
  
  <p>I am accessing the Redis Cache from an ASP.NET Web API and a Web Job. The NuGet package used for connection is "StackExchange.Redis" (<a href="https://github.com/StackExchange/StackExchange.Redis" rel="nofollow noreferrer">https://github.com/StackExchange/StackExchange.Redis</a>).</p>
  
  <p>The way I am connecting to Redis in code is as follows:</p>
  
  <pre><code>connection = ConnectionMultiplexer.Connect(configurationOptions);
  connection.ConnectionFailed += ConnectionFailed;
  connection.ConnectionRestored += ConnectionRestored;
  connection.InternalError += InternalError;
  
  if (!connection.IsConnected)
  {
      //_traceSource.TraceWarning($"Connection to REDIS '{_endpointAddress}' was not established.");
  }
  
  database = connection.GetDatabase();
  
  return database;
  </code></pre>
  
  <p>In addition, I have implemented the Dispose() method to make sure that connections are disconnected properly:</p>
  
  <pre><code>public void Dispose()
  {
     connection?.Close(true);
  }
  </code></pre>