{"action":"created","issue":{"url":"https://api.github.com/repos/StackExchange/StackExchange.Redis/issues/12","repository_url":"https://api.github.com/repos/StackExchange/StackExchange.Redis","labels_url":"https://api.github.com/repos/StackExchange/StackExchange.Redis/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/StackExchange/StackExchange.Redis/issues/12/comments","events_url":"https://api.github.com/repos/StackExchange/StackExchange.Redis/issues/12/events","html_url":"https://github.com/StackExchange/StackExchange.Redis/issues/12","id":31052756,"node_id":"MDU6SXNzdWUzMTA1Mjc1Ng==","number":12,"title":"StackExchange.Redis timeout and “No connection is available to service this operation”","user":{"login":"stilago-ci","id":6463823,"node_id":"MDQ6VXNlcjY0NjM4MjM=","avatar_url":"https://avatars3.githubusercontent.com/u/6463823?v=4","gravatar_id":"","url":"https://api.github.com/users/stilago-ci","html_url":"https://github.com/stilago-ci","followers_url":"https://api.github.com/users/stilago-ci/followers","following_url":"https://api.github.com/users/stilago-ci/following{/other_user}","gists_url":"https://api.github.com/users/stilago-ci/gists{/gist_id}","starred_url":"https://api.github.com/users/stilago-ci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stilago-ci/subscriptions","organizations_url":"https://api.github.com/users/stilago-ci/orgs","repos_url":"https://api.github.com/users/stilago-ci/repos","events_url":"https://api.github.com/users/stilago-ci/events{/privacy}","received_events_url":"https://api.github.com/users/stilago-ci/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":21,"created_at":"2014-04-08T08:46:12Z","updated_at":"2018-09-18T06:40:51Z","closed_at":"2014-04-14T12:23:29Z","author_association":"NONE","body":"Hi Marc,\n\nFirst of all thanks for this awesome redis client.\nBut I have some issues :)\n\nI have the following issues in our production environment (Web-Farm - 4 nodes, on top of it Load balancer):\n\n1) Timeout performing HGET key, inst: 3, queue: 29, qu=0, qs=29, qc=0, wr=0/0\nat StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor``1 processor, ServerEndPoint server) in ConnectionMultiplexer.cs:line 1699 This happens 3-10 times in a minute\n\n2) No connection is available to service this operation: HGET key at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor``1 processor, ServerEndPoint server) in ConnectionMultiplexer.cs:line 1666\n\nI tried to implement as Marc suggested (Maybe I interpreted it incorrectly) - better to have fewer connections to Redis than multiple. I made the following implementation:\n\npublic class SeRedisConnection\n{\n    private static ConnectionMultiplexer _redis;\n\n```\nprivate static readonly object SyncLock = new object();\n\npublic static IDatabase GetDatabase()\n{\n    if (_redis == null || !_redis.IsConnected || !_redis.GetDatabase().IsConnected(default(RedisKey)))\n    {\n        lock (SyncLock)\n        {\n            try\n            {\n                var configurationOptions = new ConfigurationOptions\n                {\n                    AbortOnConnectFail = false\n                };\n                configurationOptions.EndPoints.Add(new DnsEndPoint(ConfigurationHelper.CacheServerHost,\n                    ConfigurationHelper.CacheServerHostPort));\n\n                _redis = ConnectionMultiplexer.Connect(configurationOptions);\n            }\n            catch (Exception ex)\n            {\n               IoC.Container.Resolve<IErrorLog>().Error(ex);\n                return null;\n            }\n        }\n    }\n    return _redis.GetDatabase();\n}\n\npublic static void Dispose()\n{\n    _redis.Dispose();\n}\n```\n\n}\n\nActually dispose is not being used right now. Also I have some specifics of the implementation which might cause such behavior (I'm only using hashes): \n1. Add, Remove hashes - async \n2. Get -sync\n\nOriginal question you can find here: \nhttp://stackoverflow.com/questions/22930856/stackexchange-redis-timeout-and-no-connection-is-available-to-service-this-oper\n\nThanks a lot in advance!\n\nLooking forward for your response.\n\nBTW: Here what I can see from my redis cache server (TCP connections never goes up):\n![image](https://cloud.githubusercontent.com/assets/6463823/2645316/4796970a-bf31-11e3-94a5-9728f06c1b25.png)\n\nAlso I have stress-testing web-farm (2 nodes - Microsoft NLB). If I run load test for 200 req/s - it handles it ok in this environment and I noticed 5-8 open TCP connections and no timeouts at all. But the issue is with Microsoft NLB if you are making stress-test from 2-3 ip addresses it allocates requests only to one node.\n\nSo in production environment case it should be 4 nodes \\* 8 (active connections) = 32 open connections rather than 200.  \n"},"comment":{"url":"https://api.github.com/repos/StackExchange/StackExchange.Redis/issues/comments/422273563","html_url":"https://github.com/StackExchange/StackExchange.Redis/issues/12#issuecomment-422273563","issue_url":"https://api.github.com/repos/StackExchange/StackExchange.Redis/issues/12","id":422273563,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMjI3MzU2Mw==","user":{"login":"mgravell","id":17328,"node_id":"MDQ6VXNlcjE3MzI4","avatar_url":"https://avatars3.githubusercontent.com/u/17328?v=4","gravatar_id":"","url":"https://api.github.com/users/mgravell","html_url":"https://github.com/mgravell","followers_url":"https://api.github.com/users/mgravell/followers","following_url":"https://api.github.com/users/mgravell/following{/other_user}","gists_url":"https://api.github.com/users/mgravell/gists{/gist_id}","starred_url":"https://api.github.com/users/mgravell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgravell/subscriptions","organizations_url":"https://api.github.com/users/mgravell/orgs","repos_url":"https://api.github.com/users/mgravell/repos","events_url":"https://api.github.com/users/mgravell/events{/privacy}","received_events_url":"https://api.github.com/users/mgravell/received_events","type":"User","site_admin":false},"created_at":"2018-09-18T06:40:51Z","updated_at":"2018-09-18T06:40:51Z","author_association":"CONTRIBUTOR","body":"No it doesn't. It has builds from 4.6.1 upwards.\n\nOn Tue, 18 Sep 2018, 02:06 usernamedd, <notifications@github.com> wrote:\n\n> @usernamedd <https://github.com/usernamedd> on which version? If it is <\n> 2.0, then I'd say \"try 2.*\" - almost all of the 2.* work related to\n> connection stability.\n>\n> Thank u so much . it is actually < 2.0 , but version 2.0 need 4.7\n> framework . I am thinking about it .\n>\n> —\n> You are receiving this because you modified the open/close state.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/StackExchange/StackExchange.Redis/issues/12#issuecomment-422219617>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/AABDsAMXVxW1YNY1b8MpkGTP9B0VJW_Iks5ucEcNgaJpZM4BwiiD>\n> .\n>\n"}}
{"actor":{"display_login":"mgravell"}}