Hey, we’re using the Redis driver and we recently noticed very strange behavior where connections would spike from 500 to around 1,500 for no apparent reason (Same requests amount, same load, will run for days without any problems) - we’re hosted on AWS if that makes any difference. Also, if we cap the max connections on the driver, what is a recommended amount?
Thanks
I’d make sure all RedisClients are being properly disposed. If you want cap number of connections you should use PooledRedisClientsManager as it will block when it runs out of connections instead of RedisManagerPool which will create overflow connections outside of the pool. Details about pooling behavior of each manager is at: https://github.com/ServiceStack/ServiceStack.Redis#redis-client-managers
We don’t have a recommended pool size limit, PooledRedisClientsManager defaults with a conservative about of 10 x each host provided, whilst RedisManagerPool defaults to 40, but they can be tweaked depending on your environment.
Ron Rejwan:
+Demis Bellot Hey thanks for the reply.
We’re using RedisManagerPool running on around 25 servers, and we’ve wrapped all of our functions with using()
Here is a snippet showing our average usage:
https://gist.github.com/rejwan/48ae36bc57b5a2deae32
you shouldn’t share the redis client instance across threads (i.e. passed into Task.Run), instead retrieve/release it from the pool within the same thread. But other than that I wouldn’t be able to tell what the issue is from here without a repro.
Ron Rejwan:
+Demis Bellot - OK we’ll remove all Task.Run, regarding using PooledRedisClientsManager, is there a best practice on using it (ie specifying a limit, etc?) or should we just use the default ctor with the URL to our Redis server?
I’d try going with the defaults first, then avoid hang onto clients for too long to return them into the pool quicker ready for others to use.
Ron Rejwan:
We use Redis access as a caching layer to get/set - we store the pool itself statically in a static class. Does that sound good enough?
Yep, the pools/client managers are supposed to be used as singletons.