cache optymalisation

This commit is contained in:
Artur Kuś 2025-08-18 20:15:23 +02:00
parent 2b99559d2b
commit 51cb8238f4
2 changed files with 20 additions and 27 deletions

View File

@ -10,7 +10,7 @@ services:
TZ: Europe/Warsaw
NGINX_ENVSUBST_TEMPLATE_DIR: /etc/nginx/templates
NGINX_ENVSUBST_OUTPUT_DIR: /etc/nginx/conf.d
NGINX_CACHE_DISK_PATH: "/var/cache/nginx"
ports:
- "80:80"
@ -19,8 +19,8 @@ services:
volumes:
# Konfiguracja Nginx
- apps-data:/etc/nginx/conf.d:ro
- nginx2GB_cache:/var/cache/nginx2GB
- nginx05GB_cache:/var/cache/nginx05GB
- nginx_cache:/var/cache/nginx_cache
# Certyfikaty SSL
- ${DOCKER_DATA}/letsencrypt:/letsencrypt:rw
@ -28,22 +28,16 @@ services:
- ${DOCKER_DATA}/nginx-logs:/var/log/nginx:rw
command: /bin/sh -c "mkdir -p /var/cache/nginx05GB /var/cache/nginx2GB && nginx -g 'daemon off;'"
volumes:
nginx2GB_cache:
driver_opts:
type: tmpfs
device: tmpfs
o: size=2147483648 # 2GB
nginx05GB_cache:
driver_opts:
type: tmpfs
device: tmpfs
o: size=536870912 # 512MB
apps-data:
external: true
nginx_cache:
driver_opts:
type: tmpfs
device: tmpfs
o: size=3G
apps-data:
external: true
networks:
proxy-net:

View File

@ -2,20 +2,17 @@
# Limitowanie requestów (pozostawiamy bez zmian)
limit_req_zone $binary_remote_addr zone=ip_limit:10m rate=30r/s;
# Konfiguracja cache (nowa część)
proxy_cache_path /var/cache/nginx05GB levels=1:2 keys_zone=STATIC:50m inactive=24h max_size=500m use_temp_path=off;
proxy_cache_path /var/cache/nginx2GB
proxy_cache_path /var/cache/nginx
levels=1:2
keys_zone=GLOBAL_CACHE:256m
keys_zone=COMBINED_CACHE:320m # 256m + 64m
inactive=7d
max_size=2g
max_size=2500m # Zostawiamy margines
use_temp_path=off
manager_files=0 # Wyłącza logi manager-a
loader_files=0 # Wyłącza logi loader-a
manager_files=0
loader_files=0
loader_threshold=300
loader_sleep=50;
server {
listen 443 ssl;
server_name www.bodypainter.eu;
@ -53,7 +50,7 @@
location ~* \.(jpg|jpeg|png|gif|ico|webp|svg)$ {
access_log off;
proxy_pass http://arti24-container:3000;
proxy_cache GLOBAL_CACHE;
proxy_cache COMBINED_CACHE;
proxy_cache_valid 200 30d;
proxy_cache_min_uses 2;
proxy_cache_lock on;
@ -73,6 +70,8 @@
expires 1y;
access_log off;
proxy_cache_revalidate on; # Dodaj dla świeżości danych
proxy_cache_background_update on; # Lepsza wydajność
}
}