免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2821 | 回复: 4
打印 上一主题 下一主题

nginx反向代理,最大限度利用物理内存 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-11-29 15:08 |只看该作者 |倒序浏览
nginx反向代理,最大限度利用物理内存









如题,nginx反向代理如何最大限度的利用内存
贴出来我的nginx配置
  1. user  www www;

  2. worker_processes 8;

  3. error_log  /usr/local/nginx/logs/nginx_error.log  crit;

  4. pid        /usr/local/nginx/nginx.pid;

  5. #Specifies the value for maximum file descriptors that can be opened by this process.
  6. worker_rlimit_nofile 65535;

  7. events
  8. {
  9.   use epoll;
  10.   worker_connections 65535;
  11. }

  12. http
  13. {
  14.   include       mime.types;
  15.   default_type  application/octet-stream;

  16.   charset  utf-8;
  17.       
  18.   server_names_hash_bucket_size 128;
  19.   client_header_buffer_size 32k;
  20.   large_client_header_buffers 4 32k;
  21.   client_max_body_size 300m;
  22.       
  23.   sendfile on;
  24.   tcp_nopush     on;

  25.   keepalive_timeout 60;

  26.   tcp_nodelay on;

  27.   client_body_buffer_size  512k;
  28.   proxy_connect_timeout    5;
  29.   proxy_read_timeout       60;
  30.   proxy_send_timeout       5;
  31.   proxy_buffer_size        16k;
  32.   proxy_buffers            4 64k;
  33.   proxy_busy_buffers_size 128k;
  34.   proxy_temp_file_write_size 128k;


  35.   proxy_temp_path   /cache/proxy_temp_dir;

  36.   proxy_cache_path  /cache/proxy_cache_dir  levels=1:2   keys_zone=cache_one:200m inactive=1d max_size=30g;
  37.   
  38.   upstream backend_server {
  39.     server   192.168.8.43:80 weight=1 max_fails=2 fail_timeout=30s;
  40.     server   192.168.8.44:80 weight=1 max_fails=2 fail_timeout=30s;
  41.     server   192.168.8.45:80 weight=1 max_fails=2 fail_timeout=30s;
  42.   }

  43.   server
  44.   {
  45.     listen       80;
  46.     server_name  www.offensive.cn 192.168.88.128;
  47.     index index.html index.htm;

  48.     location /
  49.     {

  50.          proxy_next_upstream http_502 http_504 error timeout invalid_header;
  51.          proxy_cache cache_one;
  52.       
  53.          proxy_cache_valid  200 304 12h;

  54.          proxy_cache_key $host$uri$is_args$args;
  55.          proxy_set_header Host  $host;
  56.          proxy_set_header X-Forwarded-For  $remote_addr;
  57.          proxy_pass http://backend_server;
  58.          expires      1d;
  59.     }
  60.    
  61.    
  62.     location ~ .*\.(php|jsp|cgi)?$
  63.     {
  64.          proxy_set_header Host  $host;
  65.          proxy_set_header X-Forwarded-For  $remote_addr;
  66.          proxy_pass http://backend_server;
  67.     }

  68.     access_log /var/log/nginx.log;
  69.   }
  70. }
复制代码
用top命令看





显示虚拟内存用了215M,实际内存只用了12m,
机器内存是24G,如何才能充分利用物理内存,

论坛徽章:
0
2 [报告]
发表于 2011-11-29 15:35 |只看该作者
谢谢。学习了{:2_168:}

论坛徽章:
0
3 [报告]
发表于 2011-11-29 23:58 |只看该作者
是个什么样的应用?可以靠大量连接数把内存占满,前提是你确实有那么多用户。

配置中有proxy_cache,缓存上限也设置的足够大,有足够访问量后内存使用量自然会增加。还是遇到什么问题了吗?

24G内存只跑一个Nginx,确实比较奢侈

论坛徽章:
5
技术图书徽章
日期:2013-08-27 10:03:49CU大牛徽章
日期:2013-09-18 15:16:55CU大牛徽章
日期:2013-09-18 15:18:22CU大牛徽章
日期:2013-09-18 15:18:43技术图书徽章
日期:2014-04-24 15:51:26
4 [报告]
发表于 2011-11-30 13:52 |只看该作者
把内存用满才是硬道理,不然就是闲置资源。

楼主那么高的配置,不如虚拟化成双机或集群。

论坛徽章:
0
5 [报告]
发表于 2011-12-01 11:54 |只看该作者
看的我云里雾里 我再学学
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP