HDDとSSDで、MySQLのベンチマークスコアがどのくらい変化するのか実験してみた

今日は、社内サーバの移行作業を行っています。
最近、他の社員から頻繁に「サーバが遅い」と言われているので、思い切って新しいマシンを購入しました。
スペックは以下の通り。

  • CPU・・・Core i7 860(2.80GHz、4コア)
  • メモリ・・・8GB
  • OS・・・Ubuntu 9.10 64bit

サーバというか、ただのデスクトップなんですが、スペック的には申し分ありません。


そして、ストレージには、SATA接続で現在最速と言われるPhotoFast G-Monster V5の128GBをチョイス。
Read 270MB/s、Write 230MB/sという怪物です。
本当は、Write 270MB/sの256GBモデルが欲しかったのですが、どこの店も在庫切れということで購入することができませんでした。
お店の人に聞いても、すごく評判がいいみたいです。これは、名機の予感・・。


ベンチマークツールには、sysbenchを用意。
なんでこのツールにしたかというと、apt-getでインストールできてラクだったから。


下記の設定で、ベンチマークを行います。


# sysbench --test=oltp --oltp-table-size=1000000 --num-threads=4 --max-requests=0 --max-time=180 --oltp-test-mode=complex --mysql-user=root run

-

まずは、HDDのベンチマークから。

  • 500GB SATA 7,200rpm HDD(メーカーは忘れた)
  • Ubuntuは、デスクトップ版を使用

結果


sysbench 0.4.10: multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
WARNING: Preparing of "BEGIN" is unsupported, using emulation
(last message repeated 3 times)
Running the test with following options:
Number of threads: 4

Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations, 1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Threads started!
Time limit exceeded, exiting...
(last message repeated 3 times)
Done.

OLTP test statistics:
queries performed:
read: 53662
write: 19165
other: 7666
total: 80493
transactions: 3833 (21.28 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 72827 (404.32 per sec.)
other operations: 7666 (42.56 per sec.)

Test execution summary:
total time: 180.1203s
total number of events: 3833
total time taken by event execution: 720.2343
per-request statistics:
min: 32.44ms
avg: 187.90ms
max: 1371.09ms
approx. 95 percentile: 535.88ms

Threads fairness:
events (avg/stddev): 958.2500/8.61
execution time (avg/stddev): 180.0586/0.03


そして、今度はSSDに換装して計測。

結果


sysbench 0.4.10: multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
WARNING: Preparing of "BEGIN" is unsupported, using emulation
(last message repeated 3 times)
Running the test with following options:
Number of threads: 4

Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations, 1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Threads started!
Time limit exceeded, exiting...
(last message repeated 3 times)
Done.

OLTP test statistics:
queries performed:
read: 848540
write: 303050
other: 121220
total: 1272810
transactions: 60610 (336.69 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 1151590 (6397.10 per sec.)
other operations: 121220 (673.38 per sec.)

Test execution summary:
total time: 180.0176s
total number of events: 60610
total time taken by event execution: 719.6126
per-request statistics:
min: 1.57ms
avg: 11.87ms
max: 240.64ms
approx. 95 percentile: 61.80ms

Threads fairness:
events (avg/stddev): 15152.5000/182.45
execution time (avg/stddev): 179.9032/0.01


なんと、SSDに換装しただけで、クエリパフォーマンスの合計値が15.8倍にアップしました。SSD恐るべし!


最後に、MySQLInnoDB Pluginをインストールして計測してみます。
このPluginの素晴らしさについては、こちらのサイトで詳しく解説されていますので、合わせて読んでみてください。なお、今回だけUbuntuは、サーバ版を使用しています。
SSDの真の性能を引き出す MySQL 5.1.38 InnoDB Plugin


sysbench 0.4.10: multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
WARNING: Preparing of "BEGIN" is unsupported, using emulation
(last message repeated 3 times)
Running the test with following options:
Number of threads: 4

Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations, 1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Threads started!
Time limit exceeded, exiting...
(last message repeated 3 times)
Done.

OLTP test statistics:
queries performed:
read: 2543114
write: 908255
other: 363302
total: 3814671
transactions: 181651 (1008.82 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 3451369 (19167.62 per sec.)
other operations: 363302 (2017.64 per sec.)

Test execution summary:
total time: 180.0625s
total number of events: 181651
total time taken by event execution: 719.2517
per-request statistics:
min: 1.38ms
avg: 3.96ms
max: 159.57ms
approx. 95 percentile: 11.71ms

Threads fairness:
events (avg/stddev): 45412.7500/1086.10
execution time (avg/stddev): 179.8129/0.01


Pluginを追加しただけで、HDD比47.8倍までスコアが伸びました。
これは、本番稼動が楽しみです。