https://github.com/doarakko/isucon13
https://github.com/doarakko/isucon13
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/doarakko/isucon13
- Owner: Doarakko
- Created: 2024-10-10T09:43:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-08T14:51:38.000Z (over 1 year ago)
- Last Synced: 2025-03-25T07:03:46.163Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 614 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# isucon13
## Manual
- [本選当日マニュアル](https://github.com/isucon/isucon13/blob/main/docs/cautionary_note.md)
- [アプリケーションマニュアル](https://github.com/isucon/isucon13/blob/main/docs/isupipe.md)
- [コード](https://github.com/isucon/isucon13)
## Rules
- 1つの修正ごとにブランチを切ってベンチマークを実行する
- ブランチ名はアルファベット・数字のみで記号は含めない
- 以下を PR に添付する
- ベンチマークの実行結果
- スロークエリの解析結果
- アクセスログの解析結果
## Getting Started
### GitHub issue の作成
各種手順を Todo リストにしたテンプレートを用意しているためそちらを利用する
### ssh
各種コマンドは isucon ユーザーで SSH 接続する想定で作られています。
isucon ユーザーで SSH できるように、以下を参考に公開鍵を登録してください。
https://isucon-workshop.trap.show/text/chapter-2/2-EnterServerAndSomeSetting.html
#### local host
```sh
cd ~/.ssh
ssh-keygen -t ed25519 -f isucon13
cat ~/.ssh/isucon13.pub
```
`~/.ssh/config`
```
Host isucon13
HostName ec2-18-179-36-166.ap-northeast-1.compute.amazonaws.com
User isucon
IdentityFile ~/.ssh/isucon13.pub
```
#### remote host
```sh
echo "" >> ~/.ssh/authorized_keys
```
### GitHub
https://isucon-workshop.trap.show/text/chapter-3/0-Github.html
### 秘伝のタレを配置
- `Makefile`
- 各種変数を更新
- `BIN_NAME`
- `SERVICE_NAME`
- `MYSQL_DB_NAME`
- ベンチ実行コマンドを更新
- `setup.sh`
- `deploy.sh`
- 接続する SSH ユーザ名を更新
- `config/alp.yml`
### Setup tools
- MySQL・nginx の設定ファイルをホームディレクトリ下にコピー
- alp
- pt-query-digest
- pprof
```sh
ssh isucon13
make setup
```
### MySQL・nginx の設定ファイルをGit管理
`make setup` 実行後に行うこと
```sh
git add mysql/* nginx/*
git commit -m "add MySQL and nginx config files"
git push origin main
```
### MySQL のスロークエリのログを有効にする
https://isucon-workshop.trap.show/text/chapter-3/1-SlowQueryLog.html
### nginx のアクセスログのフォーマットを変更する
https://isucon-workshop.trap.show/text/chapter-3/2-AccessLog.html
### New Relic
```sh
cp /home/isucon/webapp/go/.env.example /home/isucon/webapp/go/.env
sudo systemctl restart isupipe-go.service
```
https://newrelic.com/jp/blog/how-to-relic/isucon-go-agent
### pprof
https://isucon-workshop.trap.show/text/chapter-3/3-pprof.html
## Usage
### ssh
```sh
ssh isucon13
```
### DB 接続
```sh
ssh isucon13
make mysql
```
### ベンチマーク実行
```sh
ssh isucon13
make bench
```
### スロークエリの解析
```sh
ssh isucon13
make slowq
```
### アクセスログの解析
```sh
ssh isucon13
make alp
```
### デプロイ
メインブランチ
```sh
make deploy
```
特定ブランチ
```sh
make deploy-
```
以下がデプロイ対象で、リスタートも自動で行なっているため追加作業は不要
- アプリケーション
- `nginx.conf`
- `mysqld.cnf`
### サービスステータスの確認
```sh
ssh isucon13
make check-service-status
```
### サービスログの確認
```sh
ssh isucon13
make watch-service-log
```
## Hints
### CPU 使用率・メモリ使用率等の確認
リアルタイムで更新されるため基本的に常に起動しておく
```sh
ssh isucon13
top
```
### nginx のアクセスログから特定のリクエストを抽出
```sh
ssh isucon13
sudo grep -E "/api/user/.+/icon" /var/log/nginx/access.log
sudo zgrep -E "/api/user/.+/icon" /var/log/nginx/access.log.gz
```
## References
- [ISUCON初心者向け講習会](https://isucon-workshop.trap.show/)
- [matsuu/aws-isucon](https://github.com/matsuu/aws-isucon)
- [south37/00_timeline.md](https://gist.github.com/south37/d4a5a8158f49e067237c17d13ecab12a)
- [ISUCON入門以前_ISUNARABE_LT#1](https://speakerdeck.com/sadnessojisan/isuconru-men-yi-qian-isunarabe-lt-number-1)
- [壁を感じたISUCON12本戦](https://poyo.hatenablog.jp/entry/2022/08/28/191329)
- [ISUCON予選突破を支えたオペレーション技術](https://blog.yuuk.io/entry/web-operations-isucon)
- [Linuxサーバにログインしたらいつもやっているオペレーション](https://blog.yuuk.io/entry/linux-server-operations)
- [ISUCON4 予選でアプリケーションを変更せずに予選通過ラインを突破するの術](https://kazeburo.hatenablog.com/entry/2014/10/14/170129)
- [ISUCONで学ぶ Webアプリケーションのパフォーマンス向上のコツ 実践編 完全版](https://www.slideshare.net/slideshow/isucon-summerclass2014action2final/38224673)
- [ISUCONの勝ち方 YAPC::Asia Tokyo 2015](https://www.slideshare.net/slideshow/isucon-yapcasia-tokyo-2015/51993443)
- [ISUCON予選突破を支えるオペレーション技術 / Web Operations about ISUCON](https://speakerdeck.com/yuukit/web-operations-about-isucon)
- [Ansible playbooks for isucon](https://github.com/pddg/isu12f)
- [[ISUCON用] 複数台同時デプロイスクリプト(Golang)](https://qiita.com/momotaro98/items/694000dfb736d0316441)
- [MEMORYストレージエンジンでMySQLのパフォーマンスをあげよう](https://qiita.com/hirose-ma/items/c4a10d31a47a5421bb9c)
- [traP-isucon-newbie-handson2022](https://github.com/oribe1115/traP-isucon-newbie-handson2022)
- [matsuu/kataribe](https://github.com/matsuu/kataribe)
- [jpr5/ngrep](https://github.com/jpr5/ngrep/)
- [netdata/netdata](https://github.com/netdata/netdata)
- [単独のサーバーの「負荷」の正体を突き止める](https://tetsuyai.hatenablog.com/entry/20120105/1325750731)
- [MySQLのストレージエンジンについて](https://qiita.com/ishishow/items/280a9d049b8f7bcbc14a)