StackExchange.Redis memory leak when cluster becomes unreachable
I am trying to integrate StackExchange.Redis client into my solution to do request logging.
High availability is essential, so the logging component must survive network failures and potential redis cluster outages. Precision is less important, so I am using "Fire & Forget" mode.
To test network outage scenario I have created a test web app with the following code:
namespace WebApplication1
{
public static class Logger
{
private static readonly IDatabase _db;
static Logger()
{
var configurationOptions = new ConfigurationOptions();
configurationOptions.AbortOnConnectFail = false;
configurationOptions.ConnectRetry = 1;
configurationOptions.ConnectTimeout = 100;
configurationOptions.EndPoints.Add("test.example.com", 6379);
var redis = ConnectionMultiplexer.Connect(configurationOptions);
_db = redis.GetDatabase();
}
public static void Push()
{
_db.ListRightPush("key", "value", When.Always, CommandFlags.FireAndForget);
}
}
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
Logger.Push();
}
}
}
...and hit it with 50k requests using Apache Bench. After reaching 1.1GB working set, local IIS crashed.
This is not at all what I expect, given it is configured it to only retry once and timeout after 100ms.
Have I misconfigured it?
@ArnoldZokas did you ever figure this out?
My team is having what appears to be a similar problem using ElastiCache w/ Redis. When EC became inaccessible, the Windows Service ate up all of the memory and slowed everything else to a complete crawl.
@eudaimos no, haven't. Good luck and please post a solution if you find one.
We are having similar issues. The simplest reproduction is to shutdown the redis server and then run a client app that initializes redis via ConnectionMultiplexer.Connect (you don't even need to try to make other calls). Continuous leaking of memory occurs, at the rate of about 20MB per hour.
I am wondering whether the following fix in a separate branch is related:
https://github.com/deepakverma/StackExchange.Redis/commit/ab182e4ab7f8f01106f4a21dabd597c119f7ccbd
Is this still an issue after the race fix is in, e.g. with a current release?
Hi @NickCraver. I no longer have access to the environment to test this. Happy to close this issue if you are.