Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
206 views
in Technique[技术] by (71.8m points)

c# - Redis TimeoutException

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?

question from:https://stackoverflow.com/questions/65899195/redis-timeoutexception

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...