14

伙计们,

有人可以在运行 Mysql 的 Amazon RDS 上解释这种内存消耗模式吗?在此图中,我在 03:30 升级到 db.m2.2xlarge,可用内存为 34GB。您可以非常清楚地看到切换。当客户端开始连接并点击该实例时,Freeable 内存急剧下降到 5GB,现在它一直悬停在那里。在我之前的数据库实例大小之间的升级中,我看到了相同的模式,直到可释放内存降至 1GB 以下并无限期地悬停在那里。

这个实例在 03:30 到 07:30 之间在做什么?为什么它不释放未使用的内存,因为它变得可用?我想我希望这个图是一个波形,对应于使用和流量模式,vs 和指数衰减形状,这表明它是一个超级懒惰和/或损坏的垃圾收集算法。

另请注意,大约 2/3 的 DB 操作是写入,1/3 是读取,并且 DB 前面大约有 2GB 的 memcache。

内存消耗亚马逊rds mysql

4

1 回答 1

13

MySQL maintains a cache of recently used tables, queries and results in memory, in order to return faster results. For example, if you query "select * from company where id = 1" from a client 1 million times, only the first query needs to go to disk, the next 999,999 will come straight from the in RAM cache. There is no reason for MySQL to expire this cache until it knows it needs more memory, so it keeps things saved until it needs to free up RAM for other work or more frequently used results.

I don't claim to be an expert - I understand DB query cache optimization to be a very complex and deep science. Programmers at Oracle, Microsoft and others have spent years and years working out the best way for the cache space to be managed, so it's hard to predict from the outside.

于 2011-08-21T22:17:45.540 回答