## StackExchange.Redis ### General Guidance 1. **Set AbortConnect to false**, then let the ConnectionMultiplexer reconnect automatically. [See here for details](https://gist.github.com/JonCole/36ba6f60c274e89014dd#file-se-redis-setabortconnecttofalse-md) 2. **Reuse the ConnectionMultiplexer** - do not create a new one for each request. The `Lazy` pattern [shown here](https://azure.microsoft.com/en-us/documentation/articles/cache-dotnet-how-to-use-azure-redis-cache/#connect-to-the-cache) is strongly recommended. 3. **Configure your [ThreadPool settings](https://gist.github.com/JonCole/e65411214030f0d823cb#file-threadpool-md) to avoid timeouts**. 4. **Be aware of the performance costs associated with different operations** you are running. For instance, the "KEYS" command is an O(n) operation and should be avoided. The [redis.io site](http://redis.io/commands/) has details around the time complexity for each operation that it supports. 5. **Consider turning on ["Server GC"](https://msdn.microsoft.com/en-us/library/ms229357(v=vs.110).aspx)**. "Workstation GC" is the default and can impact the latencies when garbage collection is in happening. 6. **Most customers find that a single ConnectionMultiplexer is sufficient for their needs.** However, if you have high throughput requirements, you may consider slowly increasing the number of connections to see if you get an improvement in throughput. Avoid setting it to an arbitrarily large number of connections as it may not give the desired benefit. 7. **Configure supported TLS settings**. If you are targeting .NET 4.7 or later, you should not have to do anything because StackExchange.Redis will automatically use the OS level settings when deciding which TLS versions to support (which is a good thing in most cases). If you are targeting an older version of .NET, then you *should* configure the client to use the highest TLS version that your client system supports (typically TLS 1.2). Once you move to a newer version of the .NET framework, then you should probably remove this configuration and let the OS settings take precedence. This can configured through the [sslProtocols connection string entry](https://github.com/StackExchange/StackExchange.Redis/blob/master/docs/Configuration.md#configuration-options) (**requires NuGet package version 1.2.3 or later**), or through the ConfigurationOptions class as show here: >var options = ConfigurationOptions.Parse(connectionString); > >options.SslProtocols = System.Security.Authentication.SslProtocols.Tls12; > >ConnectionMultiplexer.Connect(options); ### Reconnecting with `Lazy` pattern We have seen [a few rare cases](https://github.com/StackExchange/StackExchange.Redis/issues/559) where StackExchange.Redis fails to reconnect after a connection blip (for example, due to patching). Restarting the client or creating a new ConnectionMultiplexer will fix the issue. [Here is some sample code](https://gist.github.com/JonCole/925630df72be1351b21440625ff2671f#file-redis-lazyreconnect-cs) that still uses the recommended `Lazy`pattern while allowing apps to force a reconnection periodically. Make sure to update code calling into the ConnectionMultiplexer so that they handle any `ObjectDisposedException` errors that occur as a result of disposing the old one.