RDS 吃光了所有交换 space

RDS eating all the swap space

我们一直在 RDS 中使用 MariaDB,我们注意到交换 space 在没有被回收的情况下变得越来越高。然而,可释放内存似乎没问题。请检查附件。

实例类型:db.t2.micro

可用内存:125Mb

Swap space:每 24 小时增加 5Mb

IOPS:禁用

存储空间:10Gb (SSD)

很快 RDS 就会吃掉所有的交换 space,这会给应用程序带来很多问题。 有没有人有类似的问题? 最大隔夜利息是多少 space? (未在文档中找到任何内容)

请帮忙!

在 RDS 中启用增强监控 使事情变得更加清晰。 显然,我们需要关注的是 Committed Swap 而不是 Swap Usage。我们能够看到我们有多少 Free Swap

我现在也相信 MySQL 只是因为那里 space 太多而将东西转储到交换区中,即使它并不是真的急需内存。

有没有人有类似的问题?

我在不同的实例类型上遇到了类似的问题。即使您切换到具有更多内存的更高实例类型,交换的趋势仍然存在。

您可以找到来自 AWS 的解释 here

Amazon RDS DB instances need to have pages in the RAM only when the pages are being accessed currently, for example, when executing queries. Other pages that are brought into the RAM by previously executed queries can be flushed to swap space if they haven't been used recently. It's a best practice to let the operating system (OS) swap older pages instead of forcing the OS to keep pages in memory. This helps make sure that there is enough free RAM available for upcoming queries.

以及分辨率:

Check both the FreeableMemory and the SwapUsage Amazon CloudWatch metrics to understand the overall memory usage pattern of your DB instance. Check these metrics for a decrease in the FreeableMemory metric that occurs at the same time as an increase in the SwapUsage metric. This can indicate that there is pressure on the memory of the DB instance.

最大隔夜利息是多少space?

通过启用增强监控,您应该能够看到 OS 指标,例如The amount of swap memory free, in kilobytes. 查看详情 here