isucon5予選をフレームワークに載せ替えてみるヤツ
紆余曲折あってただの素振り。
git clone git@github.com:matsuu/vagrant-isucon.git
cd isucon5-qualifier
# vagrantのportを変更
# config.vm.network "forwarded_port", guest: 3306, host: 23306, auto_correct: true
vagrant up
sudo systemctl stop isuxi.ruby
sudo systemctl disable isuxi.ruby
sudo systemctl enable isuxi.go
sudo systemctl start isuxi.go
GRANT ALL ON *.* to isucon@"10.0.%" identified by '' with grant option;
FLUSH PRIVILEGES;
/etc/mysql/mysql.conf.d/mysqld.cnfのbind-address
を0.0.0.0
にする
sudo systemctl restart mysql
cp ../../isucon5-qualify/webapp/go/app.go .
cp -pr ../../isucon5-qualify/webapp/go/templates
GOOS=linux GOARCH=amd64 go build app.go
sudo systemctl restart isuxi.go
sudo systemctl status isuxi.go
https://github.com/tkuchiki/alp
cat access.log | ./alp --max -r
基本slow_logをONにしといて、最後にOFF
mysql> show variables like 'long_query%';
mysql> show variables like 'slow_query%';
mysql> set global slow_query_log=1;
# 実行時間が遅い順
$ mysqldumpslow -s at /var/lib/mysql/vagrant-slow.log > /home/isucon/slow.log
# 実行回数が多い順
$ mysqldumpslow -s c /var/lib/mysql/vagrant-slow.log > /home/isucon/slow.log
504.3
{"success"=>488, "redirect"=>163, "failure"=>1, "error"=>0, "exception"=>0}
558.5
{"success"=>541, "redirect"=>175, "failure"=>1, "error"=>0, "exception"=>0}
nginxのrestart
sudo systemctl restart nginx.service
636.9
{"success"=>617, "redirect"=>199, "failure"=>1, "error"=>0, "exception"=>0}
mysqlのrestart
sudo systemctl restart mysql
mysql_config --socket
でsocketの場所確認。引数で/var/run/mysqld/mysqld.sock
を指定してて接続できない罠があった
wget http://download.redis.io/releases/redis-4.0.2.tar.gz
tar xzf redis-4.0.2.tar.gz
cd redis-4.0.2
make
sudo make install
sudo groupadd redis
sudo useradd -s /sbin/nologin -M -g redis redis
sudo mkdir /var/run/redis
sudo chmod 755 /var/run/redis
sudo chown redis:redis /var/run/redis
sudo mkdir /var/log/redis
sudo chmod 755 /var/log/redis
sudo chown redis:redis /var/log/redis
sudo mkdir /etc/redis
sudo chown redis:redis /etc/redis
mkdir /home/isucon/webapp/go/etc/redis;
cp -pr redis.conf /home/isucon/webapp/go/etc/redis/.
redis-server.serviceを/etc/systemd/system/に置く
sudo ln -s /home/isucon/webapp/go/etc/redis/redis.conf /etc/redis/.
sudo systemctl start redis-server
/usr/local/bin/redis-cli
で接続できたらOK
sudo /sbin/sysctl -p
632.1
{"success"=>613, "redirect"=>191, "failure"=>1, "error"=>0, "exception"=>0}
誤差。 リクエストをさばけるようになったら生きてくるでしょう。
654.5
{"success"=>634, "redirect"=>205, "failure"=>1, "error"=>0, "exception"=>0}
ごみの修正
845.9
{"success"=>821, "redirect"=>249, "failure"=>1, "error"=>0, "exception"=>0}
816.3
{"success"=>792, "redirect"=>243, "failure"=>1, "error"=>0, "exception"=>0}
1394.3
{"success"=>1355, "redirect"=>393, "failure"=>1, "error"=>0, "exception"=>0}
1729.3
{"success"=>1681, "redirect"=>483, "failure"=>1, "error"=>0, "exception"=>0}
1884.1
{"success"=>1833, "redirect"=>511, "failure"=>1, "error"=>0, "exception"=>0}
7428.5
{"success"=>7230, "redirect"=>1985, "failure"=>1, "error"=>0, "exception"=>0}
7428.5
{"success"=>7230, "redirect"=>1985, "failure"=>1, "error"=>0, "exception"=>0}
7285.4
{"success"=>7092, "redirect"=>1934, "failure"=>1, "error"=>0, "exception"=>0}
7730.7
{"success"=>7524, "redirect"=>2067, "failure"=>1, "error"=>0, "exception"=>0}
8756.3
{"success"=>8523, "redirect"=>2333, "failure"=>1, "error"=>0, "exception"=>0}
なんか、redisから取れてないケースがある。。 1件取得するだけなら、redisもmysqlもそこまで変わらないのかも。
8920.1
{"success"=>8682, "redirect"=>2381, "failure"=>1, "error"=>0, "exception"=>0}