Amazon RDS for MariaDBでスレッドプールを利用できるようになりました

2016.03.22

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

久しぶりにAWS関連をエントリするAWSコンサルティング部の藤本です。

概要

MySQL 5.x系はスレッドプール機能を商用プラグインとして提供しています。
(Amazon RDS for MySQLはスレッドプールをサポートしていません)

スレッドプールプラグイン

一方、MariaDBは5.1系からスレッドプールを標準提供しています。
MariaDB 10.0.17であるRDS for MariaDBもスレッドプールを提供しています。が、実は先日まで利用することができませんでした。

それがRDS for MariaDBのパラメータグループのthread_handlingにpool-of-threadsを指定可能となりました。

経緯

先日、RDS for MariaDBでスレッドプールを利用しようとしたところ、RDSが起動しなくなりました。

RDS for MariaDBのパラメータグループにthread_handlingというコネクションのスレッド利用方式に関する設定があります。

# aws rds describe-db-parameters --db-parameter-group-name thread-handling-test |jq -r ".Parameters[] |select(.ParameterName == \"thread_handling\")"
{
  "ApplyMethod": "pending-reboot",
  "Description": "Determines how the server handles threads.",
  "DataType": "string",
  "AllowedValues": "no-threads,one-thread-per-connection,pool-of-threads",
  "Source": "engine-default",
  "IsModifiable": true,
  "ParameterName": "thread_handling",
  "ApplyType": "static"
}

スレッドプールを利用する場合、thread_handlingをpool-of-threadsに指定します。

先日まではパラメータグループを設定し、RDSインスタンスを再起動したところ、「再起動」ステータスからずっと変わらない状況でした。

ログのerror/mysql-error-running.logを確認すると以下のメッセージが出力され、再起動が繰り返されます。

160125 9:18:23 [ERROR] /rdsdbbin/mysql/bin/mysqld: Error while setting value 'pool-of-threads#' to 'thread_handling'
160125 9:18:23 [ERROR] Aborting

160125 9:22:29 [ERROR] /rdsdbbin/mysql/bin/mysqld: Error while setting value 'pool-of-threads#' to 'thread_handling'
160125 9:22:29 [ERROR] Aborting

それが本日より利用可能となりました。

パラメータグループを変更します。

RDS_·_AWS_Console

RDSインスタンスを再起動します。

screenshot_2016-03-22_11_27_44(2)_png_png

再起動を待ちます。

無事に起動しました。

RDS_·_AWS_Console 2

MariaDBに接続して、パラメータを確認します。

# mysql -h ***************.ap-northeast-1.rds.amazonaws.com -ufujimoto -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.5.5-10.0.17-MariaDB MariaDB Server

Copyright (c) 2000, 2016, 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 variables like 'thread_handling';
+-----------------+-----------------+
| Variable_name   | Value           |
+-----------------+-----------------+
| thread_handling | pool-of-threads |
+-----------------+-----------------+
1 row in set (0.01 sec)

まとめ

今回のアップデートは私には嬉しいアップデートでした。
MySQL互換のAmazon Auroraが登場していたこともあり、RDS for MariaDBの登場に驚いていたのですが、今回はパッケージソフトウェアのパフォーマンス向上、サポート範囲でMariaDB一択となっていたため、結果、RDS for MariaDBの登場は嬉しいものとなりました。あとはMariaDBはリリースペースが早いのでどのようなペースでRDSがサポートしていくのかに注目したいです。