ElastiCache high SwapUsage issue?

為什麼會出現高SwapUsage使用量的原因? 出現高SwapUsage使用量時,是不是問題?

Jerry’s Notes
What’s next?
2 min readMar 20, 2022

--

為什麼會出現高SwapUsage使用量的原因?

Three reasons for swapping in Redis

1) The system is under memory pressure since the Redis processes are demanding more physical memory than the amount that is available. 高COB、connection、fragmentation rate 都可能造成,Redis 所使用的內存,高於實例上的內存量,而使用到 SWAP。

For example:

• High Normal/Replica/PubSub COB usage, which can be checked in Elmo internal metric

• High connection count since each connection is a file descriptor and it will occupy a little of bit of memory

• High fragmentation, which can be checked in INFO output

2) The Redis instance data set, or part of the data set, is mostly completely idle (never accessed by clients), so the kernel could swap idle memory pages on disk. This problem is rare since even a moderately slow instance will touch all the memory pages often, forcing the kernel to retain all the pages in memory. Redis 上的數據長時間,沒有要存取到,所以作業系統搬移到SWAP上。

3) Some processes are generating massive read or write I/Os on the system. Because files are generally cached, it tends to put pressure on the kernel to increase the filesystem cache, and therefore generate swapping activity. Please note it includes Redis RDB and/or AOF background threads which can produce large files. 當執行高I/o的行為時,因為需要執行檔案緩存,會造成高內存的使用量,進而導致內存不足而使用到SWAP。

Q: 出現高SwapUsage使用量時,是不是問題?

不一定。簡單來說,只有 Freememory 是足夠的,再加上 SwapUsage 沒有持續增加的話,一般是不會影響的。

This is a host-level metric reported in bytes. For more information, see Host-Level Metrics.

This metric should not exceed 300 MB. If it does, see the following topics:

Ensuring that you have enough memory to create a Redis snapshot

Managing Reserved Memory

--

--

Jerry’s Notes
What’s next?

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