I'm using AWS Elasticache Redis and I've been having issues with Redis and to many connections. Using "Info All" I can see the total used connections can grow to around 50,000 in a day.
Currently I'm using PHP to connect to Redis and I have this put into many different php functions so it can be called many times for a single page request. Also PHP session are on redis.
I wanted to ask: - Can I create a persistent connection to redis from PHP? One connection for all requests to use. - Should I use a Global PHP variable as a Redis connection that different functions use rather then creating a new connection to redis for each function? - I've read about Nginx proxying redis requests "redis_pass" - would this connect just once and proxy requests through? would this be a better solution?
Any other solutions? Just looking for a wise way to reduce the number of redis connections from PHP. (Note: using php 7.0.6).
thanks :) Adam
Edit: I noticed you can also get your PHP Session data on Redis via Nginx - would this also reduce connections - I assume yes: How can I get the value from Redis and put it in a variable in NGiNX?