-
Improvement
-
Resolution: Fixed
-
Minor
-
4.0.2
-
MOODLE_400_STABLE
-
MOODLE_401_STABLE
-
MDL-75369-master -
When Moodle connects to Redis (function new_redis in redis/lib.php), it does a ping as well as a connect:
if ($redis->connect($server, $port)) {
|
...omitted code that sets some options on the redis object...
|
// Database setting option...
|
$this->isready = $this->ping($redis);
|
} else {
|
$this->isready = false;
|
}
|
I was profiling something unrelated and noticed that this ping takes almost as long as the connect. in my profile, Redis::connect took a total of 4.1ms for 2 calls (presumably this is because we're using Redis for both session and MUC caches, I didn't check), while Redis::ping took a total of 1.7ms for the 2 calls.
Obviously the exact time taken will depend on infrastructure but I don't understand the benefit of the ping here. From the time it takes, it seems like the connect() call does really connect, i.e. if it was basically just storing the address and not doing any networking it would complete in well under a millisecond, so if the server is down then that should probably fail already. Also, even if something is wrong with the server, presumably we would find that out as soon as we try to do a 'get' from the cache, so what's the point in checking it early,
The comment above the ping line is not helpful as to why it's needed.
While this is only a very small amount of time, for sites that use Redis (hosted on a separate machine) which is probably very common, that time is taken on every single request, so deleting this line would seem like a nice easy performance gain. Unless there is a good reason why it's actually needed, in which case the comment should probably be improved!
- caused a regression
-
MDL-72622 Support TLS connections for Redis
- Closed