背景
我司的软件在一个客户处测试功能和性能,这个客户比较特殊:java
http1.1host
host header问题(此时先直连后端服务,不考虑代理)
最开始是请求直接返400,nginx access log能够看到400可是没有更多信息,error log则没有任何信息打印,一开始另外一位同事负责定位,我跟着一块儿用wireshark抓包看了好久,没得出结论。后来我又看了一下,nginx error log默认的日志级别是crit,那么直接改到debug,看到这个信息:node

那么问题就一目了然了,查了一下,这个header是http1.1要求必须带的python

且nginx严格遵照该协议,没有提供可配置的方式忽略这个头,如上图按理说服务端不该该强行处理这种问题,但客户要求最高,没办法linux
这时候好在,正好咱们须要一层反向代理,那么,看看能不能找一个容许不带该header的反向代理服务器实现,接下来能够暂时忽略这个问题,咱们使用压测工具测性能,压测工具在这个header上是没有问题的nginx
代理布署及性能问题
windows server系统的服务器,一开始咱们直接用Nginx,但简单测后就知道性能不好,搜了一下基本是说nginx和apache在windows上性能都没啥但愿,首推的基本仍是微软自家的IIS,因而咱们配起了IIS,果真性能与直连后端相比基本没有损耗,可是通过很长时间查资料,找不到配置忽略host header的方法,并且IIS的确很差用,配置比较难看懂,你们都不熟悉windows平台,接下来只能另辟蹊径git
pythontwistednodejsredbirdjavaundertowgomissing required Host header
// hosts, haveHost := req.Header["Host"]
isH2Upgrade := req.isH2Upgrade()
// if req.ProtoAtLeast(1, 1) && (!haveHost || len(hosts) == 0) && !isH2Upgrade && req.Method != "CONNECT" {
// return nil, badRequestError("missing required Host header")
// }
// if len(hosts) > 1 {
// return nil, badRequestError("too many Host headers")
// }
// if len(hosts) == 1 && !httpguts.ValidHostHeader(hosts[0]) {
// return nil, badRequestError("malformed Host header")
// }
host header
golang socket使用问题
netstatTIME_WAIT
TIME_WAITCLOSE_WAITwindows socket time_wait
go socket time_wait
http.DefaultTransport.(*http.Transport).MaxIdleConns = 8192http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost = 81922
想一想python应该也能作到无损耗的,暂时没有再去研究,但从简单使用来看,脚本语言毕竟是脚本语言,你大爷仍是你大爷。