StackExchange / StackExchange.Redis

General purpose redis client
https://stackexchange.github.io/StackExchange.Redis/
Other
5.91k stars 1.51k forks source link

Timeout exception conecting Azure Cache for Redis from AppService #2748

Open llopezalonso opened 4 months ago

llopezalonso commented 4 months ago

We are experiencing timeouts with Redis when 10k request are sent by an appService to Redis.

Azure resources:

AppService Code:

Error shown in AppInsights:

Timeout awaiting response (outbound=67648KiB, inbound=328KiB, 5250ms elapsed, timeout is 5000ms), command=HGET, next: HGET MICLAVEBBDD, inst: 0, qu: 0, qs: 0, aw: False, bw: SpinningDown, rs: ReadAsync, ws: Idle, in: 65536, last-in: 14161, cur-in: 8719, sync-ops: 0, async-ops: 10008, serverEndpoint: XXXX.redis.cache.windows.net:6380, conn-sec: 385.31, aoc: 0, mc: 1/1/0, mgr: 9 of 10 available, clientName: wnRURURU0000D9(SE.Redis-v2.8.0.27420), IOCP: (Busy=0,Free=1000,Min=256,Max=1000), WORKER: (Busy=21,Free=32746,Min=256,Max=32767), POOL: (Threads=80,QueuedItems=835,CompletedItems=20361,Timers=17), v: 2.8.0.27420 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)

Any thoughts that can help us??

Ton of thanks

dehaaneric commented 4 months ago

We have the same challenges on the same stack. Running on Azure App Service with .NET 6 (and now 8) and REDIS. After almost 7 years now, we made the following learnings:

Some low hanging fruits:

llopezalonso commented 4 months ago

Ton of thanks for your response and your insights.

Regarding your comments:

Regarding the other comments:

Again, ton of thanks for your comments and ideas, we are stuck on this problem :(

NickCraver commented 4 months ago

What kind of sends are involved here? On the outbound we see 67648KiB which is quite a bit in queue on the ounbound side of the socket - is this storing very large keys?

llopezalonso commented 4 months ago

Thanks for your response @NickCraver

No, we are not storing large keys (aprox 13k values in the database and larger is 15kb)

NickCraver commented 4 months ago

@llopezalonso The outbound was 67648KiB, so even assuming 15KiB upper bound that's around 4,700 outbound keys being stored at once as a spike in traffic - does that sound like the intended behavior or fail a gut check?