%3CLINGO-SUB%20id%3D%22lingo-sub-2022202%22%20slang%3D%22en-US%22%3EAzure%20Redis%20Timeouts%20-%20Server%20Side%20Issues%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2022202%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EOverview%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThere%20are%20many%20reasons%20that%20may%20cause%20timeouts%20on%20Redis%20client%20side%2C%20due%20to%20client%2C%20network%20or%20server%20side%20causes%2C%20and%20the%20error%20message%20also%20may%20differ%20based%20on%20Client%20library%20used.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ETimeouts%20in%20Azure%20Cache%20for%20Redis%20occurs%20on%20client%20side%20when%20client%20application%20cannot%20receive%20the%20response%20from%20Redis%20server%20side%20timely.%3CBR%20%2F%3EAnytime%2C%20when%20client%20application%20doesn%E2%80%99t%20receive%20response%20before%20one%20of%20the%20timeout%20value%20expire%2C%20a%20timeout%20will%20occur%20and%20will%20be%20logged%20on%20client%20application%20logs%20as%20Redis%20timeout%20error%20message.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThere%20are%20some%20causes%20on%20Azure%20Cache%20for%20Redis%20server%20or%20on%20the%20VM%20hosting%20it%2C%20that%20can%20also%20cause%20Redis%20timeouts%20on%20client%20side.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EIf%20the%20cause%20of%20the%20delay%20is%20on%20Server%20side%2C%20the%20client%20application%20will%20not%20receive%20the%20response%20from%20Redis%20server%20timely%20and%20a%20timeout%20may%20happen.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOrder%20by%20most%20common%20issues%2C%20below%20are%20the%20most%20common%20Server%20side%20causes%3A%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E1-%20Server%20Update%20%2F%20Patch%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E2-%20Long%20Running%20Commands%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E3-%20Server%20High%20CPU%20Load%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E4-%20Server%20High%20Memory%20Usage%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E5-%20Redis%20Server%20Bandwidth%20Limit%20Exceeded%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20Client%20or%20Network%20side%20Redis%20timeout%20causes%2C%20please%20see%20these%26nbsp%3B%3CFONT%20size%3D%223%22%3E%3CSPAN%3ETech%20Community%20articles%3A%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-paas-blog%2Fazure-redis-timeouts-client-side-issues%2Fba-p%2F2022203%22%20target%3D%22_blank%22%3EAzure%20Redis%20Timeouts%20-%20Client%20Side%20Issues%3C%2FA%3E%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-paas-blog%2Fazure-redis-timeouts-network-issues%2Fba-p%2F2022222%22%20target%3D%22_blank%22%3EAzure%20Redis%20Timeouts%20-%20Network%20Issues%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%20style%3D%22background-color%3A%20%230072c6%3B%20width%3A%20100%25%3B%22%20border%3D%221%22%20width%3D%22100%25%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22100%25%22%3E%3CFONT%20size%3D%224%22%20color%3D%22%23FFFFFF%22%3E%3CSTRONG%3E1-%20Server%20Update%20%2F%20Patch%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3EWhen%20any%20Redis%20Server%20update%20occurs%2C%20some%20Redis%20timeouts%20may%20happen%20on%20client%20side.%3CBR%20%2F%3EThis%20is%20expected%20and%20by%20design%20as%20described%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EStandard%2FPremium%20Tiers%20of%20Azure%20Cache%20for%20Redis%20are%20made%20up%20of%20two%20Redis%20nodes.%20Each%20node%20running%20a%20single%20Redis%20server%20process%20and%20having%20a%20dedicated%20VM.%3C%2FP%3E%0A%3CP%3EOne%20instance%20is%20the%20%22primary%22%20node%20and%20other%20is%20the%20%22replica%22%20node.%20The%20primary%20node%20replicates%20data%20to%20the%20replica%20node%20more%20or%20less%20continuously.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20the%20primary%20node%20goes%20down%26nbsp%3Bunexpectedly%2C%20the%20replica%20will%20promote%20itself%20to%20primary%2C%20typically%20within%2010-15%20seconds.%20When%20the%20old%20primary%20node%20comes%20back%20up%2C%20it%20will%20become%20a%20replica%20and%20replicate%20data%20from%20the%20current%20primary%20node.%3C%2FP%3E%0A%3CP%3EIn%20the%20case%20of%26nbsp%3Bany%20update%2Fpatch%2C%20replica%20is%20proactively%20promoted%20to%20primary%20and%20the%20client%20should%20be%20able%20to%20immediately%20reconnect%20without%20any%20significant%20delay.%3C%2FP%3E%0A%3CP%3EBasic%20tier%20cache%20has%20only%20one%20node%2C%20with%20no%20replica%20to%20take%20over%20during%20patching%2C%20so%20during%20update%2Fpatch%20the%20Basic%20tier%20Redis%20instances%20will%20go%20down%20and%20not%20be%20accessible%20during%20the%20patching%20process.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20one%20of%20the%20reasons%20why%20Basic%20caches%20are%20good%20for%20test%2Fdevelopment%20environments%20but%20not%20recommended%20for%20production.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3ERedis%20updates%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EOn%20Azure%20Redis%20service%2C%20there%20are%20three%20types%20of%20updates%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3ERedis%3C%2FSTRONG%3E%20updates%2Fpatches%20applied%20to%20the%20binaries%20used%20by%20Redis%20service%3B%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EHost%3C%2FSTRONG%3E%20updates%2Fpatches%20applied%20to%20each%20Redis%20node%20VM.%20%26nbsp%3BThe%20VM%20reboots%20after%20any%20Host%20update%3B%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EHost%20OS%3C%2FSTRONG%3E%20updates%2Fpatches%20applied%20to%20operating%20system%20used%20by%20each%20Redis%20node%20VM.%20The%20VM%20reboots%20after%20any%20Host%20OS%20update.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EIf%20Azure%20Redis%20is%20in%20a%20Standard%20or%20Premium%20Tier%2C%20Redis%20Updates%2Fpatches%2C%20Host%20OS%20or%20Guest%20OS%20updates%20should%20not%20have%20any%20impact%20on%20the%20Redis%20availability.%20%3CBR%20%2F%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3EFailover%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EEvery%20time%20a%20Redis%20Updates%2Fpatches%20occur%20an%20Redis%20failover%20is%20initiated.%3C%2FP%3E%0A%3CP%3EWhen%20the%20failover%20occurs%2C%20the%20current%20connections%20on%20the%20primary%20node%20will%20be%20broken%20and%20will%20timeout%20on%20client%20application%20side%20-%20this%20is%20expected.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20number%20of%20errors%20seen%20by%20the%20client%20application%20depends%20on%20how%20many%20operations%20were%20pending%20on%20that%20connection%20at%20the%20time%20of%20the%20failover.%3C%2FP%3E%0A%3CP%3EAny%20connection%20that's%20routed%20through%20the%20node%20that%20closed%20its%20connections%20will%20see%20errors.%3C%2FP%3E%0A%3CP%3EMany%20client%20libraries%20can%20throw%20different%20types%20of%20errors%20when%20connections%20break%2C%20including%20time-out%20exceptions%2C%20connection%20exceptions%2C%20or%20socket%20exceptions.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAll%20the%20process%20is%20described%20in%20this%20documentation%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-cache-for-redis%2Fcache-failover%23how-does-a-failover-affect-my-client-application%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EHow%20does%20a%20failover%20affect%20my%20client%20application%3F%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3E%3CSTRONG%3EHow%20to%20verify%20Server%20Updates%26nbsp%3Bor%20Patch%2C%26nbsp%3B%3C%2FSTRONG%3E%3CSTRONG%3Efrom%20client%20side%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3ECurrently%20there%20are%20no%20way%20to%20verify%20Redis%2C%20Host%20or%20Host%20OS%20updates%2Fpatches%20on%20client%20side%20or%20on%20Azure%20Portal.%20This%20is%20something%20currently%20in%20roadmap.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3E%3CSTRONG%3EHow%20to%20mitigate%20Server%20Updates%26nbsp%3Bor%20Patch%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EAs%20per%20Microsoft%20best%20practices%2C%20the%20application%20should%20retry%20to%20reconnect%20and%20when%20the%20retry%20happen%2C%20will%20reconnect%20to%20the%20new%20primary%20node%20without%20any%20impact%20on%20the%20service%20or%20to%20the%20end%20users.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3EStackexchange.Redis%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EStackexchange.Redis%20have%20retry%20policy%20configured%20by%20default.%20With%20that%20some%20timeouts%20may%20be%20seen%20on%20client%20side%2C%20but%20with%20client%20retry%20policy%2C%20Redis%20service%20should%20be%20always%20available.%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EStackExchange.Redis%20client%20library%20has%20a%20setting%20named%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BAbortConnect%26nbsp%3Bthat%20controls%20how%20it%20handles%20connectivity%20errors%20like%20this.%20The%20default%20value%20for%20this%20setting%20is%20%22True%22%2C%20meaning%20that%20it%26nbsp%3Bwill%20not%26nbsp%3Breconnect%20automatically%20in%20some%20cases.%20Microsoft%20recommendation%26nbsp%3Bis%20to%20set%20AbortConnect%20to%20false%2C%20to%20let%20the%20ConnectionMultiplexer%20reconnect%20automatically.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EScheduling%20Redis%20updates%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ECurrently%20there%E2%80%99s%20feature%20available%20to%20allows%20schedule%20Redis%20updates.%20However%2C%20it%20does%20not%20cover%20platform%20updates%20(host%20or%20host%20OS%20updates)%2C%20which%20happen%20much%20more%20often.%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ESo%20at%20the%20moment%2C%20it%E2%80%99s%20not%20possible%20to%20specify%20the%20update%20time%20for%20all%20types%20of%20updates.%3CBR%20%2F%3EPlease%20see%20this%20documentation%20showing%20how%20to%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-cache-for-redis%2Fcache-administration%23schedule-updates%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3ESchedule%20updates%3C%2FSPAN%3E%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%20style%3D%22background-color%3A%20%230072c6%3B%20width%3A%20100%25%3B%22%20border%3D%221%22%20width%3D%22100%25%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22100%25%22%3E%3CFONT%20size%3D%224%22%20color%3D%22%23FFFFFF%22%3E%3CSTRONG%3E2-%20Long%20Running%20Commands%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3ESome%20commands%20are%20more%20expensive%20than%20others%20to%20execute%2C%20depending%20on%20their%20complexity.%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EBecause%20Redis%20is%20a%20%3C%2FSPAN%3E%3CSPAN%3Esingle-threaded%20server%20side%20system%2C%20t%3C%2FSPAN%3E%3CSPAN%3Ehe%20time%20needed%20to%20run%20some%20more%20time%20expensive%20commands%20may%20cause%20some%20latency%20or%20timeouts%20on%20client%20side%2C%20as%20server%20can%20be%20busy%20dealing%20with%20these%20expensive%20commands.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBased%20on%20Redis.io%20documentation%20there%20are%20some%20well-known%20commands%20with%20higher%20time%20complexity%2C%20as%20described%20on%20top%20of%20each%20command%20description%2C%20on%20Redis.io%20page.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22LuisFilipe_3-1609435653931.png%22%20style%3D%22width%3A%20502px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F243589i57D4B9308E90BBDB%2Fimage-dimensions%2F502x121%3Fv%3D1.0%22%20width%3D%22502%22%20height%3D%22121%22%20role%3D%22button%22%20title%3D%22LuisFilipe_3-1609435653931.png%22%20alt%3D%22LuisFilipe_3-1609435653931.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ETime%20complexities%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EO(1)%20-%20the%20command%20will%20be%20applied%20to%20only%20one%20specific%20key.%3C%2FP%3E%0A%3CP%3EO(N)%20-%20with%20N%20being%20the%20number%20of%20keys%20in%20the%20database%20-%20this%20means%20the%20command%20will%20be%20applied%20to%20(or%20will%20read)%20each%20one%20of%20keys%20in%20the%20database%20-%20these%20commands%20should%20be%20avoided%20to%20use.%20When%20that%20is%20not%20possible%2C%20these%20type%20of%20commands%20should%20be%20used%20carefully.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThese%20types%20of%20complex%20commands%20should%20be%20avoided%2C%20as%20described%20here%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-cache-for-redis%2Fcache-troubleshoot-server%23long-running-commands%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-cache-for-redis%2Fcache-troubleshoot-server%23long-running-commands%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlso%2C%20Eval%20commands%20used%20to%20run%20LUA%20scripts%20on%20Redis%20side%20may%20need%20some%20time%20to%20finish.%3C%2FP%3E%0A%3CP%3EBecause%20Redis%20command%20processing%20is%20single-threaded%2C%20a%20command%20that%20takes%20time%20to%20run%20will%20block%20all%20others%20that%20come%20after.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EHow%20to%20verify%20Long%20Running%20Commands%2C%20from%20client%20side%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ERedis-cli%20command%20line%20console%20can%20be%20used%20to%20run%20the%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BSlowLog%20command%2C%20to%20measure%20expensive%20commands%20being%20executed%20against%20the%20server.%20%3C%2FSPAN%3E%3CSPAN%3EThis%20command%20is%20used%20to%20read%20or%20reset%20the%20Redis%20slow%20queries%20log%2C%20and%20the%20output%20is%20shown%20in%20microseconds.%20More%20information%20about%20SlowLog%20command%3A%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fredis.io%2Fcommands%2Fslowlog%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%3CSPAN%3Ehttps%3A%2F%2Fredis.io%2Fcommands%2Fslowlog%3C%2FSPAN%3E%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlso%2C%20%E2%80%9CMax%20CPU%22%20and%20%E2%80%9CServer%20Load%22%20metrics%20on%20Azure%20Portal%20can%20be%20used%20to%20see%20how%20much%20server-side%20bandwidth%20is%20being%20used%2C%20usually%20corelated%20to%20long-running%20commands%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22LuisFilipe_2-1609435606972.png%22%20style%3D%22width%3A%20724px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F243588i3A990FE30BE84BE9%2Fimage-dimensions%2F724x381%3Fv%3D1.0%22%20width%3D%22724%22%20height%3D%22381%22%20role%3D%22button%22%20title%3D%22LuisFilipe_2-1609435606972.png%22%20alt%3D%22LuisFilipe_2-1609435606972.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFor%20that%2C%20%3CSTRONG%3EMax%3C%2FSTRONG%3E%20aggregation%20should%20be%20used%20on%20the%20chart.%3CBR%20%2F%3E%E2%80%9CMax%20CPU%22%20and%20%E2%80%9CServer%20Load%22%20metrics%20are%20available%20to%20the%20Redis%20instance%20or%20per%20shard%2C%20in%20case%20of%20Redis%20clustered%20instances.%20On%20that%20case%20you%20may%20need%20to%20investigate%20each%20shard%26nbsp%3B%20%E2%80%9CMax%20CPU%22%20and%20%E2%80%9CServer%20Load%22%20usage%20to%20be%20able%20to%20identify%20any%26nbsp%3Boverload%20specifically%26nbsp%3Bin%20some%20shard.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EHow%20to%20mitigate%20Long%20Running%20Commands%20running%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ETo%20avoid%20having%20long%20running%20commands%2C%20time%20complex%20commands%20should%20be%20avoided%20and%20replaced%20by%20O(1)%20time%20complexity%20commands.%3C%2FP%3E%0A%3CP%3EFor%20instance%2C%20the%26nbsp%3BKEYS%26nbsp%3Bcommand%20is%20often%20used%20without%20knowing%20that%20it's%20an%20O(N)%20operation.%20Avoid%20KEYS%20can%20be%20done%20doing%20some%20more%20requests%20using%26nbsp%3BSCAN%26nbsp%3BO(1)%20to%20reduce%20CPU%20spikes.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlso%2C%20complex%20scripts%20should%20be%20reviewed%20to%20understand%20their%20performance%20impacts%2C%20and%20replaced%20by%20simple%20scripts.%20Having%20many%20simple%20scripts%20are%20preferable%20as%20having%20only%20few%20complex%20scripts.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%20style%3D%22background-color%3A%20%230072c6%3B%20width%3A%20100%25%3B%22%20border%3D%221%22%20width%3D%22100%25%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22100%25%22%3E%3CFONT%20size%3D%224%22%20color%3D%22%23FFFFFF%22%3E%3CSTRONG%3E3-%20Server%20High%20CPU%20Load%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3EHigh%20server%20load%20or%20CPU%20usage%20means%20the%20server%20can't%20process%20requests%20in%20time.%26nbsp%3BThe%20server%20may%20be%20slow%20to%20respond%20and%20unable%20to%20keep%20up%20with%20request%20rates.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20server%20takes%20more%20time%20to%20respond%20as%20expected%2C%20this%20not%20means%20forcibly%20an%20issue%20on%20Server%20performance.%20Specially%20on%20Standard%20and%20Premium%20Redis%20tiers%2C%20Redis%20service%20have%20a%20dedicated%20VM%20with%20full%20resources%20available%20to%20Redis%20service%2C%20on%20each%20Redis%20node%3A%20primary%20and%20replica.%26nbsp%3B%3CBR%20%2F%3EIf%20something%20wrong%20is%20detected%20on%20primary%20node%2C%20failover%20happen%20and%20the%20replica%20node%20can%20be%20promoted%20to%20new%20primary%20and%20take%20care%20of%20all%20work%20requested%20by%20client%20application.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUsually%2C%26nbsp%3Bserver%20taking%20more%20time%20to%20respond%20than%20the%20expected%20are%20caused%20by%20client%20application%20requesting%20long-running%20commands%20or%20scripts%2C%20using%20large%20key%20values%20or%20using%20a%20cache%20size%20tier%20lower%20than%20the%20needed%20to%20deal%20with%20all%20the%20work%20requested%20by%20client%20application.%3CBR%20%2F%3EAlso%2C%20high%20memory%20pressure%20can%20cause%20high%20number%20of%20page%20faults%2C%20and%20managing%20page%20faults%20can%20cause%20high%20CPU%20usage%20on%20Server%20side.%20Please%20see%20below%20on%20topic%204%20how%20to%20investigate%26nbsp%3Bhigh%20memory%20pressure%20on%20Server%20side.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3E%3CSTRONG%3EHow%20to%20verify%20High%20Server%20CPU%20usage%2C%20from%20client%20side%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EThe%20%E2%80%9CCPU%22%20or%20%E2%80%9CServer%20Load%22%20metrics%20on%20Azure%20Portal%20can%20be%20used%20to%20find%20CPU%20usage%20and%20Server%20load.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22CPU%2C%20Server%20Load.PNG%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F243788iE7EE9B36B5D5D190%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22CPU%2C%20Server%20Load.PNG%22%20alt%3D%22CPU%2C%20Server%20Load.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EFor%20that%2C%20%3CSTRONG%3EMax%3C%2FSTRONG%3E%20aggregation%20should%20be%20used%20on%20the%20chart.%3CBR%20%2F%3E%E2%80%9CCPU%22%20or%20%E2%80%9CServer%20Load%22%20metrics%20are%20available%20to%20the%20Redis%20instance%20or%20per%20shard%2C%20in%20case%20of%20Redis%20clustered%20instances.%20On%20that%20case%20you%20may%20need%20to%20investigate%20each%20shard%20individually%26nbsp%3Bto%20identify%20high%20%E2%80%9CCPU%22%20or%20%E2%80%9CServer%20Load%22%20in%20some%20specific%20shard.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3E%3CSTRONG%3EHow%20to%20mitigate%20High%20Server%20CPU%20usage%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22sxs-lookup%22%3E%3CSPAN%20data-stu-id%3D%226140b-133%22%3EThere%20are%20several%20changes%20you%20may%20make%20to%20mitigate%20high%20server%20load%3A%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%20class%3D%22sxs-lookup%22%3E%3CSPAN%20data-stu-id%3D%226140b-134%22%3EInvestigate%20long%20running%20commands%20used%20as%20described%20above%20on%20topic%202.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%20class%3D%22sxs-lookup%22%3E%3CSPAN%20data-stu-id%3D%226140b-136%22%3EScale%20to%20a%20larger%20cache%20size%20with%20more%20CPU%20capacity.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%20class%3D%22sxs-lookup%22%3E%3CSPAN%20data-stu-id%3D%226140b-135%22%3ECreate%20alerts%20on%20metrics%20like%20CPU%20or%20server%20load%20to%20be%20notified%20early%20about%20potential%20impacts.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%20style%3D%22background-color%3A%20%230072c6%3B%20width%3A%20100%25%3B%22%20border%3D%221%22%20width%3D%22100%25%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22100%25%22%3E%3CFONT%20size%3D%224%22%20color%3D%22%23FFFFFF%22%3E%3CSTRONG%3E4-%20Server%20High%20Memory%20Usage%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3EMemory%20pressure%20on%20the%20server%20side%20may%20cause%20some%20kinds%20of%20performance%20issues%20that%20can%20delay%20processing%20of%20requests%2C%20and%20when%20memory%20pressure%20occurs%2C%20the%20system%20may%20page%20data%20to%20disk.%3C%2FP%3E%0A%3CP%3EThis%26nbsp%3Bpage%20faulting%26nbsp%3Bcauses%20the%20system%20to%20slow%20down%20significantly.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20are%20some%20possible%20causes%20of%20this%20memory%20pressure%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20cache%20is%20filled%20with%20data%20near%20its%20maximum%20capacity.%3C%2FLI%3E%0A%3CLI%3ERedis%20is%20seeing%20high%20memory%20fragmentation.%20This%20fragmentation%20is%20most%20often%20caused%20by%20storing%20large%20objects%2C%20since%20Redis%20is%20optimized%20for%20small%20objects.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3E%3CSTRONG%3EHow%20to%20verify%20High%20Server%20Memory%20usage%2C%20from%20client%20side%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20%E2%80%9Cused_memory%22%20and%20%22used_memory_rss%22%20metrics%20on%20Azure%20Portal%20can%20be%20used%20to%20see%20how%20much%20memory%20is%20being%20used%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22LuisFilipe_0-1609762172295.png%22%20style%3D%22width%3A%20711px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F243795iC2B2EA36818E227B%2Fimage-dimensions%2F711x374%3Fv%3D1.0%22%20width%3D%22711%22%20height%3D%22374%22%20role%3D%22button%22%20title%3D%22LuisFilipe_0-1609762172295.png%22%20alt%3D%22LuisFilipe_0-1609762172295.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EFor%20that%2C%20%3CSTRONG%3EMax%3C%2FSTRONG%3E%20aggregation%20should%20be%20used%20on%20the%20chart.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAny%20Redis%20console%20can%20be%20used%20to%20run%20%3CSTRONG%3EInfo%3C%2FSTRONG%3E%20command.%20This%20command%20may%20be%20used%20to%20identify%20memory%20usage%20looking%20for%20%22%3CSTRONG%3EUsed%20Memory%3C%2FSTRONG%3E%22%20and%20%22%3CSTRONG%3EUsed%20Memory%20RSS%3C%2FSTRONG%3E%E2%80%9C%20section%20in%20the%20command%20output.%20Please%20see%20more%20about%20using%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fredis.io%2Fcommands%2Finfo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EInfo%20command%3C%2FA%3E.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3E%3CSTRONG%3EHow%20to%20mitigate%20High%20Server%20Memory%20usage%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EThere%20are%20several%20possible%20changes%20to%20help%20keep%20memory%20usage%20healthy%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EConfigure%20a%20memory%20policy%26nbsp%3Band%20set%20expiration%20time%20on%20keys%20-%20this%20policy%20may%20not%20be%20sufficient%20if%20having%20fragmentation.%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3EThe%20default%20eviction%20policy%20is%20volatile-lru%20-%20this%20evict%20keys%20by%20trying%20to%20remove%20the%20less%20recently%20used%20(LRU)%20keys%20first%2C%20but%20only%20the%20keys%20that%20have%20an%26nbsp%3Bexpire%20set.%20so%2C%20using%26nbsp%3Bvolatile-lru%2C%20set%20expiration%20time%20on%20keys%20is%20highly%20recommended.%3C%2FLI%3E%0A%3CLI%3EConfigure%20a%20%3CSTRONG%3Emaxmemory-reserved%3C%2FSTRONG%3E%20and%20%3CSTRONG%3Emaxfragmentationmemory-reserved%3C%2FSTRONG%3E%20value%20this%20should%20be%20large%20enough%20to%20compensate%20for%20memory%20fragmentation.%20Microsoft%20recommendation%20is%20to%20use%205%25%20of%20the%20size%20of%20the%20cache%20(or%20higher)%20to%20each%20one%20of%20these%20reserved%20values%2C%20when%20using%20large%20key%20sizes.%3CBR%20%2F%3EFor%20the%20points%20above%2C%20please%20see%20how%20to%20%3CFONT%20size%3D%223%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-cache-for-redis%2Fcache-configure%23memory-policies%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EConfigure%26nbsp%3BMemory%20Policies%3C%2FA%3E.%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3EReview%20client%20application%20logic%20and%20split%20large%20cached%20objects%20into%20smaller%20objects.%3C%2FLI%3E%0A%3CLI%3EScale%20to%20a%20larger%20cache%20size%20with%20more%20memory%20capacity.%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%20class%3D%22sxs-lookup%22%3E%3CSPAN%20data-stu-id%3D%226140b-135%22%3ECreate%20alerts%20on%20metrics%20like%26nbsp%3Bused_memory%20and%2For%20used_memory_rss%20to%20be%20notified%20early%20about%20potential%20impacts.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%20style%3D%22background-color%3A%20%230072c6%3B%20width%3A%20100%25%3B%22%20border%3D%221%22%20width%3D%22100%25%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22100%25%22%3E%3CFONT%20size%3D%224%22%20color%3D%22%23FFFFFF%22%3E%3CSTRONG%3E5-%20Redis%20Server%20Bandwidth%20Limit%20Exceeded%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3ERedis%20Server%20Network%20Bandwidth%20exceeded%20and%20some%20other%20network%20causes%20for%20Redis%20timeouts%20are%20explained%20on%20this%20Tech%20Community%20article%3A%26nbsp%3B%3CSTRONG%3E%3CA%20id%3D%22link_9%22%20class%3D%22page-link%20lia-link-navigation%20lia-custom-event%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-paas-blog%2Fazure-redis-timeouts-network-issues%2Fba-p%2F2022222%22%20target%3D%22_blank%22%3EAzure%20Redis%20Timeouts%20-%20Network%20Issues%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3E%3CSTRONG%3EConclusion%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EDespite%20having%20different%20reasons%20to%20have%20Redis%20timeouts%20on%20connections%20to%20Azure%20Cache%20for%20Redis%2C%20some%20different%20causes%20on%20Client%2C%20Server%20or%20Network%20side%20can%20cause%20Redis%20timeouts.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20Client%20or%20Network%20side%20Redis%20timeout%20causes%2C%20please%20see%20these%26nbsp%3B%3CFONT%20size%3D%223%22%3E%3CSPAN%3ETech%20Community%20articles%3A%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-paas-blog%2Fazure-redis-timeouts-client-side-issues%2Fba-p%2F2022203%22%20target%3D%22_blank%22%3EAzure%20Redis%20Timeouts%20-%20Client%20Side%20Issues%3C%2FA%3E%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-paas-blog%2Fazure-redis-timeouts-network-issues%2Fba-p%2F2022222%22%20target%3D%22_blank%22%3EAzure%20Redis%20Timeouts%20-%20Network%20Issues%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3E%3CSTRONG%3ERelated%20documentation%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-cache-for-redis%2Fcache-troubleshoot-timeouts%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ETimeout%20issues%3C%2FA%3E%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%3CA%20href%3D%22https%3A%2F%2Fredis.io%2Fcommands%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ERedis%20commands%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%3CSPAN%20class%3D%22sxs-lookup%22%3E%3CSPAN%20data-stu-id%3D%226140b-136%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-cache-for-redis%2Fcache-how-to-scale%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%20data-linktype%3D%22relative-path%22%3EHow%20to%20Scale%20Azure%20Cache%20for%20Redis%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-cache-for-redis%2Fcache-how-to-monitor%23alerts%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECreating%20Alerts%20on%20Azure%3C%2FA%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1-%20Server%20Update%20%2F%20Patch%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-cache-for-redis%2Fcache-failover%23how-does-a-failover-affect-my-client-application%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EHow%20does%20a%20failover%20affect%20my%20client%20application%3F%3C%2FA%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-cache-for-redis%2Fcache-administration%23schedule-updates%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESchedule%20updates%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E2-%20Long%20Running%20Commands%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CFONT%20size%3D%223%22%3E%3CA%20href%3D%22https%3A%2F%2Fredis.io%2Fcommands%2Fslowlog%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ESlowlog%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CFONT%20size%3D%223%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpt-pt%2Fazure%2Fazure-cache-for-redis%2Fcache-troubleshoot-server%23long-running-commands%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ELong-running%20Commands%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E3-%20Server%20High%20CPU%20Load%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CFONT%20size%3D%223%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-cache-for-redis%2Fcache-troubleshoot-server%23high-cpu-usage-or-server-load%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EHigh%20CPU%20or%20Server%20Load%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E4-%20Server%20High%20Memory%20Usage%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CFONT%20size%3D%223%22%3E%3CA%20href%3D%22https%3A%2F%2Fredis.io%2Ftopics%2Flru-cache%23eviction-policies%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EEviction%20policies%3C%2FA%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-cache-for-redis%2Fcache-configure%23memory-policies%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EConfigure%26nbsp%3BMemory%20Policies%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CFONT%20size%3D%223%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-cache-for-redis%2Fcache-troubleshoot-server%23memory-pressure-on-redis-server%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMemory%20pressure%20Server-side%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%3CA%20href%3D%22https%3A%2F%2Fredis.io%2Fcommands%2Finfo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EInfo%20command%3C%2FA%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20hope%20this%20can%20be%20useful%20!!!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2022202%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Azure%20Redis%20Timeouts%20-%20Server%20Side%20Issues.png%22%20style%3D%22width%3A%20543px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F243464i158101AB2C1622A4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Azure%20Redis%20Timeouts%20-%20Server%20Side%20Issues.png%22%20alt%3D%22Azure%20Redis%20Timeouts%20-%20Server%20Side%20Issues.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2022202%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Cache%20for%20Redis%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20Redis%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

 

Overview

There are many reasons that may cause timeouts on Redis client side, due to client, network or server side causes, and the error message also may differ based on Client library used.

 

Timeouts in Azure Cache for Redis occurs on client side when client application cannot receive the response from Redis server side timely.
Anytime, when client application doesn’t receive response before one of the timeout value expire, a timeout will occur and will be logged on client application logs as Redis timeout error message.

 

There are some causes on Azure Cache for Redis server or on the VM hosting it, that can also cause Redis timeouts on client side. If the cause of the delay is on Server side, the client application will not receive the response from Redis server timely and a timeout may happen.

 

Order by most common issues, below are the most common Server side causes: 

1- Server Update / Patch
2- Long Running Commands
3- Server High CPU Load

4- Server High Memory Usage

5- Redis Server Bandwidth Limit Exceeded

   

For Client or Network side Redis timeout causes, please see these Tech Community articles:

Azure Redis Timeouts - Client Side Issues
Azure Redis Timeouts - Network Issues

 

 

1- Server Update / Patch

When any Redis Server update occurs, some Redis timeouts may happen on client side.
This is expected and by design as described below.

 

Standard/Premium Tiers of Azure Cache for Redis are made up of two Redis nodes. Each node running a single Redis server process and having a dedicated VM.

One instance is the "primary" node and other is the "replica" node. The primary node replicates data to the replica node more or less continuously.

 

If the primary node goes down unexpectedly, the replica will promote itself to primary, typically within 10-15 seconds. When the old primary node comes back up, it will become a replica and replicate data from the current primary node.

In the case of any update/patch, replica is proactively promoted to primary and the client should be able to immediately reconnect without any significant delay.

Basic tier cache has only one node, with no replica to take over during patching, so during update/patch the Basic tier Redis instances will go down and not be accessible during the patching process. 

This is one of the reasons why Basic caches are good for test/development environments but not recommended for production.

 

Redis updates:

On Azure Redis service, there are three types of updates:

  • Redis updates/patches applied to the binaries used by Redis service;
  • Host updates/patches applied to each Redis node VM.  The VM reboots after any Host update;
  • Host OS updates/patches applied to operating system used by each Redis node VM. The VM reboots after any Host OS update.

If Azure Redis is in a Standard or Premium Tier, Redis Updates/patches, Host OS or Guest OS updates should not have any impact on the Redis availability.
 

Failover:

Every time a Redis Updates/patches occur an Redis failover is initiated.

When the failover occurs, the current connections on the primary node will be broken and will timeout on client application side - this is expected.

 

The number of errors seen by the client application depends on how many operations were pending on that connection at the time of the failover.

Any connection that's routed through the node that closed its connections will see errors.

Many client libraries can throw different types of errors when connections break, including time-out exceptions, connection exceptions, or socket exceptions.

 

All the process is described in this documentation: How does a failover affect my client application?

 

 

How to verify Server Updates or Patch, from client side:

Currently there are no way to verify Redis, Host or Host OS updates/patches on client side or on Azure Portal. This is something currently in roadmap.

 

How to mitigate Server Updates or Patch:

As per Microsoft best practices, the application should retry to reconnect and when the retry happen, will reconnect to the new primary node without any impact on the service or to the end users.

 

Stackexchange.Redis:

Stackexchange.Redis have retry policy configured by default. With that some timeouts may be seen on client side, but with client retry policy, Redis service should be always available.

StackExchange.Redis client library has a setting named AbortConnect that controls how it handles connectivity errors like this. The default value for this setting is "True", meaning that it will not reconnect automatically in some cases. Microsoft recommendation is to set AbortConnect to false, to let the ConnectionMultiplexer reconnect automatically.

 

Scheduling Redis updates:

Currently there’s feature available to allows schedule Redis updates. However, it does not cover platform updates (host or host OS updates), which happen much more often.

So at the moment, it’s not possible to specify the update time for all types of updates.
Please see this documentation showing how to
Schedule updates

 

 

2- Long Running Commands

Some commands are more expensive than others to execute, depending on their complexity.

Because Redis is a single-threaded server side system, the time needed to run some more time expensive commands may cause some latency or timeouts on client side, as server can be busy dealing with these expensive commands.

 

Based on Redis.io documentation there are some well-known commands with higher time complexity, as described on top of each command description, on Redis.io page.

LuisFilipe_3-1609435653931.png

 

Time complexities:

O(1) - the command will be applied to only one specific key.

O(N) - with N being the number of keys in the database - this means the command will be applied to (or will read) each one of keys in the database - these commands should be avoided to use. When that is not possible, these type of commands should be used carefully.

 

These types of complex commands should be avoided, as described here:

https://docs.microsoft.com/en-us/azure/azure-cache-for-redis/cache-troubleshoot-server#long-running-...

 

Also, Eval commands used to run LUA scripts on Redis side may need some time to finish.

Because Redis command processing is single-threaded, a command that takes time to run will block all others that come after.

 

How to verify Long Running Commands, from client side:

Redis-cli command line console can be used to run the SlowLog command, to measure expensive commands being executed against the server. This command is used to read or reset the Redis slow queries log, and the output is shown in microseconds. More information about SlowLog command: https://redis.io/commands/slowlog

 

Also, “Max CPU" and “Server Load" metrics on Azure Portal can be used to see how much server-side bandwidth is being used, usually corelated to long-running commands:

LuisFilipe_2-1609435606972.png

For that, Max aggregation should be used on the chart.
“Max CPU" and “Server Load" metrics are available to the Redis instance or per shard, in case of Redis clustered instances. On that case you may need to investigate each shard  “Max CPU" and “Server Load" usage to be able to identify any overload specifically in some shard.

 

How to mitigate Long Running Commands running:

To avoid having long running commands, time complex commands should be avoided and replaced by O(1) time complexity commands.

For instance, the KEYS command is often used without knowing that it's an O(N) operation. Avoid KEYS can be done doing some more requests using SCAN O(1) to reduce CPU spikes.

 

Also, complex scripts should be reviewed to understand their performance impacts, and replaced by simple scripts. Having many simple scripts are preferable as having only few complex scripts.

 

 

3- Server High CPU Load

High server load or CPU usage means the server can't process requests in time. The server may be slow to respond and unable to keep up with request rates.

 

When server takes more time to respond as expected, this not means forcibly an issue on Server performance. Specially on Standard and Premium Redis tiers, Redis service have a dedicated VM with full resources available to Redis service, on each Redis node: primary and replica. 
If something wrong is detected on primary node, failover happen and the replica node can be promoted to new primary and take care of all work requested by client application.

 

Usually, server taking more time to respond than the expected are caused by client application requesting long-running commands or scripts, using large key values or using a cache size tier lower than the needed to deal with all the work requested by client application.
Also, high memory pressure can cause high number of page faults, and managing page faults can cause high CPU usage on Server side. Please see below on topic 4 how to investigate high memory pressure on Server side.

 

How to verify High Server CPU usage, from client side:

The “CPU" or “Server Load" metrics on Azure Portal can be used to find CPU usage and Server load.

CPU, Server Load.PNG

For that, Max aggregation should be used on the chart.
“CPU" or “Server Load" metrics are available to the Redis instance or per shard, in case of Redis clustered instances. On that case you may need to investigate each shard individually to identify high “CPU" or “Server Load" in some specific shard.

 

How to mitigate High Server CPU usage:

There are several changes you may make to mitigate high server load:

  • Investigate long running commands used as described above on topic 2.
  • Scale to a larger cache size with more CPU capacity.
  • Create alerts on metrics like CPU or server load to be notified early about potential impacts.

 

4- Server High Memory Usage

Memory pressure on the server side may cause some kinds of performance issues that can delay processing of requests, and when memory pressure occurs, the system may page data to disk.

This page faulting causes the system to slow down significantly.

 

There are some possible causes of this memory pressure:

  • The cache is filled with data near its maximum capacity.
  • Redis is seeing high memory fragmentation. This fragmentation is most often caused by storing large objects, since Redis is optimized for small objects.

 

How to verify High Server Memory usage, from client side:

  • The “used_memory" and "used_memory_rss" metrics on Azure Portal can be used to see how much memory is being used:

LuisFilipe_0-1609762172295.png

For that, Max aggregation should be used on the chart.

 

  • Any Redis console can be used to run Info command. This command may be used to identify memory usage looking for "Used Memory" and "Used Memory RSS“ section in the command output. Please see more about using Info command.

 

How to mitigate High Server Memory usage:

There are several possible changes to help keep memory usage healthy:

  • Configure a memory policy and set expiration time on keys - this policy may not be sufficient if having fragmentation. 
  • The default eviction policy is volatile-lru - this evict keys by trying to remove the less recently used (LRU) keys first, but only the keys that have an expire set. so, using volatile-lru, set expiration time on keys is highly recommended.
  • Configure a maxmemory-reserved and maxfragmentationmemory-reserved value this should be large enough to compensate for memory fragmentation. Microsoft recommendation is to use 5% of the size of the cache (or higher) to each one of these reserved values, when using large key sizes.
    For the points above, please see how to Configure Memory Policies.
  • Review client application logic and split large cached objects into smaller objects.
  • Scale to a larger cache size with more memory capacity.
  • Create alerts on metrics like used_memory and/or used_memory_rss to be notified early about potential impacts.

 

5- Redis Server Bandwidth Limit Exceeded

Redis Server Network Bandwidth exceeded and some other network causes for Redis timeouts are explained on this Tech Community article: Azure Redis Timeouts - Network Issues

   

 

Conclusion:

Despite having different reasons to have Redis timeouts on connections to Azure Cache for Redis, some different causes on Client, Server or Network side can cause Redis timeouts.

 

For Client or Network side Redis timeout causes, please see these Tech Community articles:

Azure Redis Timeouts - Client Side Issues
Azure Redis Timeouts - Network Issues

 

 

Related documentation:

Timeout issues 

Redis commands

How to Scale Azure Cache for Redis 
Creating Alerts on Azure

 

1- Server Update / Patch

How does a failover affect my client application?

Schedule updates

 

2- Long Running Commands

Slowlog

Long-running Commands

 

3- Server High CPU Load

High CPU or Server Load

 

4- Server High Memory Usage

Eviction policies
Configure Memory Policies

Memory pressure Server-side

Info command

 

 

I hope this can be useful !!!