免费注册 查看新帖 |

Chinaunix

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

[Web] 请求一个关于nginx+fastcgi遇到的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-11-28 03:54 |只看该作者 |倒序浏览
遇到一个很头疼的问题.
公司现在的web服务器是之前的系统管理员按照http://blog.s135.com/post/314.htm文章进行配置的.因为是内部测试,每天的流量也就2000多IP,同时在线最多也就一百多人.现在的问题是时不时的php-cgi进程突然从1到5、600。然后又迅速回到1.如果到5\600时,网站打开就会很慢或者打不开,查了很多资料,使用了php-fpm,但问题依然存在。快被折腾疯了,不知道该从何入手

nginx配置
  1. user  www www;
  2. worker_processes 4;
  3. worker_cpu_affinity 0001 0010 0100 1000;
  4. error_log  logs/error.log;
  5. pid        logs/nginx.pid;
  6. worker_rlimit_nofile 51200;
  7. events
  8. {
  9.            use epoll;
  10.        worker_connections 51200;
  11. }

  12. http
  13. {
  14.   include       mime.types;
  15. error_page 500 502 503 504 [url]http://www.XXX.COM[/url](为公司的网址);  
  16. default_type  application/octet-stream;
  17. #fastcgi_connect_timeout 60;
  18. #fastcgi_send_timeout 180;
  19. #fastcgi_read_timeout 180;
  20. fastcgi_buffer_size 128k;
  21. fastcgi_buffers 4 256k;
  22. #fastcgi_busy_buffers_size 256k;
  23. #fastcgi_temp_file_write_size 256k;
  24. client_header_buffer_size 128k;
  25. #large_client_header_buffers 4 256k;
  26. keepalive_timeout  60;   
  27. gzip  on;
  28. gzip_min_length  1000;
  29. gzip_buffers     4 8k;
  30. gzip_types       text/* text/css application/javascript application/x-javascript;
  31. gzip_comp_level  9;
  32. gzip_proxied     any;
  33. gzip_vary        on;
  34. output_buffers   4 32k;
  35. postpone_output  1460;
复制代码


php-fpm的配置
  1. <?xml version="1.0" ?>
  2. <configuration>

  3.         All relative paths in this config are relative to php's install prefix

  4.         <section name="global_options">

  5.                 Pid file
  6.                 <value name="pid_file">logs/php-fpm.pid</value>

  7.                 Error log file
  8.                 <value name="error_log">logs/php-fpm.log</value>

  9.                 When this amount of php processes exited with SIGSEGV or SIGBUS ...
  10.                 <value name="emergency_restart_threshold">10</value>

  11.                 ... in a less than this interval of time, a complete restart will be initiated.
  12.                 Useful to work around accidental curruptions in accelerator's shared memory.
  13.                 <value name="emergency_restart_interval">1m</value>

  14.                 Time limit on waiting child's reaction on signals from master
  15.                 <value name="process_control_timeout">5s</value>

  16.                 Set to 'no' to debug fpm
  17.                 <value name="daemonize">yes</value>

  18.         </section>

  19.         <workers>

  20.                 <section name="pool">

  21.                         Name of pool. Used in logs and stats.
  22.                         <value name="name">main</value>

  23.                         Address to accept fastcgi requests on.
  24.                         Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'
  25.                         <value name="listen_address">127.0.0.1:10080</value>

  26.                         <value name="listen_options">

  27.                                 Set listen(2) backlog
  28.                                 <value name="backlog">-1</value>

  29.                                 Set permissions for unix socket, if one used.
  30.                                 In Linux read/write permissions must be set in order to allow connections from web server.
  31.                                 Many BSD-derrived systems allow connections regardless of permissions.
  32.                                 <value name="owner"></value>
  33.                                 <value name="group"></value>
  34.                                 <value name="mode">0666</value>
  35.                         </value>

  36.                         Additional php.ini defines, specific to this pool of workers.
  37.                         <value name="php_defines">
  38.                 <!--                <value name="sendmail_path">/usr/sbin/sendmail -t -i</value>                -->
  39.                 <!--                <value name="display_errors">0</value>                                                                -->
  40.                         </value>

  41.                         Unix user of processes
  42.                         <value name="user">www</value>

  43.                         Unix group of processes
  44.                         <value name="group">www</value>

  45.                         Process manager settings
  46.                         <value name="pm">

  47.                                 Sets style of controling worker process count.
  48.                                 Valid values are 'static' and 'apache-like'
  49.                                 <value name="style">static</value>

  50.                                 Sets the limit on the number of simultaneous requests that will be served.
  51.                                 Equivalent to Apache MaxClients directive.
  52.                                 Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
  53.                                 Used with any pm_style.
  54.                                 <value name="max_children">120</value>

  55.                                 Settings group for 'apache-like' pm style
  56.                                 <value name="apache_like">

  57.                                         Sets the number of server processes created on startup.
  58.                                         Used only when 'apache-like' pm_style is selected
  59.                                         <value name="StartServers">20</value>

  60.                                         Sets the desired minimum number of idle server processes.
  61.                                         Used only when 'apache-like' pm_style is selected
  62.                                         <value name="MinSpareServers">5</value>

  63.                                         Sets the desired maximum number of idle server processes.
  64.                                         Used only when 'apache-like' pm_style is selected
  65.                                         <value name="MaxSpareServers">35</value>

  66.                                 </value>

  67.                         </value>

  68.                         Time limit on waiting execution of single request
  69.                         Should be used when 'max_execution_time' ini option does not terminate execution for some reason
  70.                         <value name="request_execution_timeout">31s</value>

  71.                         Set open file desc rlimit
  72.                         <value name="rlimit_files">51200</value>

  73.                         Set max core size rlimit
  74.                         <value name="rlimit_core">unlimited</value>

  75.                         Chroot to this directory at the start
  76.                         <value name="chroot"></value>

  77.                         Chdir to this directory at the start
  78.                         <value name="chdir"></value>

  79.                         Redirect workers' stdout and stderr into main log.
  80.                         If not set, they will be redirected to /dev/null, according to FastCGI specs
  81.                         <value name="catch_workers_output">yes</value>

  82.                         How much requests each process should execute before respawn.
  83.                         Useful to work around memory leaks in 3rd party libraries.
  84.                         For endless request processing please specify 0
  85.                         Equivalent to PHP_FCGI_MAX_REQUESTS
  86.                         <value name="max_requests">10240</value>

  87.                         Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.
  88.                         Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+)
  89.                         Makes sense only with AF_INET listening socket.
  90.                         <value name="allowed_clients">127.0.0.1</value>

  91.                         Pass environment variables like LD_LIBRARY_PATH
  92.                         All $VARIABLEs are taken from current environment
  93.                         <value name="environment">
  94.                                 <value name="HOSTNAME">$HOSTNAME</value>
  95.                                 <value name="PATH">/usr/local/bin:/usr/bin:/bin</value>
  96.                                 <value name="TMP">/tmp</value>
  97.                                 <value name="TMPDIR">/tmp</value>
  98.                                 <value name="TEMP">/tmp</value>
  99.                                 <value name="OSTYPE">$OSTYPE</value>
  100.                                 <value name="MACHTYPE">$MACHTYPE</value>
  101.                                 <value name="MALLOC_CHECK_">2</value>
  102.                         </value>

  103.                 </section>

  104.         </workers>

  105. </configuration>
复制代码

论坛徽章:
0
2 [报告]
发表于 2008-12-02 14:01 |只看该作者
先查是不是被攻击
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP