Share
Embed
Transcript
24 slides
-
$ whoami 北澤 祥太 / kanata / かなた @kanatakita ShotaKitazawa
所属: LINE 株式会社 Verda 室ネットワーク開発チーム (2022/04〜) 趣味: ラーメン、スノボ、自宅鯖構築、イベント裏方 ISUCON歴: ISUCON6〜 • ISUCON11 予選作問担当, ISUCON9・7 本戦出場 (7は学生枠) 2 よく使う アイコン -
5 web サービスが動いているサーバの ssh アクセス情報が競技者に渡される 競技者がベンチマークを実行するとベンチ用マシン から競技者用マシンへ沢山のリクエストが飛ぶ リクエストが捌けた数等で算出される点数を競う 様々なミドルウェアや特定の言語 (Go,
Python, Ruby, ...) で書かれた Web アプリケーションが配置されている 雑な紹介 -
ツールの誕生背景 • ISUCON で勝つためには「実装→ベンチマーク→プロファイリング」の フィードバックループを限りなく高速に回すことが必要 • もともと弊チームでは以下のデプロイスクリプトを実装し利用していた ◦ 開発用ソフトウェアのインストール ◦
git リポジトリ上のソースコードをデプロイ ◦ プロファイルデータを Slack に POST (プロファイリングは手動) • 競技中、上記スクリプトに困らせられることが多々... ◦ スクリプト内に環境依存な処理がある (eg. web サーバは nginx 前提) ▪ ISUCON10f は Envoy ◦ プロファイルデータ収集スクリプトが複数台構成に対応していない ◦ 複数人でのデプロイが考慮されていない ▪ 「デプロイしまーす」「いいよー」 6 -
isucontinuous https://github.com/ShotaKitazawa/isucontinuous • 「開発→デプロイ→ベンチマーク→プロファイリング」の一連の流れを 複数人で行いやすくするためのツール • 8 種のサブコマンドを提供 ◦ init,
setup, import, push, sync, deploy, profiling, afterbench • 各種コマンドは設定ファイル (isucontinuous.yaml) を元に動作 7 -
init 8 isucontinuous local-repo └─── isucontinuous.yaml setup Git local repository
host01 host02 host03 -
setup 9 isucontinuous host01 host02 host03 install some software (eg.
Docker) based on isucontinuous.yaml local-repo └─── isucontinuous.yaml -
import 10 host01 host02 host03 /etc/nginx /etc/mysql ... /etc/nginx /etc/mysql
... /etc/nginx /etc/mysql ... isucontinuous local-repo ├──── isucontinuous.yaml ├──── host01/… ├──── host02/… └──── host03/… download some files from servers based on isucontinuous.yaml -
push 11 isucontinuous host01 host02 host03 local-repo ├──── isucontinuous.yaml ├────
host01/… ├──── host02/… └──── host03/… push to remote repository -
sync 12 isucontinuous host01 host02 host03 local-repo ├──── isucontinuous.yaml ├────
host01/… ├──── host02/… └──── host03/… fetch & merge from remote repository -
deploy 13 isucontinuous host01 host02 host03 local-repo ├──── isucontinuous.yaml ├────
host01/… ├──── host02/… └──── host03/… fetch & switch to detached branch deploy some files to servers based on isucontinuous.yaml /etc/nginx /etc/mysql ... /etc/nginx /etc/mysql ... /etc/nginx /etc/mysql ... -
profiling 14 isucontinuous host01 host02 host03 execute profiling command via
ssh based on isucontinuous.yaml -
afterbench 15 isucontinuous host01 host02 host03 execute analyze command via
ssh based on isucontinuous.yaml post profile data -
isucontinuous.yaml (1/3) setup: docker: netdata: version: latest public_port: 19999 alp:
version: v1.0.8 slack: default_channel_id: "C012BGJSJMC" hosts: - host: localhost user: &user root key: &key /root/.ssh/id_rsa 16 -
isucontinuous.yaml (2/3) hosts: - … (省略) deploy: &deploy slack_channel_id: ""
pre_command: >- rm -f "{{.Env.ACCESSLOG_PATH}}"; rm -f "{{.Env.SLOWLOG_PATH}}"; post_command: >- sudo systemctl restart mysql nginx && sudo systemctl restart isucondition.go.service targets: - src: nginx target: /etc/nginx - src: mysql target: /etc/mysql - src: go target: /home/isucon/webapp/go compile: make 17 -
isucontinuous.yaml (3/3) hosts: - … (省略) profiling: &profiling command: >-
PPROF_TMPDIR=/pprof/{{.Git.Revision}} /home/isucon/local/go/bin/go tool pprof /home/isucon/webapp/go/isucondition http://localhost:6060/debug/fgprof?seconds=90 after_bench: &after_bench slack_channel_id: "" target: /profile/{{.Git.Revision}}/ command: >- mkdir -p /profile/{{.Git.Revision}}; PPROF_FILENAME=$(ls /root/pprof/tmp/ -tr | tail -n1); if [ -f "/root/pprof/tmp/$PPROF_FILENAME" ]; then /home/isucon/local/go/bin/go tool pprof -top -cum /root/pprof/tmp/$PPROF_FILENAME > /profile/{{.Git.Revision}}/pprof_top_cum; fi; cat "{{.Env.ACCESSLOG_PATH}}" | alp ltsv -r --sort sum > /profile/{{.Git.Revision}}/accesslog; cat "{{.Env.SLOWLOG_PATH}}" | docker run -i --rm matsuu/pt-query-digest > /profile/{{.Git.Revision}}/slowlog; 18 -
ユースケース1: 初期セットアップ 1. init : ローカルリポジトリの新規作成 2. isucontinuous.yaml の編集 3.
setup : 各種開発用ソフトウェアのインストール 4. import : 各種設定ファイルやソースコードを Git で管理 5. push : GitHub に push 19 -
ユースケース2: 開発・デプロイ 1. GitHub に push したリポジトリを元に各メンバーが各ブランチで作業 ※ 開発用ローカルリポジトリは isucontinuous
により作成されたものとは別に用意 2. deploy : 特定リビジョンの各ファイルを各サーバにデプロイ 3. profiling : 各サーバにてプロファイリング用コマンドを実行 4. afterbench : プロファイルデータを収集し Slack に送信 20 -
ユースケース3: 開発中サーバ上の新たなファイルを Git 管理 1. redis 等、サーバーに新たなミドルウェアがインストールされる 2. sync :
ローカルリポジトリを remotes/origin/master と同期 3. isucontinuous.yaml に新たな import/deploy 対象を追記 4. import : 各種設定ファイルやソースコードを Git で管理 5. push : GitHub に push 21