Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon RDS running out of freeable memory. Should I be worried?

I have an Amazon RDS instance. Freeable Memory has been declining since setup over 1-2 weeks, starting from 15GB of memory down to about 250MB. As it has dropped this low in the last days, it has started to resemble a sawtooth pattern where Freeable Memory drops to this range (250 - 350MB) and then goes back up agin to 500 - 600MB in a sawtooth pattern.

There has not been any notable decline in application quality. However, I am worried that the DB will run out of memory and crash.

Is there a danger that the RDS instance will run out of memory? Is there some setting or parameter I should be looking at to determine if the instance is set up correctly? What is causing this sawtooth pattern?

Freeable Memory Declining

like image 303
william tell Avatar asked Mar 11 '13 06:03

william tell


People also ask

What happens when RDS runs out of space?

An Amazon RDS DB instance in the storage-full status doesn't have enough available space to perform basic operations, such as connecting to or restarting the instance. To resolve this issue, do the following: Confirm that the DB instance status is storage-full. Increase the allocated storage of your DB instance.

What does Freeable memory mean RDS?

Freeable memory is the amount of memory (RAM) available on the RDS Instance. The value of Freeable memory should never go too low. The optimal value completely depends on the database type (OLTP/OLAP), application or system type that is being used.

How do you increase Freeable memory on RDS?

If your freeable memory remains consistently low, you can change your RDS DB instance size to a larger instance size that has more memory. To monitor swap memory, turn on Enhanced Monitoring to review metrics in intervals with a granularity of as little as one second.

What happen when RDS primary database instance fails?

What would happen to an RDS (Relational Database Service) Multi-Availability Zone deployment if the primary DB instance fails? IP of the primary DB Instance is switched to the standby DB Instance. A new DB instance is created in the standby availability zone.


2 Answers

Short answer - you shouldn't worry about FreeableMemory unless it is became really low (about 100-200 Mb) or significant swapping occur (see RDS SwapUsage metric).

FreeableMemory is not a MySQL metric, but OS metric. It is hard to give precise definition, but you can treat it as memory which OS will be able to allocate to anyone who request it (in your case it likely will be MySQL). MySQL have a set of settings which are restricting it's overall memory usage to some cap(you can use something like this to actually calculate it). It's unlikely that your instance will ever hit this limit, due to the fact that in general you never reach max number of connections, but this is still possible.

Now going back to "decline" in FreeableMemory metric. For the MySQL most of the memory consume by InnoDB buffer pool (see here for details). RDS instances in there config by default have size for this buffer set to 75% of hosts physical memory - which in your case is about 12 GB. This buffer is used for caching all DB data which used in both read and write operations. So in your case, since this buffer is really big - it is slowly filling with data which cached (it is likely that this buffer is actually big enough to cache all DB). So when you first start you instance this buffer is empty and than once you start reading/writing stuff into DB all this data are bringing into cache. They will stay here up to the time when this cache became full and new request came. At this time least recently used data will be replaced with new data. So initial decline of FreeableMemory after DB instance restart explains with this fact. It is not a bad thing, cause you actually want as much as possible of you data to be cache in order for you DB to work faster. The only thing which can go nasty is when part or all of this buffer will be pushed out of physical memory into swap. At that point you will have huge performance drop.

As a preventive care it might be a good idea to tune MySQL max memory used for different thing in case you FreeableMemory metric is constantly on a level of 100-200 Mb, just to reduce possibility of swapping.

like image 114
Dmitry Avatar answered Sep 26 '22 02:09

Dmitry


Freeable memory field is used by MySQL for buffering and caching for it`s own processes. It is normal for the amount of Freeable memory to decrease over time. I wouldn't be worried it kicks old info out as it demands more room.

like image 35
Larry McKenzie Avatar answered Sep 23 '22 02:09

Larry McKenzie