当后端某机器无法连接,或者处理fastcgi请求时异常退出,nginx会将fastcgi请求发送到另外一台机器。

配置文件

http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; upstream backend { //配置后端机器
server 192.168.22.103:9000;
server 172.28.250.130:9901;
} server {
listen 8099;
upstream backend {
server 192.168.22.103:9000;
server 172.28.250.130:9901;
}
....... # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass backend; //指定到后端机器
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
} ...............

2017/10/11 11:12:21 [debug] 24481#0: *66 http upstream request: "/aa.php?"
2017/10/11 11:12:21 [debug] 24481#0: *66 http upstream process header
2017/10/11 11:12:21 [debug] 24481#0: *66 malloc: 0000000006717E30:4096
2017/10/11 11:12:21 [debug] 24481#0: *66 recv: fd:4 0 of 4096
2017/10/11 11:12:21 [error] 24481#0: *66 upstream prematurely closed connection while reading response header from upstream, client: 192.168.22.103, server: localhost, request: "GET /aa.php HTTP/1.1", upstream: "fastcgi://192.168.22.103:9000", host: "172.28.250.184:8099"
2017/10/11 11:12:21 [debug] 24481#0: *66 http next upstream, 2
2017/10/11 11:12:21 [debug] 24481#0: *66 free rr peer 2 4
2017/10/11 11:12:21 [warn] 24481#0: *66 upstream server temporarily disabled while reading response header from upstream, client: 192.168.22.103, server: localhost, request: "GET /aa.php HTTP/1.1", upstream: "fastcgi://192.168.22.103:9000", host: "172.28.250.184:8099"
2017/10/11 11:12:21 [debug] 24481#0: *66 free rr peer failed: 0000000006738850 0
2017/10/11 11:12:21 [debug] 24481#0: *66 close http upstream connection: 4
2017/10/11 11:12:21 [debug] 24481#0: *66 free: 00000000066F71D0, unused: 48
2017/10/11 11:12:21 [debug] 24481#0: *66 event timer del: 4: 1507691601518
2017/10/11 11:12:21 [debug] 24481#0: *66 reusable connection: 0
2017/10/11 11:12:21 [debug] 24481#0: *66 get rr peer, try: 1
2017/10/11 11:12:21 [debug] 24481#0: *66 get rr peer, current: 00000000067388F8 0
2017/10/11 11:12:21 [debug] 24481#0: *66 stream socket 4
2017/10/11 11:12:21 [debug] 24481#0: *66 epoll add connection: fd:4 ev:80000005
2017/10/11 11:12:21 [debug] 24481#0: *66 connect to 172.28.250.130:9901, fd:4 #68
2017/10/11 11:12:21 [debug] 24481#0: *66 http upstream connect: -2
2017/10/11 11:12:21 [debug] 24481#0: *66 posix_memalign: 00000000066F71D0:128 @16
2017/10/11 11:12:21 [debug] 24481#0: *66 event timer add: 4: 60000:1507691601519
2017/10/11 11:12:21 [debug] 24481#0: epoll: stale event 00002AD1E49F92B0
2017/10/11 11:12:21 [debug] 24481#0: timer delta: 1
2017/10/11 11:12:21 [debug] 24481#0: worker cycle
2017/10/11 11:12:21 [debug] 24481#0: epoll timer: 60000
2017/10/11 11:12:21 [debug] 24481#0: epoll: fd:4 ev:0019 d:00002AD1E49F92B1
2017/10/11 11:12:21 [debug] 24481#0: epoll_wait() error on fd:4 ev:0019
2017/10/11 11:12:21 [debug] 24481#0: *66 http upstream request: "/aa.php?"
2017/10/11 11:12:21 [debug] 24481#0: *66 http upstream process header
2017/10/11 11:12:21 [error] 24481#0: *66 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.22.103, server: localhost, request: "GET /aa.php HTTP/1.1", upstream: "fastcgi://172.28.250.130:9901", host: "172.28.250.184:8099"
2017/10/11 11:12:21 [debug] 24481#0: *66 http next upstream, 2
2017/10/11 11:12:21 [debug] 24481#0: *66 free rr peer 1 4
2017/10/11 11:12:21 [warn] 24481#0: *66 upstream server temporarily disabled while connecting to upstream, client: 192.168.22.103, server: localhost, request: "GET /aa.php HTTP/1.1", upstream: "fastcgi://172.28.250.130:9901", host: "172.28.250.184:8099"
2017/10/11 11:12:21 [debug] 24481#0: *66 free rr peer failed: 00000000067388F8 0
2017/10/11 11:12:21 [debug] 24481#0: *66 finalize http upstream request: 502
2017/10/11 11:12:21 [debug] 24481#0: *66 finalize http fastcgi request
2017/10/11 11:12:21 [debug] 24481#0: *66 close http upstream connection: 4
2017/10/11 11:12:21 [debug] 24481#0: *66 free: 00000000066F71D0, unused: 48
2017/10/11 11:12:21 [debug] 24481#0: *66 event timer del: 4: 1507691601519
2017/10/11 11:12:21 [debug] 24481#0: *66 reusable connection: 0
2017/10/11 11:12:21 [debug] 24481#0: *66 http finalize request: 502, "/aa.php?" a:1, c:1
2017/10/11 11:12:21 [debug] 24481#0: *66 http special response: 502, "/aa.php?"
2017/10/11 11:12:21 [debug] 24481#0: *66 internal redirect: "/50x.html?"

nginx fastcgi负载均衡的更多相关文章

  1. nginx+tomcat负载均衡

    最近练习nginx+tomcat负载均衡.根据一些资料整理了大体思路,最终实现了1个nginx+2个tomcat负载均衡. 安装JDK 1>进入安装目录,给所有用户添加可执行的权限 #chmod ...

  2. 使用Nginx实现负载均衡

    使用Nginx实现负载均衡 一.nginx简介 nginx是一个高性能的HTTP服务器和反向代理服务器.它起初是俄罗斯人Igor Sysoev开发的,至今支撑者俄罗斯的很多大型的网站. 二.nginx ...

  3. linux+nginx+tomcat负载均衡,实现session同步

    linux+nginx+tomcat负载均衡,实现session同步 花了一个上午的时间研究nginx+tomcat的负载均衡测试,集群环境搭建比较顺利,但是session同步的问题折腾了几个小时才搞 ...

  4. nginx+tomcat负载均衡策略

    測试环境均为本地,測试软件为: nginx-1.6.0,apache-tomcat-7.0.42-1.apache-tomcat-7.0.42-2.apache-tomcat-7.0.42-3 利用n ...

  5. 利用nginx实现负载均衡和动静分离

    1.Nginx介绍 Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器 . Nginx 是由 ...

  6. Nginx+Keepalived负载均衡高可用

    Nginx+Keepalived负载均衡高可用方案: Nginx 使用平台:unix.linux.windows. 功能: A.www web服务  http 80 b.负载均衡(方向代理proxy) ...

  7. Nginx实现负载均衡功能

    一.什么是Nginx? Nginx是一款轻量级的Web 服务器.反向代理服务器.电子邮件(IMAP/POP3)代理服务器. 二.Nginx的优点: 高并发连接:官方测试Nginx能够支撑5万并发连接, ...

  8. 若依项目利用nginx实现负载均衡及保持会话

    记录一下若依项目利用nginx实现负载均衡及保持会话的步骤. 此次作为试验性的测试,为了方便在本地window的环境上实现. 具体步骤: 1.安装两个tomcat8,可以下载一个后,另一个复制即可,下 ...

  9. nginx做负载均衡和tomcat简单集群

    Nginx做负载均衡和TOMCAT简单集群                1.下载安装nginx及其依赖包                                               ...

随机推荐

  1. jpa orderby

    return criteriaQuery.where(in).orderBy(new OrderImpl(root.get("field1"))).getRestriction() ...

  2. 打印低头思故乡 java

    public static void main(String args[][){ char poet[] = str.tocharArray(); int pos = 18; while(true){ ...

  3. Codeforces Beta Round #35 (Div. 2)

    Codeforces Beta Round #35 (Div. 2) http://codeforces.com/contest/35 A 这场的输入输出是到文件中的,不是标准的输入输出...没注意看 ...

  4. JavaScript各种继承方式(一):原型链继承(prototype chaining)

    一 原理 子类的构造函数的原型对象,是父类的构造函数创建的实例. function Fruit(){ this.name = '水果'; this.nutrition=['维生素','膳食纤维']; ...

  5. linux自旋锁、互斥锁、信号量

    为了避免并发,防止竞争.内核提供了一组同步方法来提供对共享数据的保护. 我们的重点不是介绍这些方法的详细用法,而是强调为什么使用这些方法和它们之间的差别. Linux 使用的同步机制可以说从2.0到2 ...

  6. HDU 6214 Smallest Minimum Cut(最少边最小割)

    Problem Description Consider a network G=(V,E) with source s and sink t. An s-t cut is a partition o ...

  7. 牛客网 Wannafly挑战赛12 删除子串(线性dp)

    题目描述 给你一个长度为n且由a和b组成的字符串,你可以删除其中任意的部分(可以不删),使得删除后的子串“变化”次数小于等于m次且最长. 变化:如果a[i]!=a[i+1]则为一次变化.(且新的字符串 ...

  8. f5负载均衡算法

    负载均衡使用一种算法或公式来确定由哪一个后台服务器接收流量 负载均衡是基于连接的 1.静态负载均衡算法:以固定方式分发连接 轮询算法(Round Robin):将请求依次顺序循环地分发给服务器,从1到 ...

  9. HW3 纠结的心得

    改好的controller //yuec2 Yue Cheng package hw3; import java.io.File; import java.text.DecimalFormat; im ...

  10. 月饼问题PAT B1020(贪心算法)

    月饼是中国人在中秋佳节时吃的一种传统食品,不同地区有许多不同风味的月饼.现给定所有种类月饼的库存量.总售价.以及市场的最大需求量,请你计算可以获得的最大收益是多少. 注意:销售时允许取出一部分库存.样 ...