チューニング - kota65535/isucon10-qualify GitHub Wiki

MySQLスキーマを確認

cat ../mysql/db/0_Schema.sql

スロークエリーログを出す

sudo mysqldumpslow -s at ../logs/mysql/slow.log

profiler

WSGI Application Profilerを使う

  1. profiler log保存用のディレクトリ作成 mkdir /tmp/profiler (webapp VM)
[isucon@localhost python]$ DB_PORT=3306 DB_USER=isucon DB_PASS=isucon DB_DATABASE=torb DB_HOST=127.0.0.1 /home/isucon/torb/webapp/python/venv/bin/gunicorn -b '127.0.0.1:8080' -w 2 app:app
  1. app.py 修正
  2. requirements.txt に werkzeug==0.14 を追加 (versionごとにドキュメントの違いに注意)
  3. sudo systemctl restart torb.python.service でアプリケーション再起動
  4. 試しにcurlしてみる
$ curl 172.28.128.9/api/events
[{"id": 10, "title": "\u5e73\u6210\u72d0\u5408\u6226\u30d0\u30d6\u30eb\u7d4c\u6e08", "total": 1000, "remains": 1, "sheets": {"S": {"total": 50, "remains": 0, "price": 7000}, "A": {"total": 150, "remains": 0, "price": 5000}, "B": {"total": 300, "remains": 0, "price": 3000}, "C": {"total": 500, "remains": 1, "price": 2000}}}, {"id": 11, "title": "\u77b3\u3092\u6f84\u307e\u305b\u3070", "total": 1000, "remains": 992, "sheets": {"S": {"total": 50, "remains": 50, "price": 8000}, "A": {"total": 150, "remains": 150, "price": 6000}, "B": {"total": 300, "remains": 300, "price": 4000}, "C": {"total": 500, "remains": 492, "price": 3000}}}, {"id": 19, "title": "ePGCgxLNHRsEHqcNiozfpaoUJmqGcyHZ", "total": 1000, "remains": 1000, "sheets": {"S": {"total": 50, "remains": 50, "price": 15000}, "A": {"total": 150, "remains": 150, "price": 13000}, "B": {"total": 300, "remains": 300, "price": 11000}, "C": {"total": 500, "remains": 500, "price": 10000}}}]
  1. profileログを解析
[isucon@localhost python]$ ./venv/bin/gprof2dot -f pstats /tmp/profile/GET.api.events.000909ms.1598720031.prof -o test.dot