Skip to content

Commit

Permalink
nginx worker process 調整、workload 調整
Browse files Browse the repository at this point in the history
  • Loading branch information
mickamy committed Jan 2, 2024
1 parent 10f16a7 commit acce999
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ down:
docker compose down;

bench:
docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443 --workload 6"
docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443 --workload 4"

bench-with-db-init: up
docker exec -i ishocon2-bench-1 sh -c " \
service mysql restart \
&& tar -jxvf /root/admin/ishocon2.dump.tar.bz2 && mysql -u root -pishocon ishocon2 < /root/admin/ishocon2.dump \
&& ./benchmark --ip app:443 --workload 8 \
&& ./benchmark --ip app:443 --workload 4 \
";

change-lang:
Expand Down
6 changes: 3 additions & 3 deletions admin/config/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
user www-data;
worker_processes 16;
worker_processes 8;
pid /run/nginx.pid;

events {
Expand All @@ -21,8 +21,8 @@ http {

# cache の設定
proxy_cache_path /var/nginx/cache_1 levels=1:2 keys_zone=political_parties_cache:1m max_size=1g inactive=1m use_temp_path=on;
proxy_cache_path var/nginx/cache_2 levels=1:2 keys_zone=candidates_cache:1m max_size=1g inactive=1m use_temp_path=on;
proxy_cache_path var/nginx/cache_3 levels=1:2 keys_zone=index_cache:1m max_size=1g inactive=1m use_temp_path=on;
proxy_cache_path /var/nginx/cache_2 levels=1:2 keys_zone=candidates_cache:1m max_size=1g inactive=1m use_temp_path=on;
proxy_cache_path /var/nginx/cache_3 levels=1:2 keys_zone=index_cache:1m max_size=1g inactive=1m use_temp_path=on;

server {
listen 443;
Expand Down
1 change: 0 additions & 1 deletion docker/app/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash -eux

sudo mkdir -p /usr/share/nginx/var/nginx/cache_1 /usr/share/nginx/var/nginx/cache_2 /usr/share/nginx/var/nginx/cache_3 /usr/share/nginx/var/nginx/cache_4 /usr/share/nginx/var/nginx/cache_5
sudo mkdir -p /var/nginx/cache_1 /var/nginx/cache_2 /var/nginx/cache_3 /var/nginx/cache_4 /var/nginx/cache_5
sudo nginx -t
sudo service nginx start
Expand Down
79 changes: 79 additions & 0 deletions note.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,82 @@ docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443 --workload 6"
2024/01/02 09:42:30 {"score": 20442, "success": 15346, "failure": 0}
```

---

以下、他の方のブログ等を読んでの対応

---

- 前回の状態で再度ベンチ 36352

```
❯ make bench
docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443 --workload 6"
2024/01/02 23:23:16 Start GET /initialize
2024/01/02 23:23:17 期日前投票を開始します
2024/01/02 23:23:17 期日前投票が終了しました
2024/01/02 23:23:17 投票を開始します Workload: 6
2024/01/02 23:24:03 投票が終了しました
2024/01/02 23:24:03 投票者が結果を確認しています
2024/01/02 23:24:31 投票者の感心がなくなりました
2024/01/02 23:24:31 {"score": 36352, "success": 28576, "failure": 0}
```

- nginx の worker process は CPU と同じがいいらしい 35176

```
ishocon@8bb736ded6ff:~$ lscpu | grep CPU
CPU 操作モード: 32-bit
CPU: 8
オンラインになっている CPU のリスト: 0-7
```

```
❯ make bench
docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443 --workload 6"
2024/01/02 23:30:27 Start GET /initialize
2024/01/02 23:30:27 期日前投票を開始します
2024/01/02 23:30:28 期日前投票が終了しました
2024/01/02 23:30:28 投票を開始します Workload: 6
2024/01/02 23:31:13 投票が終了しました
2024/01/02 23:31:13 投票者が結果を確認しています
2024/01/02 23:32:20 投票者の感心がなくなりました
2024/01/02 23:32:20 {"score": 35176, "success": 29888, "failure": 0}
```

- unicorn process 調整(とりあえず 8)

nginx に到達できていないっぽい

```
2024/01/02 23:38:02 Get https://app:443/css/bootstrap.min.css: dial tcp 172.18.0.2:443: connect: cannot assign requested address
2024/01/02 23:38:02 Get https://app:443/css/bootstrap.min.css: dial tcp 172.18.0.2:443: connect: cannot assign requested address
2024/01/02 23:38:02 Get https://app:443/css/bootstrap.min.css: dial tcp 172.18.0.2:443: connect: cannot assign requested address
2024/01/02 23:38:02 Get https://app:443/css/bootstrap.min.css: dial tcp 172.18.0.2:443: connect: cannot assign requested address
2024/01/02 23:38:02 Get https://app:443/css/bootstrap.min.css: dial tcp 172.18.0.2:443: connect: cannot assign requested address
2024/01/02 23:38:02 Get https://app:443/: dial tcp 172.18.0.2:443: connect: cannot assign requested address
2024/01/02 23:38:02 Get https://app:443/: dial tcp 172.18.0.2:443: connect: cannot assign requested address
2024/01/02 23:38:02 Get https://app:443/candidates/19: dial tcp 172.18.0.2:443: connect: cannot assign requested address
2024/01/02 23:38:02 Get https://app:443/css/bootstrap.min.css: dial tcp 172.18.0.2:443: connect: cannot assign requested address
2024/01/02 23:38:02 Get https://app:443/css/bootstrap.min.css: dial tcp 172.18.0.2:443: connect: cannot assign requested address
2024/01/02 23:38:02 Get https://app:443/css/bootstrap.min.css: dial tcp 172.18.0.2:443: connect: cannot assign requested address
2024/01/02 23:38:02 Get https://app:443/: dial tcp 172.18.0.2:443: connect: cannot assign requested address
2024/01/02 23:38:02 Get https://app:443/css/bootstrap.min.css: dial tcp 172.18.0.2:443: connect: cannot assign requested address
2024/01/02 23:38:32 投票者の感心がなくなりました
2024/01/02 23:38:32 {"score": -6410, "success": 31845, "failure": 451}
```

- workload を 4 に変更 43824

```
❯ make bench
docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443 --workload 4"
2024/01/02 23:41:41 Start GET /initialize
2024/01/02 23:41:41 期日前投票を開始します
2024/01/02 23:41:42 期日前投票が終了しました
2024/01/02 23:41:42 投票を開始します Workload: 4
2024/01/02 23:42:27 投票が終了しました
2024/01/02 23:42:27 投票者が結果を確認しています
2024/01/02 23:43:08 投票者の感心がなくなりました
2024/01/02 23:43:08 {"score": 43824, "success": 33112, "failure": 0}
```
2 changes: 1 addition & 1 deletion webapp/ruby/unicorn_config.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
worker_processes 16
worker_processes 8
preload_app true
pid '/tmp/unicorn.pid'
listen 8080

0 comments on commit acce999

Please sign in to comment.