Skip to content

Commit

Permalink
more cache on nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
mickamy committed Jan 2, 2024
1 parent e56f3c0 commit 649c4a4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
17 changes: 13 additions & 4 deletions admin/config/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +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_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 All @@ -38,15 +39,23 @@ http {

location /political_parties/ {
proxy_cache political_parties_cache;
proxy_cache_valid 200 302 1m;
proxy_cache_valid 200 302 30s;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_set_header Host $host;
proxy_pass http://app;
}
}

location /candidates/ {
proxy_cache candidates_cache;
proxy_cache_valid 200 302 1m;
proxy_cache_valid 200 302 30s;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_set_header Host $host;
proxy_pass http://app;
}

location = / {
proxy_cache index_cache;
proxy_cache_valid 200 302 30s;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_set_header Host $host;
proxy_pass http://app;
Expand Down
3 changes: 2 additions & 1 deletion docker/app/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash -eux

sudo mkdir -p /var/nginx/cache_1 /var/nginx/cache_2
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
sudo service mysql start || true
Expand Down
15 changes: 15 additions & 0 deletions note.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,18 @@ docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443 --workload 6"
2024/01/02 09:12:13 {"score": 18968, "success": 16184, "failure": 0}
```

- more cache on nginx 20442

```
❯ make bench
docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443 --workload 6"
2024/01/02 09:41:10 Start GET /initialize
2024/01/02 09:41:10 期日前投票を開始します
2024/01/02 09:41:21 期日前投票が終了しました
2024/01/02 09:41:21 投票を開始します Workload: 6
2024/01/02 09:42:07 投票が終了しました
2024/01/02 09:42:07 投票者が結果を確認しています
2024/01/02 09:42:30 投票者の感心がなくなりました
2024/01/02 09:42:30 {"score": 20442, "success": 15346, "failure": 0}
```

0 comments on commit 649c4a4

Please sign in to comment.