내 질문에 컨텍스트를 작성합니다 ...nginx를 사용하여 여러 인스턴스에서 캐시 공유
Node.js 웹 앱이 정상적으로 작동합니다. AWS (Elastic Load Balancing, 클래식 모드)에 여러 EC2 인스턴스가있는 자동 확장 그룹이있는로드 밸런서가 있습니다.
각 EC2 인스턴스에는 Nginx 리버스 프록시가 설치되어있어 PM2 및 Node.js (Express)와 잘 작동합니다. Nginx를 사용하여 정적 파일 캐싱, 요청 캐싱, https 및 다른 작업.
Nginx를 사용하는 모든 인스턴스간에 캐시를 공유하고 각 컴퓨터의 메모리 캐시를 각각 사용하지 않는 방법을 알아야합니다. Memcache o Redis를 사용하고 싶습니다.하지만 하나를 선택해야합니다. Redis를 선호합니다. 나는 아무 대답없이 ServerFault에서이 질문을 발견
proxy_cache_path /cache/nginx levels=1:2 keys_zone=cache_zone_name:10m;
location/{
#root html;
#index index.html index.htm;
#Config proxy inverse cache
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# Add cache debugging header
add_header X-Cache-Status $upstream_cache_status;
# Configure cache
proxy_cache cache_zone_name;
proxy_cache_valid any 1m;
proxy_cache_key $scheme$host$request_uri;
}
:
이
내가이 순간 (단지 중요한 코드)에서 일하고 있어요 방법 예입니다.감사합니다.
편집 : 중요 사항, 나는 캐시 성능 :