2
votes

We have been using MariaDB in RDS and we noticed that the swap space is getting increasingly high whithout being recycled. The freeable memory however seems to be fine. Please check the attached files.

Instance type : db.t2.micro

Freeable memory : 125Mb

Swap space : increased by 5Mb every 24h

IOPS : disabled

Storage : 10Gb (SSD)

Soon RDS will eat all the swap space, which will cause lots of issues to the app. Does anyone have similar issues? What is the maximum swap space? (didn't find anything in the docs)

Please help!

enter image description here

enter image description here

2

2 Answers

2
votes

Does anyone have similar issues?

I had similar issues on different instance types. The trend of swapping stays even if you would switch to higher instance type with more memory.

An explanation from AWS you can find 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.

And the resolution:

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.

What is the maximum swap space?

By enabling Enhanced Monitoring you should be able to see OS metrics, e.g. The amount of swap memory free, in kilobytes. See details here

2
votes

Enabling enhanced monitoring in RDS has made things more clear. Obviously what we needed to watch was Committed Swap instead of Swap Usage. We were able to see how much Free Swap we had.

I now also believe that MySQL is dumping things in swap just because there is too much space in there, even though it wasn't really in urgent need of memory.