nginx反向代理,最大限度利用物理內存
nginx反向代理,最大限度利用物理內存
如題,nginx反向代理如何最大限度的利用內存
貼出來我的nginx配置user www www;
worker_processes 8;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
events
{
use epoll;
worker_connections 65535;
}
http
{
include mime.types;
default_type application/octet-stream;
charset utf-8;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 300m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
client_body_buffer_size 512k;
proxy_connect_timeout 5;
proxy_read_timeout 60;
proxy_send_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_temp_path /cache/proxy_temp_dir;
proxy_cache_path /cache/proxy_cache_dir levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;
upstream backend_server {
server 192.168.8.43:80 weight=1 max_fails=2 fail_timeout=30s;
server 192.168.8.44:80 weight=1 max_fails=2 fail_timeout=30s;
server 192.168.8.45:80 weight=1 max_fails=2 fail_timeout=30s;
}
server
{
listen 80;
server_name www.offensive.cn 192.168.88.128;
index index.html index.htm;
location /
{
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_cache cache_one;
proxy_cache_valid 200 304 12h;
proxy_cache_key $host$uri$is_args$args;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://backend_server;
expires 1d;
}
location ~ .*\.(php|jsp|cgi)?$
{
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://backend_server;
}
access_log /var/log/nginx.log;
}
}用top命令看
顯示虛擬內存用了215M,實際內存只用了12m,
機器內存是24G,如何才能充分利用物理內存,
《解決方案》
謝謝。學習了{:2_168:}
《解決方案》
是個什麼樣的應用?可以靠大量連接數把內存佔滿,前提是你確實有那麼多用戶。
配置中有proxy_cache,緩存上限也設置的足夠大,有足夠訪問量后內存使用量自然會增加。還是遇到什麼問題了嗎?
24G內存只跑一個Nginx,確實比較奢侈
《解決方案》
把內存用滿才是硬道理,不然就是閑置資源。
樓主那麼高的配置,不如虛擬化成雙機或集群。
《解決方案》
看的我雲里霧裡 我再學學