skip to Main Content

I’m pushing some data to a Redis instance from a console app every few seconds. This is roughly how I’m doing it:

            int foo = GetFoo();
            BigObject bar = GetBigObject();

            _cache.StringSet("Foo", JsonConvert.SerializeObject(foo));
            _cache.StringSet("Bar", JsonConvert.SerializeObject(bar));

but after a while I get an exception:

StackExchange.Redis.RedisTimeoutException: ‘Timeout performing SET
RtSignal-op (5000ms), inst: 0, qu: 0, qs: 0, aw: False, rs:
CompletePendingMessage, ws: Idle, in: 0, in-pipe: 5, out-pipe: 0,
serverEndpoint: Unspecified/localhost:5002, mgr: 9 of 10 available,
clientName: SVGD0083, IOCP: (Busy=0,Free=1000,Min=16,Max=1000),
WORKER: (Busy=3,Free=32764,Min=16,Max=32767), v: 2.0.593.37019 (Please
take a look at this article for some common client-side issues that
can cause timeouts:
https://stackexchange.github.io/StackExchange.Redis/Timeouts)’

In the linked to page there is a suggestion that the issue might be a result of Thread Theft and the solution is to include the following line:

ConnectionMultiplexer.SetFeatureFlag("preventthreadtheft", true);

The problem is that there doesn’t seem to exist a SetFeatureFlag method in .NET framework.

Any ideas?

2

Answers


  1. StackExchange.Redis is not part of the .net framework.

    _cache probably is the StackExchange.Redis.IDatabase object type.
    So, just add the line where you initialize redis support at your application – probably at startup.cs.

    Login or Signup to reply.
  2. What is the size of your objects? If JsonConvert.SerializeObject(foo) is returning a 500MB string, then yes: you’re going to have a bad day.

    Also, what else is the server doing? This needs a little digging at the server, but: the redis SLOWLOG command gives you information into long-running operations. If anything is taking serious time (I’d start to get twitchy at anything that takes more than say 10 milliseconds), then your server is essentially stalling, which needs to be investigated – but that’s not something the library can fix.

    If you’re talking to a far away server, you may want a larger timeout.

    Finally, I very much doubt that this particular scenario is related to thread-theft; if anything, that sounds like you’re clutching at straws (metaphorically). But if ConnectionMultiplexer.SetFeatureFlag doesn’t exist, you’re probably using an old library version. So: what library version are you using?

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