Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add github actions workflow to run benchmark #1

Merged
merged 26 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
50a9b96
ci: add github actions workflow to run benchmark
mickamy Dec 31, 2023
154d82e
fix: use get-pip for python 3.6
mickamy Dec 31, 2023
c0635e4
ci: waiting for docker compose to be up
mickamy Dec 31, 2023
42e4930
make: add Makefile and build showwin/ishocon2_app_base everytime
mickamy Dec 31, 2023
0195fde
ci: make build on CI to build latest version of base image
mickamy Dec 31, 2023
498b9eb
fix: fix container name
mickamy Dec 31, 2023
ad91751
make: add task to execute bench
mickamy Dec 31, 2023
90d8ecf
make: add up and down for docker to make
mickamy Dec 31, 2023
0cd168f
feat: add script to run app
mickamy Dec 31, 2023
ac623b5
ci: run benchmark for all lang on CI
mickamy Dec 31, 2023
6c7ce8d
script: remove unnecessary lines
mickamy Dec 31, 2023
d641e45
fix: run.sh and make file
mickamy Dec 31, 2023
c1b0fbb
docker: set tty true for app
mickamy Dec 31, 2023
3e31a17
refactor: dockerfile and environment should be closer for it would be…
mickamy Dec 31, 2023
048dd8d
docker: run sudo apt-get update for all Dockerfiles
mickamy Dec 31, 2023
06bf57c
python: sudo on install
mickamy Dec 31, 2023
55959fc
ci: make every language app to be runned on CI
mickamy Dec 31, 2023
f3af7b6
docker: copy run.sh on each Dockerfile
mickamy Dec 31, 2023
75f1065
ruby: fix run.sh to use unicorn
mickamy Dec 31, 2023
36328bd
fix: idk why but uwsgi not found, so specify it with absolute path
mickamy Dec 31, 2023
7a64de5
chore: echo check message on ruby app run
mickamy Dec 31, 2023
b1da2d2
ruby: fix typo in extension
mickamy Dec 31, 2023
340f1eb
chore: remove -t option from docker exec
mickamy Dec 31, 2023
509a17b
php: make php to be runnable by script
mickamy Dec 31, 2023
9f03671
ci: replace python to $ISUCON_APP_LANG
mickamy Dec 31, 2023
7ecccac
ci: fix run command and other things
mickamy Dec 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Benchmark

on:
workflow_dispatch:
push:

concurrency:
group: ${{ github.workflow }}-${{ github.sha }}
cancel-in-progress: true

jobs:
benchmark:
name: Run benchmark
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
language:
- "crystal"
- "go"
- "nodejs"
- "php"
- "python"
- "python_sanic"
- "ruby"
steps:
- uses: actions/checkout@v2
- run: echo 'Run benchmark for ISHOCON2'
- run: |
sed -i 's/python/'"$ISHOCON_APP_LANG"'/g' ./docker-compose.yml
cat ./docker-compose.yml
make build
env:
ISHOCON_APP_LANG: ${{ matrix.language }}
- run: make up && sleep 30
- run: make bench
timeout-minutes: 5
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
common:
docker build -f docker/app/base/Dockerfile -t showwin/ishocon2_app_base:latest .

build: common
docker compose build

up: build
docker compose up -d

down:
docker compose down

bench:
docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443"
2 changes: 1 addition & 1 deletion doc/local_manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ $ docker exec -it ishocon2_app_1 /bin/bash
## ベンチマーカー

```
$ docker exec -it ishocon2_bench_1 /bin/bash
$ docker exec -it ishocon2-bench-1 /bin/bash
$ ./benchmark --ip app:443 # docker-compose.yml で link しているので app で到達できます
```
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ services:
build:
context: .
dockerfile: ./docker/app/python/Dockerfile
command: tail -f /dev/null
environment:
ISHOCON_APP_LANG: "${ISHOCON_APP_LANG-python}"
command: [/home/ishocon/run.sh]
tty: true
volumes:
- storage_app:/var/lib/mysql
- ./webapp:/home/ishocon/webapp
Expand Down
4 changes: 3 additions & 1 deletion docker/app/crystal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ FROM showwin/ishocon2_app_base:latest
ENV APP_LANG 'Crystal'

# Crystal のインストール
RUN sudo apt-get update
RUN sudo apt-get install -y gnupg2
RUN curl -sL "https://keybase.io/crystal/pgp_keys.asc" | sudo apt-key add -
RUN echo "deb https://dist.crystal-lang.org/apt crystal main" | sudo tee /etc/apt/sources.list.d/crystal.list
RUN sudo apt-get update
RUN sudo apt install -y libssl1.0-dev crystal

# アプリケーション
Expand All @@ -17,6 +17,8 @@ COPY admin/config/bashrc /home/ishocon/.bashrc
WORKDIR /home/ishocon
EXPOSE 443

COPY run.sh /home/ishocon/run.sh

COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh
ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"]

Expand Down
3 changes: 2 additions & 1 deletion docker/app/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/bin/bash -eux

sudo service nginx start
sudo service mysql start
sudo chown -R mysql:mysql /var/lib/mysql /var/run/mysqld
Expand Down
2 changes: 2 additions & 0 deletions docker/app/go/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ COPY admin/config/bashrc /home/ishocon/.bashrc
WORKDIR /home/ishocon
EXPOSE 443

COPY run.sh /home/ishocon/run.sh

COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh
ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"]

Expand Down
2 changes: 2 additions & 0 deletions docker/app/nodejs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ RUN cd /home/ishocon/webapp/nodejs && \
WORKDIR /home/ishocon
EXPOSE 443

COPY run.sh /home/ishocon/run.sh

COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh
ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"]

Expand Down
2 changes: 2 additions & 0 deletions docker/app/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ RUN cd /home/ishocon/webapp/php && \
WORKDIR /home/ishocon
EXPOSE 443

COPY run.sh /home/ishocon/run.sh

COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh
ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"]

Expand Down
5 changes: 4 additions & 1 deletion docker/app/python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ FROM showwin/ishocon2_app_base:latest
ENV APP_LANG 'Python'

# Python のインストール
RUN sudo apt-get update
RUN sudo apt-get install -y zlib1g-dev
RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \
PYENV_ROOT="$HOME/.pyenv" && PATH="$PYENV_ROOT/bin:$PATH" && \
eval "$(pyenv init -)" && \
pyenv install 3.6.5 && pyenv global 3.6.5 && \
cd && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python get-pip.py && rm get-pip.py
cd && curl https://bootstrap.pypa.io/pip/3.6/get-pip.py -o get-pip.py && python get-pip.py && rm get-pip.py

# アプリケーション
RUN mkdir /home/ishocon/data /home/ishocon/webapp
Expand All @@ -23,6 +24,8 @@ RUN LC_ALL=C.UTF-8 && LANG=C.UTF-8 && cd /home/ishocon/webapp/python && \
WORKDIR /home/ishocon
EXPOSE 443

COPY run.sh /home/ishocon/run.sh

COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh
ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"]

Expand Down
3 changes: 3 additions & 0 deletions docker/app/ruby/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM showwin/ishocon2_app_base:latest
ENV APP_LANG 'Ruby'

# Ruby のインストール
RUN sudo apt-get update
RUN sudo apt-get install -y ruby-dev libmysqlclient-dev && \
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
RUN PATH="$HOME/.rbenv/bin:$PATH" && \
Expand All @@ -21,6 +22,8 @@ RUN cd /home/ishocon/webapp/ruby && sudo gem install bundler -v "1.16.1" && bund
WORKDIR /home/ishocon
EXPOSE 443

COPY run.sh /home/ishocon/run.sh

COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh
ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"]

Expand Down
2 changes: 1 addition & 1 deletion docker/benchmarker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:18.04

RUN apt-get update
RUN sudo apt-get update
RUN apt-get install -y wget

# Go のインストール
Expand Down
3 changes: 2 additions & 1 deletion docker/benchmarker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/bin/bash -ux

service mysql start # なぜか失敗する(調査中)
chown -R mysql:mysql /var/lib/mysql /var/run/mysqld
service mysql start # 正しく起動
Expand Down
55 changes: 55 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash -eux

app_lang="${ISHOCON_APP_LANG}"

if [ -z "$app_lang" ]
then
echo "ISHOCON_APP_LANG is not set"
exit 1
fi

check_message="start application w/ ${app_lang}..."

echo "app_lang: $app_lang"

function run_ruby() {
bundle install
unicorn -c unicorn_config.rb
echo "$check_message"
}

function run_python() {
/home/ishocon/.pyenv/shims/uwsgi --ini app.ini
echo "$check_message"
}

function run_python_sanic() {
/home/ishocon/.pyenv/shims/uwsgi --ini app.ini
echo "$check_message"
}


function run_go() {
go get -t -d -v ./...
go build -o webapp *.go
./webapp
echo "$check_message"
}

function run_php() {
sudo mv -f /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig
sudo cp webapp/php/php-nginx.conf /etc/nginx/nginx.conf
sudo service nginx reload
echo "$check_message"
}

function run_crystal() {
shards install
crystal app.cr
echo "$check_message"
}

echo "run $app_lang app..."
cd "/home/ishocon/webapp/$app_lang"

"run_$app_lang"
Loading