東京に来た!コミットやフェイルオーバーが高速でスタンバイ機にもアクセス可能な RDS の高可用性オプションが利用可能になりました

新しい RDS の高可用性オプションが東京に来ました!Aurora と同様にスタンバイ機へ読み取り専用でアクセスできるので、速度だけでなくコスト効率も良いです。

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

ウィスキー、シガー、パイプをこよなく愛する大栗です。

2週間ほど前に、RDS の新しい高可用性オプションで、コミットレイテンシが高速で、フェイルオーバーも速い Multi-AZ DB Cluster が一般提供された事をレポートしました。本日東京でも利用可能になったので確認してみます。

サービス自体の詳細は、前回のエントリをご確認ください。

Multi-AZ DB Cluster

従来の高可用性オプションでは、2台構成で片方がアクセスできないスタンバイ機になっており実質1台として運用する構成でした。新しいオプションである Multi-AZ DB Cluster では3台構成となりスタンバイ機の2台へも読み取り専用でアクセスが可能になっており、レプリカ台数が固定の Amazon Aurora といった感覚のイメージで利用できます。スタンバイ機も利用可能なので、コスト効率も高くなっています。

Multi-AZ DB cluster deployments

AWS Documentation > Amazon Relational Database Service (RDS) > User Guide > Multi-AZ DB cluster deployments https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/multi-az-db-clusters-concepts.html より引用

従来の高可用性オプションとの違い

従来の高可用性オプションとの比較は以下のようになります。

項目 Multi-AZ DB Instance
従来からの機能
Multi-AZ DB Cluster
新機能
DB エンジン Amazon RDS for MariaDB, Amazon RDS for MySQL, Amazon RDS for PostgreSQL, Amazon RDS for Oracle, Amazon RDS for SQL Server Amazon RDS for PostgreSQL, Amazon RDS for MySQL
追加の読み取り容量 なし:スタンバイインスタンスへアクセスできない。ただし別途リードレプリカを構成可能。 2台のスタンバイインスタンスへ読み取りアクセスが可能。追加のリードレプリカは構成できない。
トランザクションコミット Multi-AZ DB Instance と比較して最大2倍高速なトランザクションコミット
フェイルオーバー時間 フェイルオーバー時間は通常 60~120 秒 フェイルオーバー時間は通常 35 秒未満。未処理のトランザクション量に依存する。
AZ 停止に対する回復力 自動的に最新インスタンスへフェイルオーバーする 残り2台のスタンバイの1台が引き継ぎプライマリの書き込みワークロードを処理する
トランザクションコミットのジッタ 書き込みパスの障害に影響を受けやすい 3台中2台の書き込みクォーラムを使用。最大1個の障害のある書き込みパスに影響されない

リージョン

リージョンは東京!とオハイオが追加になりました。

  • 米国東部 (バージニア北部): us-east-1
  • 米国東部 (オハイオ): us-east-2 New!
  • 米国西部 (オレゴン): us-west-2
  • 欧州 (アイルランド): eu-west-1
  • アジアパシフィック (東京): ap-northeast-1 New!

やってみる

基本的に前回の手順と同様です。前回詳しく紹介しているので、ざっと紹介していきます。

今回は MySQL で構築します。バージョンは Multi-AZ DB Cluster に対応している 8.0.28 を選択します。

可用性と耐久性でMulti-AZ DB Clisterを選択します。

今回は検証なので、最も小さいdb.m6gd.largeを選択しました。

ストレージは最小の 100 GiB、1000 IOPS としています。

起動するまでしばらくかかります。

起動すると、このようにエンドポイントがわかるのでログインしてみます。

ライターエンドポイントにアクセスします。

$ mysql -u admin -ppassword -h database-1.cluster-123456789012.ap-northeast-1.rds.amazonaws.com
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 60
Server version: 8.0.28 Source distribution

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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>

source のステータスを確認してみます。

mysql> show master status;
+----------------------------+----------+--------------+------------------+-------------------------------------------+
| File                       | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                         |
+----------------------------+----------+--------------+------------------+-------------------------------------------+
| mysql-bin-changelog.000015 |      197 |              |                  | e206f978-a4c2-11ec-b397-0a068c636f95:1-16 |
+----------------------------+----------+--------------+------------------+-------------------------------------------+
1 row in set (0.00 sec)

次はリーダーエンドポイントにログインします。

$ mysql -u admin -ppassword -h database-1.cluster-ro-123456789012.ap-northeast-1.rds.amazonaws.com
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 73
Server version: 8.0.28 Source distribution

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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>

source と replica のステータスを確認してみます。

mysql> show master status;
+----------------------------+----------+--------------+------------------+-------------------------------------------+
| File                       | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                         |
+----------------------------+----------+--------------+------------------+-------------------------------------------+
| mysql-bin-changelog.000014 |      509 |              |                  | e206f978-a4c2-11ec-b397-0a068c636f95:1-18 |
+----------------------------+----------+--------------+------------------+-------------------------------------------+
1 row in set (0.00 sec)

mysql> show slave status;
+----------------------------------+--------------+--------------+-------------+---------------+----------------------------+---------------------+-----------------+---------------+----------------------------+------------------+-------------------+-----------------+---------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+---------------------------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+--------------------------------------+-------------------------+-----------+---------------------+--------------------------------------------------------+--------------------+-------------+-------------------------+--------------------------+----------------+--------------------+-------------------------------------------+-------------------------------------------+---------------+----------------------+--------------+--------------------+------------------------+-----------------------+-------------------+
| Slave_IO_State                   | Master_Host  | Master_User  | Master_Port | Connect_Retry | Master_Log_File            | Read_Master_Log_Pos | Relay_Log_File  | Relay_Log_Pos | Relay_Master_Log_File      | Slave_IO_Running | Slave_SQL_Running | Replicate_Do_DB | Replicate_Ignore_DB | Replicate_Do_Table | Replicate_Ignore_Table                                                                               | Replicate_Wild_Do_Table | Replicate_Wild_Ignore_Table | Last_Errno | Last_Error | Skip_Counter | Exec_Master_Log_Pos | Relay_Log_Space | Until_Condition | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | Master_SSL_CA_File                    | Master_SSL_CA_Path | Master_SSL_Cert | Master_SSL_Cipher | Master_SSL_Key | Seconds_Behind_Master | Master_SSL_Verify_Server_Cert | Last_IO_Errno | Last_IO_Error | Last_SQL_Errno | Last_SQL_Error | Replicate_Ignore_Server_Ids | Master_Server_Id | Master_UUID                          | Master_Info_File        | SQL_Delay | SQL_Remaining_Delay | Slave_SQL_Running_State                                | Master_Retry_Count | Master_Bind | Last_IO_Error_Timestamp | Last_SQL_Error_Timestamp | Master_SSL_Crl | Master_SSL_Crlpath | Retrieved_Gtid_Set                        | Executed_Gtid_Set                         | Auto_Position | Replicate_Rewrite_DB | Channel_Name | Master_TLS_Version | Master_public_key_path | Get_master_public_key | Network_Namespace |
+----------------------------------+--------------+--------------+-------------+---------------+----------------------------+---------------------+-----------------+---------------+----------------------------+------------------+-------------------+-----------------+---------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+---------------------------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+--------------------------------------+-------------------------+-----------+---------------------+--------------------------------------------------------+--------------------+-------------+-------------------------+--------------------------+----------------+--------------------+-------------------------------------------+-------------------------------------------+---------------+----------------------+--------------+--------------------+------------------------+-----------------------+-------------------+
| Waiting for master to send event | 172.23.1.134 | rdsrepladmin |        3306 |            60 | mysql-bin-changelog.000016 |            574 | relaylog.000042 |           810 | mysql-bin-changelog.000016 | Yes              | Yes               |      |                     |                    | innodb_memcache.cache_policies,innodb_memcache.config_options,mysql.plugin,mysql.rds_history,mysql.rds_monitor,mysql.rds_replication_status,mysql.rds_sysinfo |                         |     |          0 |            |            0 |                 574 |            1110 | None            |                |     0 | Yes                | /rdsdbdata/rds-metadata/root-cert.pem |                    |                 |                   |              |                     0 | No                            |             0 |               |              0 |      |                             |         96199342 | e206f978-a4c2-11ec-b397-0a068c636f95 | mysql.slave_master_info |0 |                NULL | Slave has read all relay log; waiting for more updates |              86400 |             |            |                          |                |                    | e206f978-a4c2-11ec-b397-0a068c636f95:6-18 | e206f978-a4c2-11ec-b397-0a068c636f95:1-18 |             1 |                      |              |                    |     |                     0 |                   |
+----------------------------------+--------------+--------------+-------------+---------------+----------------------------+---------------------+-----------------+---------------+----------------------------+------------------+-------------------+-----------------+---------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+---------------------------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+--------------------------------------+-------------------------+-----------+---------------------+--------------------------------------------------------+--------------------+-------------+-------------------------+--------------------------+----------------+--------------------+-------------------------------------------+-------------------------------------------+---------------+----------------------+--------------+--------------------+------------------------+-----------------------+-------------------+
1 row in set, 1 warning (0.01 sec)

このようにライターもリーダーも普通にアクセス可能です。

さいごに

2週間で日本にも来ました。3 AZ を使った高可用性構成で、フェイルオーバーが速く、書き込みコミットも高速、スタンバイ機にも読み取り専用でアクセスできると、いい事尽くめです。現状は小さなインスタンスを選択できないため、一定以上の負荷がある本番ワークロードで、何らかの理由により Amazon Aurora が使えない場合では最適だと思いますので、是非お試しください。