isucon4...
TRANSCRIPT
ISUCON4 予選問題でアプリケーションコードを変更せず、”my.cnf”に1行だけ足して、予選通過ラインを突破するの術
MySQL Casual Talks vol.7ISUCON芸人 長野雅広 a.k.a kazeburo
ISUCON知らない方?
何を変更したのか• インデックスの追加
• アプリケーションをPerlに変更
• アプリケーションサーバの変更と起動設定のチューニング
• nginx での画像/CSS/JavaScript配信
• nginx <=> アプリケーションサーバ間をTCPからunix domain socket に
• my.cnfのチューニング
もし、my.cnf を変更しなかったら?
Benchmark04:02:01 type:info message:launch benchmarker04:02:01 type:warning message:Result not sent to server because API key is not set04:02:01 type:info message:init environment04:02:10 type:info message:run benchmark workload: 804:03:10 type:info message:finish benchmark workload: 804:03:15 type:info message:check banned ips and locked users report04:03:17 type:report count:banned ips value:61904:03:17 type:report count:locked users value:441304:03:18 type:info message:Result not sent to server because API key is not set
04:03:18 type:score success:189510 fail:0 score:40937
40,937 / 37,808
予選通過ライン
( ゚д゚)超えちゃった
タイトル変更
ISUCON4 予選問題でアプリケーションコードを変更せず、”my.cnf ”に1行だけ足して、さらに高得点を狙う
ISUCON4のアプリケーション
• いすこん銀行• ログイン機能のみ• パスワードリスト攻撃• ログイン失敗の多いIPアドレスを拒否、アカウントロックする
ISUCON4のアプリケーション
• MySQLからみると
• ログインログの書き込みが発生• 処理データ量は 40MB 程度
MySQL のバージョン
$ rpm -qa|grep mysqlmysql55-libs-5.5.40-1.3.amzn1.x86_64mysql-devel-5.5-1.6.amzn1.noarchmysql55-server-5.5.40-1.3.amzn1.x86_64mysql55-common-5.5.40-1.3.amzn1.x86_64mysql55-5.5.40-1.3.amzn1.x86_64mysql55-devel-5.5.40-1.3.amzn1.x86_64mysql-server-5.5-1.6.amzn1.noarch 5.5.40
my.cnf
[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.socksymbolic-links=0
max_allowed_packet=300M
[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid
1行追加するとしたら?やってみた
innodb_buffer_pool_size = 1G
41,359 / 40,937デフォルト 128MB なので増やすメリット大きくない
innodb_#ush_log_at_trx_commit = 2
45,053 / 40,937EC2 で Storageは HDD なのでIOが遅延できる効果は大きい
innodb_#ush_log_at_trx_commit = 0
45,792 / 40,937
“2” ですでに十分だった?
innodb_#ush_method=O_DIRECT
40,726 / 40,937
変わらない。次への伏線です
innodb_#ush_method=nosync
45,711 / 40,937innodb_#ush_log_at_trx_commit = 0 と
だいたい同じ効果?
innodb_doublewrite = 0
40,921 / 40,937
変わらず
innodb_max_purge_lag=100000
40,558 / 40,937
変わらず
innodb_max_dirty_pages_pct=99
41,236 / 40,937
変わらず
innodb_log_$le_size=32M
40,724 / 40,937
変わらず
結果
ISUCONにおける王道設定
innodb_#ush_log_at_trx_commit = 0innodb_#ush_method = nosync
それはちょっと。。
ISUCONにおける王道設定
innodb_buffer_pool_size = 1GBinnodb_#ush_log_at_trx_commit = 2
innodb_#ush_method = O_DIRECT
ご清聴ありがとうございました