概要
AWS で選択できるPublic AMI が公開されている
AMIをどう使うか? 参考になりそうな資料 https://blog.okashoi.net/entry/2017/07/17/154426 以下に従うのがよさそう https://questbeat.hatenablog.jp/entry/2020/09/08/234308
ISUCON9でやってみる
https://IP でもうアクセス可能
# AMI から作成
https://github.com/matsuu/aws-isucon
ami-03b1b78bb1da5122f
# ログイン後入れ替え
sudo -i -u isucon
cd /home/isucon/isucari
cat README.md
sudo vi /etc/nginx/sites-enabled/isucari.conf
# listenを80にする
sudo service nginx restart
ベンチマーク実行
./bin/benchmarker
# 失敗
curl https://localhost/ --insecure
./bin/benchmarker -target-url string
target url (default "http://127.0.0.1:8000")
./bin/benchmarker -target-url "http://18.180.86.212/"
./bin/benchmarker -shipment-url http://localhost:54530 -target-url http://localhost
別インスタンスで相手のローカルIP指定
./bin/benchmarker -target-url "http://172.31.27.124"
./bin/benchmarker -target-url "http://172.31.27.124" -payment-port
Usage of isucon9q:
-allowed-ips string
allowed ips (comma separated)
-data-dir string
data directory (default "initial-data")
-payment-port int
payment service port (default 5555)
-payment-url string
payment url (default "http://localhost:5555")
-shipment-port int
shipment service port (default 7000)
-shipment-url string
shipment url (default "http://localhost:7000")
-static-dir string
static file directory (default "webapp/public/static")
-target-host string
target host (default "isucon9.catatsuy.org")
-target-url string
target url (default "http://127.0.0.1:8000")
エラーは放置で良さそうか? 初回スコア
./bin/benchmarker \
-target-url http://localhost:8000 \
-payment-url http://localhost:5555 \
-shipment-url http://localhost:7000
{"pass":true,"score":2110,"campaign":0,"language":"Go","messages":[]}
やってみる
https://ohbarye.hatenablog.jp/entry/2020/07/24/isucon9-practice
sudo mysql
show databases;
use isucari;
CREATE INDEX created_at ON items (created_at);
CREATE INDEX seller_id ON items (seller_id);
CREATE INDEX buyer_id ON items (buyer_id);
{"pass":true,"score":2120,"campaign":0,"language":"Go","messages":[]}
cd /isucari/webapp/frontend$ npm i
npm run deploy
バックエンド切り替え
https://github.com/isucon/isucon9-qualify/blob/master/docs/manual.md
sudo systemctl stop isucari.golang.service
sudo systemctl start isucari.python.service
sudo find /etc/systemd -name *isucari*
sudo cat /etc/systemd/system/isucari.python.service
[Unit]
Description = isucon9 qualifier main application in python
[Service]
WorkingDirectory=/home/isucon/isucari/webapp/python
EnvironmentFile=/home/isucon/env.sh
ExecStart = /home/isucon/isucari/webapp/python/venv/bin/gunicorn app:app -w 10 -b '127.0.0.1:8000'
Restart = always
Type = simple
User = isucon
Group = isucon
[Install]
WantedBy = multi-user.target
/home/isucon/isucari/webapp/python
を起動している
python score
{"pass":true,"score":1110,"campaign":0,"language":"python","messages":[]}
find . -type f -print | xargs grep 'transactions.json'
なんとなく理解した。 この状態でバックエンドやフロントを改善し、ベンチマークをあげれば良さそう