Redis info command

info command 命令可以查詢 Redis 運行狀態,是在排查問題中,非常重要的資訊。

Jerry’s Notes
What’s next?
15 min readMar 23, 2022

--

The INFO command returns information and statistics about the server in a format that is simple to parse by computers and easy to read by humans.

常用命令

Memory 內存使用量相關

MEMORY STATE

!!!有關內存使用情況的信息以指標及其各自的數值提供。

info commandstats 命令執行統計報告

收集 “info commandstats”,連續6次,每次間隔10分鐘。

Info client: Client連接數量資訊統計

Client Info:客戶端連接的相關信息

Q: 為什麼 omem 或 oll 會增加?

■ 正常現象,因為請求一個比較大的回覆,所以接受本來就會相對久一點。
■ 發送很多命令來,Redis 處理完了,但 Redis client 還沒接受完。 (例如使用 pipe line,同時請求多個命令,Redis 都處理完了,但 Redis client 的接收速度可能會跟不上。)
■ Redis client 的底層可能有一些狀況 (網絡抖動、性能受限.. 等),所以接收回覆的效率相對變差。

Q: 有什麼方法能監控?

■ 定期監控 `client list` 的 omem,但 client list 是一個開銷比較大的命令,當 client 數多時要特別注意。
■ 定期監控 `info client` 中的 client_recent_max_output_buffer 這個命令會記錄最近最大的 omem 值,開銷相對 `client list` 小,但缺點是不會知道是哪個 client。
■ 監控 `info memory` 中的 `used_memory_overhead` 這個值能瞭解到,redis 用來存放數據結構的內存是否有突然的變化。(有變化說明數據結構有變多或變少)

Q: 有什麼方法可以避免?

■ 可以考慮設置 `client-output-buffer-limit-normal-hard-limit` 設定後,超過限制的 Redis client 將被終止,這可以保障其它正常的 client 繼續使用 Redis 。
Top Redis Headaches for Devops — Client Buffers:
https://redis.com/blog/top-redis-headaches-for-devops-client-buffers/

client-list: Client 連接資訊

https://redis.io/commands/client-list

--

--

Jerry’s Notes
What’s next?

An cloud support engineer focus on troubleshooting with customer reported issue ,and cloud solution architecture.