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 56dfc9f
Show file tree
Hide file tree
Showing 3 changed files with 21 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
6 changes: 6 additions & 0 deletions note.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,9 @@ 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

```
```

0 comments on commit 56dfc9f

Please sign in to comment.