leng 发表于 2015-11-20 13:24:54

HAPROXY/LNMP系统请求应答超时时间设置

  WEB系统架构是haproxy/nginx/php-fpm, 机器系统是freebsd或linux.
  

  1. haproxy中和超时时间相关的配置为(ms为单位):
  timeout client 120000
timeout server 120000

  

  2. nginx中和应答超时时间相关的配置为(s为单位):
  send_timeout 120 (通用设置)

  fastcgi_read_timeout 120 (对fastcgi方式有效)
  

  另外如果设置了代理, 需要对代理页设置超时时间, 比如:
  
location /mybackup {       send_timeout 120;       proxy_read_timeout 120;       proxy_connect_timeout 120;       indexindex.jsp index.html index.htm;       proxy_pass http://127.0.0.1:8080;       proxy_set_headerX-Real-IP$remote_addr;}  
  

  3. 最后php本身的超时执行时间设置(php.ini)
  max_execution_time = 120   ; Maximum execution time of each script, in seconds
  

  如上设置改动需要重启相关服务,都设置好后,用户请求应答时间的设置将为2分钟。
  另外可以在程序中调用set_time_limit方法来设置该脚本执行超时限制,
  但首先php要运行于非安全模式中safe_mode = off
  另外实际超时时间受各个上游(client)节点(haproxy,nginx)的限制。
  (client) haproxy-> (upstream) nginx -> (upstream)php-fpm
  

  iefreer

  

  
页: [1]
查看完整版本: HAPROXY/LNMP系统请求应答超时时间设置