LoginSignup
3
0

More than 5 years have passed since last update.

小ネタ/Aurora Serverlessのバッファプール(バッファキャッシュ)の動きを見てみた

Last updated at Posted at 2018-08-20

AWS Aurora Serverless が GA 化とともに東京リージョンでの使えるようになりました。

すでに色々な記事が出ていますが、私はいつもの通りバッファプール(バッファキャッシュ)の挙動について確認してみました。

一時停止→復帰の場合

Aurora Serverless は、クライアントからの接続がない状態で一定時間(設定可能。デフォルトは 5 分間)を経過すると一時停止(pause)状態になります。
一時停止状態で再接続すると、15 ~ 30 秒程度経過後、一時停止時と同じキャパシティユニットのサイズで復帰(resume)するのですが、このときバッファプール(バッファキャッシュ)がどうなるのか確認してみます。

最初の状態
$ mysql -u mkadmin -h test.cluster-XXXXXX.ap-northeast-1.rds.amazonaws.com -p --default-character-set=utf8mb4
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.10 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW ENGINE INNODB STATUS\G
*************************** 1. row ***************************
  Type: InnoDB
  Name:
Status:
=====================================
2018-08-20 07:47:04 2b47aaa43700 INNODB MONITOR OUTPUT
=====================================
(中略)
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 0; in additional pool allocated 0
Dictionary memory allocated 185320
Buffer pool size   98162
Free buffers       97933
Database pages     229
Old database pages 0
Modified db pages  0
Pending reads 0
Pending writes: LRU 0, flush list 0 single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 229, created 0, written 0
0.00 reads/s, 0.00 creates/s, 0.00 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: 229, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
(以降省略)

Free buffersDatabase pagesの数値の通り、起動直後は空に近い状態です。
ここで、適当に用意したテーブルのチェックサムを実行してみます。

データページ読み込み
mysql> CHECKSUM TABLE backup_restore_test.text_table_01;
+-----------------------------------+-----------+
| Table                             | Checksum  |
+-----------------------------------+-----------+
| backup_restore_test.text_table_01 | 495039982 |
+-----------------------------------+-----------+
1 row in set (4 min 44.35 sec)

mysql> SHOW ENGINE INNODB STATUS\G
*************************** 1. row ***************************
  Type: InnoDB
  Name:
Status:
=====================================
2018-08-20 07:53:19 2b47aaa84700 INNODB MONITOR OUTPUT
=====================================
(中略)
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 0; in additional pool allocated 0
Dictionary memory allocated 200431
Buffer pool size   98162
Free buffers       2048
Database pages     96114
Old database pages 35438
Modified db pages  0
Pending reads 0
Pending writes: LRU 0, flush list 0 single page 0
Pages made young 169, not young 5258610
0.00 youngs/s, 0.00 non-youngs/s
Pages read 614679, created 10, written 0
0.00 reads/s, 0.00 creates/s, 0.00 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: 96114, unzip_LRU len: 0
I/O sum[776]:cur[0], unzip sum[0]:cur[0]
(以降省略)

Database pagesが増えて、読み込まれたことがわかります。
この状態でクライアントからの接続を切り、5 分(デフォルト通り)待ってから再接続します。

再接続後
$ mysql -u mkadmin -h test.cluster-XXXXXX.ap-northeast-1.rds.amazonaws.com -p --default-character-set=utf8mb4
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.10 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW ENGINE INNODB STATUS\G
*************************** 1. row ***************************
  Type: InnoDB
  Name:
Status:
=====================================
2018-08-20 08:03:58 2aee84ac2700 INNODB MONITOR OUTPUT
=====================================
(中略)
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 0; in additional pool allocated 0
Dictionary memory allocated 176617
Buffer pool size   98162
Free buffers       97934
Database pages     228
Old database pages 0
Modified db pages  0
Pending reads 0
Pending writes: LRU 0, flush list 0 single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 227, created 1, written 0
11.35 reads/s, 0.05 creates/s, 0.00 writes/s
Buffer pool hit rate 964 / 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: 228, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
(以降省略)

消えてしまったようです。

手動でキャパシティユニットを変更した場合

ここで、一旦またテーブルのチェックサムを実行してから、キャパシティユニットを最初の 2 から 4 へ増やしてみました。
実行結果の記録は省略しますが、10 ~ 20 秒経過後にキャパシティユニットが増加すると、やはりバッファプール(バッファキャッシュ)は消えました。

自動でキャパシティユニットが変更された場合

未検証ですが、おそらく消えるはずです。


8/22追記:
キャパシティユニットを手動で 4 にした後、自動的に 2 に減ったときに確認してみたところ、やはり消えました。
手動の場合と同様、総メモリ容量の変化とともにバッファプール(バッファキャッシュ)に割り当てられるメモリの容量も変化するため、当然と言えば当然ですね。


その他

Aurora Serverlessについて、この検証中に色々わかったことがあるので、別の記事にまとめる予定ですました。


3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0