@
Kvm 现在是分配了五个proxy_cache_path 然后每个分配1.25G内存 允许32G的缓存文件 缓存文件放在一块sansung 830的硬盘上
运行了15个小时了 缓存文件有300来万 改成缓存2天了 页面变化都不大 有修改的话API会自动刷新 再长时间inode好像不大够 这个得后续看 大体上还算稳定
worker_cpu_affinity 导致后端出现严重的问题 去掉了 增大进程了
配置大约是这个样子 压缩什么的都放后端了 前端就是负责输出:
###############################################
user www www;
worker_processes 32;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
http {
client_header_buffer_size 4k;
client_body_buffer_size 128k;
large_client_header_buffers 4 4k;
server_names_hash_max_size 1280;
server_names_hash_bucket_size 128;
client_max_body_size 4m;
server_name_in_redirect off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
keepalive_timeout 60;
open_file_cache max=65535 inactive=300s;
open_file_cache_valid 500s;
open_file_cache_errors on;
proxy_cache_path /www/zonea levels=1:2 keys_zone=zonea:1280m inactive=3d max_size=32g;
proxy_cache_path /www/zoneb levels=1:2 keys_zone=zoneb:1280m inactive=3d max_size=32g;
proxy_cache_path /www/zonec levels=1:2 keys_zone=zonec:1280m inactive=3d max_size=32g;
proxy_cache_path /www/zoned levels=1:2 keys_zone=zoned:1280m inactive=3d max_size=32g;
proxy_cache_path /www/zonee levels=1:2 keys_zone=zonee:1280m inactive=3d max_size=32g;
server {
listen 8.8.8.8:80;
server_name
www.v2ex.com v2ex.com;
location / {
proxy_pass http://4.4.4.4:80;
proxy_cache zonea;
proxy_cache_key $request_method://$host$request_uri;
proxy_buffer_size 8k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 96k;
proxy_temp_file_write_size 256k;
proxy_cache_valid 200 301 302 1d;
proxy_cache_valid any 1m;
proxy_cache_use_stale error timeout updating invalid_header http_500 http_502 http_504 http_404;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header HTTP_CLIENT_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header X-Cached $upstream_cache_status;
}
location ~ /purge(/.*) {
proxy_cache_purge zonea $request_method://$host$1;
}
access_log off;
}
....
}
###############################################
现在有一个问题 在同一个局域网的前端和后端的机器互相ping是0.86ms 实际抓取网页测试 有时候会卡到1.2s 应该是后端对并发支持不佳吧 也可能是流氓msnbot造成的 整体上还在观察
下一步重点测试keepalive相关的参数