Performance
Magento is very chatty with Redis
Performance
Survey of /catalog/category/view for 8 production Magento instances
## Network Concerns
```bash
$ ping -c 10 172.24.32.122
PING 172.24.32.122 (172.24.32.122) 56(84) bytes of data.
64 bytes from 172.24.32.122: icmp_seq=1 ttl=64 time=0.105 ms
64 bytes from 172.24.32.122: icmp_seq=2 ttl=64 time=0.086 ms
64 bytes from 172.24.32.122: icmp_seq=3 ttl=64 time=0.107 ms
64 bytes from 172.24.32.122: icmp_seq=4 ttl=64 time=0.081 ms
64 bytes from 172.24.32.122: icmp_seq=5 ttl=64 time=0.120 ms
64 bytes from 172.24.32.122: icmp_seq=6 ttl=64 time=0.130 ms
64 bytes from 172.24.32.122: icmp_seq=7 ttl=64 time=0.099 ms
64 bytes from 172.24.32.122: icmp_seq=8 ttl=64 time=0.079 ms
64 bytes from 172.24.32.122: icmp_seq=9 ttl=64 time=0.082 ms
64 bytes from 172.24.32.122: icmp_seq=10 ttl=64 time=0.076 ms
--- 172.24.32.122 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9000ms
rtt min/avg/max/mdev = 0.076/0.096/0.130/0.020 ms
```
## Network Concerns
- `nping`
- `redis-cli --latency`
- `traceroute`
- `tcptraceroute`
## Network Concerns
Round trip time of more than 0.5ms is a red flag
## Performance
"Redis uses a mostly single threaded design"
https://redis.io/topics/latency#single-threaded-nature-of-redis
## Performance
"A consequence of being single thread is that when a request is slow to serve all the other clients will wait for this request to be served."
https://redis.io/topics/latency#latency-generated-by-slow-commands
## Performance
"It is possible to monitor slow commands using the [Redis Slow Log](https://redis.io/commands/slowlog) feature."
https://redis.io/topics/latency#latency-generated-by-slow-commands
## SLOWLOG threshold
### At runtime
```bash
127.0.0.1:6379> CONFIG SET slowlog-log-slower-than 10000
OK
```
## SLOWLOG threshold
### In the config file
```bash
$ grep slowlog-log-slower-than /etc/redis/redis.conf
slowlog-log-slower-than 10000
```
## Reading the slowlog
```bash
127.0.0.1:6379> SLOWLOG GET
9) 1) (integer) 105
2) (integer) 1538060008
3) (integer) 593744
4) 1) "SUNION"
2) "zc:ti:a95_MAGE"
```
Reading the slowlog
Every entry is composed of four (or six starting with Redis 4.0) fields:
- A unique progressive identifier for every slow log entry.
- The unix timestamp at which the logged command was processed.
- The amount of time needed for its execution, in microseconds
- The array composing the arguments of the command.
https://redis.io/commands/slowlog
## Proceed with caution
- KEYS * (Use SCAN / write a PHP script)
- FLUSHDB (FLUSHDB ASYNC was added in 4.0.0)