max_clients = worker_processes * worker_connections/4 , nginx做反向代理的时候为什么max_clients 要处以4

FROM NGINX WIKI:
worker_connections 
Syntax: worker_connections number 
Default: 
The worker_connections and worker_proceses from the main section allows you to calculate maxclients value: 
max_clients = worker_processes * worker_connections 
In a reverse proxy situation, max_clients becomes 
max_clients = worker_processes * worker_connections/4 
Since a browser opens 2 connections by default to a server ,and nginx uses the fds (file descriptors) from the same pool to connect to the upstream backend .

按照他的意思,
做http服务,浏览器只有1个连接,所以第一个公式没有除
做反向代理,浏览器会发2个连接,然后nginx又用两个连到后端,所以除了4


从浏览器到nginx,然后从nginx到后端,
从后端到nginx,再由nginx到浏览器。

就是成4了。


以上from http://bbs.chinaunix.net/thread-1767418-1-1.html

我的理解是:nginx做http server的时候, 服务端处理某个client的request和reply都用同1个fd, 

做反向代理的时候,request和reply是不一样的fd(应该不能一样,因为这里reply还需要等待后端服务器的返回结果,是异步的,request只要hold住连接就行了),并且nginx还需要另外2个不同的fd去连接后端的服务器,所以一共就是4个。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值