2017-09-14 121 views
0

我在RDS MySQL服務器上面臨高內存使用率問題, 我們設置了MySQL的內存上限爲149 GB,但它仍佔用大約98%的內存。RDS MySQL高內存消耗

任何人都可以幫我理解,RDS內存消耗和釋放行爲?

我們如何能夠知道導致高內存使用率的原因? 我們如何避免它?

RDS配置: - db.r3.8xlarge。(CPU核心= 32和內存= 240 GB)。

MySQL的內存配置: -

Innodb_buffer_pool_size=144 GB 

Innodb_buffer_pool_instances= 1 

Innodb_page_cleaners =1 

Key_buffer_size = 256 MB 

query_cache_size =64 MB 

tmp_table_size =4096 MB 

innodb_log_buffer_size= 64 MB 

Max_connections = 20484 

sort_buffer_size= 2 MB 

read_buffer_size = 0.128 MB 

read_rnd_buffer_size = 0.256 MB 

join_buffer_size = 1 MB 

thread_stack =0.25 MB 

binlog_cache_size = 0.031 MB 

部分Innodb的地位

-------- 
FILE I/O 
-------- 
I/O thread 0 state: waiting for completed aio requests (insert buffer thread) 
I/O thread 1 state: waiting for completed aio requests (log thread) 
I/O thread 2 state: waiting for completed aio requests (read thread) 
I/O thread 3 state: waiting for completed aio requests (read thread) 
I/O thread 4 state: waiting for completed aio requests (read thread) 
I/O thread 5 state: waiting for completed aio requests (read thread) 
I/O thread 6 state: waiting for completed aio requests (read thread) 
I/O thread 7 state: waiting for completed aio requests (read thread) 
I/O thread 8 state: waiting for completed aio requests (read thread) 
I/O thread 9 state: waiting for completed aio requests (read thread) 
I/O thread 10 state: waiting for completed aio requests (write thread) 
I/O thread 11 state: waiting for completed aio requests (write thread) 
I/O thread 12 state: waiting for completed aio requests (write thread) 
I/O thread 13 state: waiting for completed aio requests (write thread) 
I/O thread 14 state: waiting for completed aio requests (write thread) 
I/O thread 15 state: waiting for completed aio requests (write thread) 
I/O thread 16 state: waiting for completed aio requests (write thread) 
I/O thread 17 state: waiting for completed aio requests (write thread) 
I/O thread 18 state: waiting for completed aio requests (write thread) 
I/O thread 19 state: waiting for completed aio requests (write thread) 
I/O thread 20 state: waiting for completed aio requests (write thread) 
I/O thread 21 state: waiting for completed aio requests (write thread) 
I/O thread 22 state: waiting for completed aio requests (write thread) 
I/O thread 23 state: waiting for completed aio requests (write thread) 
I/O thread 24 state: waiting for completed aio requests (write thread) 
I/O thread 25 state: waiting for completed aio requests (write thread) 
Pending normal aio reads: [0, 0, 0, 0, 0, 0, 0, 0] , aio writes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] , 
ibuf aio reads:, log i/o's:, sync i/o's: 
Pending flushes (fsync) log: 0; buffer pool: 0 
16300373 OS file reads, 327069064 OS file writes, 34275132 OS fsyncs 
0.00 reads/s, 0 avg bytes/read, 24.00 writes/s, 2.83 fsyncs/s 
------------------------------------- 
INSERT BUFFER AND ADAPTIVE HASH INDEX 
------------------------------------- 
Ibuf: size 1, free list len 3690, seg size 3692, 1232846 merges 
merged operations: 
insert 1518763, delete mark 7967515, delete 581073 
discarded operations: 
insert 0, delete mark 0, delete 0 
Hash table size 38278223, node heap has 53862 buffer(s) 
Hash table size 38278223, node heap has 101395 buffer(s) 
Hash table size 38278223, node heap has 51039 buffer(s) 
Hash table size 38278223, node heap has 49662 buffer(s) 
Hash table size 38278223, node heap has 31822 buffer(s) 
Hash table size 38278223, node heap has 69910 buffer(s) 
Hash table size 38278223, node heap has 62223 buffer(s) 
Hash table size 38278223, node heap has 107050 buffer(s) 
75.17 hash searches/s, 83.82 non-hash searches/s 
--- 
LOG 
--- 
Log sequence number 23815192515256 
Log flushed up to 23815192515256 
Pages flushed up to 23815192515256 
Last checkpoint at 23815192515247 
0 pending log flushes, 0 pending chkp writes 
71186755 log i/o's done, 7.34 log i/o's/second 
---------------------- 
BUFFER POOL AND MEMORY 
---------------------- 
Total large memory allocated 158455627776 
Dictionary memory allocated 9737076 
Buffer pool size 9444223 
Free buffers  272250 
Database pages  8645010 
Old database pages 3191205 
Modified db pages 0 
Pending reads  0 
Pending writes: LRU 0, flush list 0, single page 0 
Pages made young 36040960, not young 898847533 
0.00 youngs/s, 0.00 non-youngs/s 
Pages read 15253773, created 43492874, written 244272465 
0.00 reads/s, 0.52 creates/s, 16.07 writes/s 
Buffer pool hit rate 1000/1000, young-making rate 0/1000 not 0/1000 
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s 
LRU len: 8645010, unzip_LRU len: 0 
I/O sum[469]:cur[0], unzip sum[0]:cur[0] 
-------------- 
ROW OPERATIONS 
-------------- 
1 queries inside InnoDB, 0 queries in queue 
1 read views open inside InnoDB 
Process ID=18963, Main thread ID=47543500240640, state: sleeping 
Number of rows inserted 7973224537, updated 16944890, deleted 452458106, read 549621443211 
6.03 inserts/s, 0.07 updates/s, 0.03 deletes/s, 229179.61 reads/s 
+0

你是什麼意思,「記憶上限?」另外,這個實例有多少「可用內存」? –

+0

@ Michael-sqlbot我想說的是「內存上限」是指我們根據內存計算計算器或內存計算查詢,我們發現內存消耗總量爲149 GB,包括所有線程緩衝內存。 –

+0

無法計算最大內存利用率。 MySQL將根據需要使用盡可能多的內存來處理工作負載。聲稱這樣做的公式通常會計算一個數字,該數字代表一個並非全部有意義的值的較低(非上限)邊界,因爲它假定存在「max_connections」連接。它比最大情況下的最大值更接近最大情況下的最大值。您在實例指標中顯示了多少「可自由使用的內存? –

回答

0

Innodb_buffer_pool_size=144 GB看起來像一個語法錯誤,但其他輸出確認它設置爲144G。

149G的「封頂」 - 這是RDS中的東西嗎?考慮到buffer_pool_size,似乎相當嚴密。

tmp_table_size =4096 MB - 由於這可以分配每查詢,你是嚴重冒着吹RAM的風險。降到1G。\

Max_connections = 20484 - 可笑的大。減少到1000.注意:許多塊內存分配「每個連接」。所以,如果你們每個人都得到20K的一部分,你可能會炸燬RAM。

Innodb_buffer_pool_instances= 1 - 更改爲16以獲得輕微的性能改進。

解決上述問題後,... buffer_pool是一種簡單的方法來減少MySQL的RAM的足跡。如果98%是一個問題,請更改。

+0

沒有RDS概念稱爲」內存上限「。聽起來像某人可能會使用的術語從調優腳本中選擇。 –