まめ畑

ゆるゆると書いていきます

MySQL5.5 と MySQL5.6 と RDS

MySQL5.6は5.5よりもベンチマーク性能が落ちるという話がここ最近見受けられます。

MySQL5.6の検証は半年程前から本格的に開始して、大量データに対して、JOINやLIMIT、INDEXが不十分なクエリに対して、productionデータで試してみたところ、完全に新規パラメータの設定やデフォルト値の変更を適用していない状態でも性能向上が出ていたので、安定性のテストをしていたのですが、上の記事などを読んでsysbenchやsql-benchを試してみました。
これは基本的なクエリを流すので、複雑な処理を高速化しているとかはあまり考慮されません。
ついでに、RDSもベンチマークを測ってみました。

MySQ5.5と5.6は基本的な設定内容は同一にしてあります。RDSはそのまま5.5のパラメータグループを使用しました。
インスタンスタイプはm2.4xlarge IOPS Optimized Instance。RDSはdb.m2.4xlargeです。
IOPSは2,000です。
5.6に関してはPerformance Schemaをdisableにしたものもとってます

結果

実行時間なので数値が少ないほうがパフォーマンスが良い

The result logs which where found and the options:
 1 mysql-5.5                               : MySQL 5.5.30  
 2 mysql-5.6                               : MySQL 5.6.10  
 3 mysql-5.6-disable_PS                    : MySQL 5.6.10  
 4 mysql-rds                               : MySQL 5.5.27 log

=====================================================================
Operation                           |      1|      2|      3|      4|
                                    |mysql-5|mysql-5|mysql-5|mysql-r|
---------------------------------------------------------------------
Results per test in seconds:                                        |
---------------------------------------------------------------------
ATIS                                |  29.00|  28.00|  28.00|  25.00|
alter-table                         |  26.00|  35.00|  33.00|  22.00|
big-tables                          |  14.00|  14.00|  14.00|  13.00|
connect                             | 329.00| 317.00| 296.00| 310.00|
create                              | 724.00| 956.00| 927.00| 639.00|
insert                              |2682.00|2714.00|2653.00|2479.00|
select                              | 283.00| 315.00| 279.00| 248.00|
wisconsin                           |  61.00|  63.00|  62.00|  53.00|
---------------------------------------------------------------------
The results per operation:                                          |
---------------------------------------------------------------------
alter_table_add (100)               |  12.00|  17.00|  15.00|  10.00|
alter_table_drop (91)               |  11.00|  15.00|  15.00|  10.00|
connect (10000)                     |  16.00|  17.00|  17.00|  19.00|
connect+select_1_row (10000)        |  24.00|  23.00|  20.00|  22.00|
connect+select_simple (10000)       |  21.00|  20.00|  19.00|  22.00|
count (100)                         |   8.00|  11.00|   8.00|   7.00|
count_distinct (1000)               |   4.00|   5.00|   5.00|   4.00|
count_distinct_2 (1000)             |  10.00|  11.00|  10.00|  10.00|
count_distinct_big (120)            |  15.00|  16.00|  16.00|   9.00|
count_distinct_group (1000)         |   9.00|  10.00|   9.00|   7.00|
count_distinct_group_on_key (1000)  |   8.00|   9.00|   8.00|   6.00|
count_distinct_group_on_key_parts (1|   9.00|   8.00|   8.00|   7.00|
count_distinct_key_prefix (1000)    |   4.00|   4.00|   3.00|   2.00|
count_group_on_key_parts (1000)     |   6.00|   7.00|   6.00|   6.00|
count_on_key (50100)                |  75.00|  93.00|  76.00|  58.00|
create+drop (10000)                 | 135.00| 194.00| 185.00| 107.00|
create_MANY_tables (10000)          | 115.00| 119.00| 111.00| 114.00|
create_index (8)                    |   0.00|   0.00|   1.00|   0.00|
create_key+drop (10000)             | 435.00| 590.00| 578.00| 392.00|
create_table (31)                   |   1.00|   0.00|   0.00|   0.00|
delete_all_many_keys (1)            |  10.00|  13.00|  14.00|  18.00|
delete_big (1)                      |   0.00|   0.00|   0.00|   0.00|
delete_big_many_keys (128)          |  10.00|  13.00|  14.00|  18.00|
delete_key (10000)                  |  11.00|  12.00|  12.00|  10.00|
delete_range (12)                   |   3.00|   4.00|   2.00|   3.00|
drop_index (8)                      |   1.00|   1.00|   0.00|   0.00|
drop_table (28)                     |   0.00|   0.00|   0.00|   0.00|
drop_table_when_MANY_tables (10000) |  34.00|  46.00|  47.00|  21.00|
insert (350768)                     | 675.00| 675.00| 670.00| 613.00|
insert_duplicates (100000)          |  40.00|  40.00|  40.00|  41.00|
insert_key (100000)                 | 216.00| 222.00| 219.00| 167.00|
insert_many_fields (2000)           |   7.00|   7.00|   6.00|   5.00|
insert_select_1_key (1)             |   3.00|   3.00|   2.00|   2.00|
insert_select_2_keys (1)            |   4.00|   3.00|   4.00|   2.00|
min_max (60)                        |   4.00|   5.00|   4.00|   4.00|
min_max_on_key (85000)              |  40.00|  41.00|  38.00|  39.00|
multiple_value_insert (100000)      |   1.00|   1.00|   1.00|   1.00|
once_prepared_select (100000)       |  46.00|  47.00|  45.00|  45.00|
order_by_big (10)                   |   9.00|   8.00|   9.00|   8.00|
order_by_big_key (10)               |   8.00|   8.00|   8.00|   7.00|
order_by_big_key2 (10)              |   7.00|   8.00|   7.00|   7.00|
order_by_big_key_desc (10)          |   8.00|   8.00|   8.00|   8.00|
order_by_big_key_diff (10)          |   8.00|   8.00|   7.00|   7.00|
order_by_big_key_prefix (10)        |   9.00|   8.00|   8.00|   8.00|
order_by_key2_diff (500)            |   1.00|   1.00|   1.00|   1.00|
order_by_key_prefix (500)           |   1.00|   0.00|   0.00|   0.00|
order_by_range (500)                |   0.00|   1.00|   1.00|   1.00|
outer_join (10)                     |   9.00|  11.00|  10.00|   9.00|
outer_join_found (10)               |  10.00|  11.00|  10.00|   8.00|
outer_join_not_found (500)          |   7.00|  10.00|   9.00|   7.00|
outer_join_on_key (10)              |   6.00|   8.00|   7.00|   5.00|
prepared_select (100000)            |  49.00|  50.00|  49.00|  50.00|
select_1_row (100000)               |  43.00|  43.00|  41.00|  42.00|
select_1_row_cache (100000)         |  47.00|  43.00|  39.00|  41.00|
select_2_rows (100000)              |  45.00|  44.00|  41.00|  41.00|
select_big (80)                     |   8.00|   8.00|   7.00|   7.00|
select_big_str (10000)              |  12.00|  11.00|  11.00|  10.00|
select_cache (10000)                |  42.00|  50.00|  44.00|  37.00|
select_cache2 (10000)               |  43.00|  49.00|  44.00|  37.00|
select_column+column (100000)       |  44.00|  43.00|  39.00|  39.00|
select_diff_key (500)               |   0.00|   1.00|   0.00|   1.00|
select_distinct (800)               |   3.00|   3.00|   3.00|   2.00|
select_group (2911)                 |  10.00|  11.00|  10.00|   8.00|
select_group_when_MANY_tables (10000|   5.00|   7.00|   6.00|   5.00|
select_join (100)                   |   1.00|   0.00|   0.00|   0.00|
select_key (200000)                 | 103.00| 100.00|  97.00|  99.00|
select_key2 (200000)                | 101.00| 105.00| 101.00| 102.00|
select_key2_return_key (200000)     |  98.00| 101.00|  98.00| 100.00|
select_key2_return_prim (200000)    |  97.00| 102.00|  99.00| 101.00|
select_key_prefix (200000)          | 101.00| 104.00| 101.00| 102.00|
select_key_prefix_join (100)        |   2.00|   2.00|   2.00|   2.00|
select_key_return_key (200000)      |  96.00|  99.00|  97.00|  98.00|
select_many_fields (2000)           |   7.00|   7.00|   8.00|   8.00|
select_range (410)                  |  23.00|  17.00|  17.00|  24.00|
select_range_key2 (25010)           |   9.00|  11.00|  10.00|   9.00|
select_range_prefix (25010)         |  10.00|   9.00|   9.00|  10.00|
select_simple (100000)              |  38.00|  36.00|  34.00|  36.00|
select_simple_cache (100000)        |  39.00|  37.00|  35.00|  37.00|
select_simple_join (500)            |   0.00|   1.00|   1.00|   1.00|
update_big (10)                     |  25.00|  19.00|  19.00|  24.00|
update_of_key (50000)               |  97.00|  99.00|  99.00|  84.00|
update_of_key_big (501)             |  21.00|   8.00|   8.00|  21.00|
update_of_primary_key_many_keys (256|  37.00|  34.00|  34.00|  47.00|
update_with_key (300000)            | 582.00| 591.00| 578.00| 513.00|
update_with_key_prefix (100000)     | 198.00| 200.00| 194.00| 174.00|
wisc_benchmark (114)                |   1.00|   2.00|   1.00|   1.00|
---------------------------------------------------------------------
TOTALS                              |4143.00|4439.00|4289.00|3790.00|
=====================================================================

結果は、確かに、5.6だと性能の劣化がありました。また、Performance Schemaをdisableにすることでパフォーマンスが向上しました。
RDSは更に、性能が良かったです。

注意

これはあくまで、sql-benchのベンチマークをした際の特性であり、ベンチマークの種類によってはこの限りではないという事と、ベンチマークは単純なクエリを大量発行するため、複雑なクエリに対して性能が向上している5.6の特性が生かしきれていないと、コード自体がこなれていないというところを注意してください。
また、もう少し新規パラメータ、デフォルト値の設定を反映した条件での性能試験とベンチマークではなく実際のproductionデータ・クエリでの性能試験を今後ウエイトを上げて評価していきますが、JOIN/LIMIT/INDEX周りの性能向上は計測できています。
また、運用・管理面での大幅な向上・セキュリティ面での向上が5.6で追加されているので、そこの恩恵も考慮する必要があります。

想像以上に健闘しているRDSですが、最適化されているだけあって標準状態でも中々な数値を出していました。
もう少し性能向上が可能かと思いますが、同じパラメータにした場合のパフォーマンスは
memorycraft: RDSってなんじゃ?(MySQL on EBS-PIOPS vs RDS-PIOPS)
で試されている方がいますが、RDSが優っています。


繰り返しになりますが、これはあくまで1つのベンチマーク結果であって、本当の性能は実際の使用状況に即して検証・検討する必要があるので、この結果でMySQL5.6は使えないという結論ではないという事に注意して下さい。

おまけ

2,000IOPSで固定しててもRDSは最大2,500IOPSまでバーストしました。
f:id:con_mame:20130221160919p:plain