我正在使用nginx将请求缓存到我的uwsgi后端
uwsgi_cache_path /var/cache/nginx/uwsgi keys_zone=cache:15M max_size=5G;
我的后端设置了一个非常长的过期标题(1年).但是,当我的系统运行时,我看到缓存在15M时达到顶峰.它达到了那个水平,然后降低到10M.
这会导致很多不必要的呼叫到我的后端.当我更改keys_zone大小时,它似乎控制整个缓存的大小.它似乎忽略了max_size,而是替换了keys_zone大小. (*)
谁能解释这种行为?这个版本中是否存在已知错误?我错过了这一点吗?我不想将5G分配给缓存管理器..
# nginx -V
nginx version: nginx/1.2.0
built by gcc 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
TLS SNI support enabled
configure arguments: --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --user=www-data --group=www-data --with-http_ssl_module --with-http_stub_status_module
(*)更新:我想这是我试图在混乱中寻找模式的过度活跃的想象力.
解决方法:
到期头(and some other headers)受到nginx的尊重,以确定响应是否可缓存,但它不用于确定缓存它的时间.
默认情况下,10分钟后将删除非活动缓存.你可以增加这个数字,看看它是否有所作为?
proxy_cache_path path [levels=levels] keys_zone=name:size
[inactive=time] [max_size=size] [loader_files=number]
[loader_sleep=time] [loader_threshold=time];Cached data that are not accessed during the time specified by the
inactive parameter get removed from the cache regardless of their
freshness. By default, inactive is set to 10 minutes.
参考:http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_path
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!