14

皆さん、

Mysqlを実行しているAmazonRDSでこのメモリ消費パターンを誰かが説明できますか?このグラフでは、03:30に、34GBの使用可能なメモリを備えたdb.m2.2xlargeにアップグレードしました。スイッチオーバーを非常にはっきりと見ることができます。クライアントが接続してそのインスタンスにアクセスし始めると、Freeableメモリは5GBに急激に低下し、現在はホバリングしています。以前のDBインスタンスサイズ間のアップグレードでは、解放可能なメモリが1 GBをわずかに下回るまで低下し、そこで無期限にホバリングするまで、同じパターンが見られました。

このインスタンスは03:30から07:30の間に何をしていますか?使用可能になったときに未使用のメモリを解放しないのはなぜですか?このグラフは、使用状況とトラフィックパターンに対応する波形と、指数関数的減衰の形状であると予想されます。これは、非常に怠惰な、または壊れたガベージコレクションアルゴリズムであることを示しています。

また、DB操作の約3分の2が書き込みで、1/3が読み取りであり、DBの前に約2GBのmemcacheがあることに注意してください。

メモリ消費amazonrdsmysql

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 に答える