Redis Error

HappyWorld

Well-known member
I find lot of these random error on my error_log, what do these mean?

Code:
[05-Feb-2019 15:50:12 UTC] PHP Fatal error:  Uncaught RedisException: Cannot assign requested address in /home/********/public_html/src/XF/CacheFactory.php:226
Stack trace:
#0 /home/********/public_html/src/XF/CacheFactory.php(226): Redis->connect('******', ****, 0)
#1 /home/********/public_html/src/XF/CacheFactory.php(79): XF\CacheFactory->createRedisCache(Array)
#2 /home/********/public_html/src/XF/CacheFactory.php(34): XF\CacheFactory->instantiate('Redis', Array)
#3 /home/********/public_html/src/XF/App.php(632): XF\CacheFactory->create('Redis', Array)
#4 /home/********/public_html/src/XF/Container.php(228): XF\App->XF\{closure}('', Array, Object(XF\Container))
#5 /home/********/public_html/src/XF/App.php(2342): XF\Container->create('cache', '')
#6 /home/********/public_html/src/XF/App.php(659): XF\App->cache('registry')
#7 /home/********/public_html/src/XF/Container.php(28): XF\App->XF\{closure}(Object(XF\Container))
#8 /home/********/public_html/src/XF/App.php(1643): XF\Container->offsetGet('registry')
#9 /home/********/public_html/src/XF/Container.php(28): XF\App->XF\{closure} in /home/********/public_html/src/XF/CacheFactory.php on line 226
 
Last edited:
This is likely happening because you've run out of TCP ports because of too many simultaneous requests that have left lingering TCP connections.

You can use unix socket paths so it doesn't consume a port count, but you really need todo this on every level that handles the request.

The only real answer is to not use pre-forking apache or php-fpm with unreasonably high worker counts. It is generally better to reject connections than to serve an unreasonable number so slowly things start to just fail after consuming resources.
 
The only real answer is to not use pre-forking apache or php-fpm with unreasonably high worker counts. It is generally better to reject connections than to serve an unreasonable number so slowly things start to just fail after consuming resources.
Not for xenforo usage, but in past to get past Redis TCP connection scaling I've used a redis proxy in front of Redis servers like Twitter's twemproxy https://github.com/twitter/twemproxy. No idea how it would work with Xenforo though.

twemproxy (pronounced "two-em-proxy"), aka nutcracker is a fast and lightweight proxy for memcached and redis protocol. It was built primarily to reduce the number of connections to the caching servers on the backend. This, together with protocol pipelining and sharding enables you to horizontally scale your distributed caching architecture.
Features
  • Fast.
  • Lightweight.
  • Maintains persistent server connections.
  • Keeps connection count on the backend caching servers low.
  • Enables pipelining of requests and responses.
  • Supports proxying to multiple servers.
  • Supports multiple server pools simultaneously.
  • Shard data automatically across multiple servers.
  • Implements the complete memcached ascii and redis protocol.
  • Easy configuration of server pools through a YAML file.
  • Supports multiple hashing modes including consistent hashing and distribution.
  • Can be configured to disable nodes on failures.
  • Observability via stats exposed on the stats monitoring port.
  • Works with Linux, *BSD, OS X and SmartOS (Solaris)
Looks like Twitter transitioned from Twemproxy to Pelikan http://twitter.github.io/pelikan/2019/09/20/why-pelikan.html
 
Last edited:
Not for xenforo usage, but in past to get past Redis TCP connection scaling I've used a redis proxy in front of Redis servers like Twitter's twemproxy https://github.com/twitter/twemproxy. No idea how it would work with Xenforo though.
You can also use persistent connections with redis & php, which mostly works; but at that stage you want to use separate redis instances for categories of things (ie sessions vs general cache vs css)
 
You can also use persistent connections with redis & php, which mostly works; but at that stage you want to use separate redis instances for categories of things (ie sessions vs general cache vs css)
Cheers :)

I might revisit redis/memcached proxy setup for xenforo and see if it works. I also tested Netflix's dynomite https://github.com/Netflix/dynomite and Corvus https://github.com/eleme/corvus/ but terms of performance last time I tested it was Twitter Twemproxy > Dynomite > Corvus very very far behind
 
Top Bottom