kavo’s diary

備忘録

pproteinを競技サーバとは別のサーバに置いて使う

今年のISUCONはpproteinを使ってみようと思う。

pprotein用サーバ作成

  • pprotein用のec2を立てる. 9000port開け
  • static ip割当
  • pproteinインストール、起動、ブラウザアクセス

pprotein→競技サーバアクセス疎通

最初IP直でsettingに書いたが穴開いてないので駄目なんだった。本番ではセキュリティグループはいじれないので、ポートフォワードでやってみる。

pprotein用サーバから競技サーバへポートフォワード実行

ssh isucon@18.182.156.175 -L 127.0.0.1:3001:localhost:3000 -i /tmp/isu13

pproteinのgroup/targetsに以下を設定

[
  {
    "Type": "pprof",
    "Label": "srv1",
    "URL": "http://localhost:3001/debug/pprof/profile",
    "Duration": 60
  },
  {
    "Type": "httplog",
    "Label": "srv1",
    "URL": "http://localhost:3001/debug/log/httplog",
    "Duration": 60
  },
  {
    "Type": "slowlog",
    "Label": "srv1",
    "URL": "http://localhost:3001/debug/log/slowlog",
    "Duration": 60
  }
]

これでアクセスが通るようになった。

自動起動設定

pprotein

sudo vi /etc/systemd/system/pprotein.service

[Unit]
Description=pprotein service

[Service]
ExecStart=/home/isucon/pprotein
WorkingDirectory=/home/isucon
Restart=always
User=isucon

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl restart pprotein.service
sudo systemctl status pprotein.service

ポートフォワード

sudo vi /etc/systemd/system/portforward-srv1.service

[Unit]
Description=SSH port forwarding

[Service]
ExecStart=/usr/bin/ssh -i /tmp/isu13 -L 127.0.0.1:3001:localhost:3000 isucon@18.182.156.175 -N
Restart=always
RestartSec=15
User=isucon

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl restart portforward-srv1.service
sudo systemctl status portforward-srv1.service