- 浏览: 74145 次
- 性别:
- 来自: 北京
-
最新评论
慢连接&LazyParser
慢连接&LazyParser
Author:放翁(文初)
Mail:fangweng@taobao.com
Tblog:weibo.com/fangweng
这里要从实际的测试中给Web应用开发者一个比较直观的关于慢连接优化的建议。
测试目标:
1. 证明慢连接对于Java的应用容器的影响。
2. 不同前端反向代理服务器对于慢连接的处理差异。
3. 如何利用LazyParser的方式来优化慢连接请求(特别是大数据量的一些异常请求的处理)
测试部署环境描述:
Apache服务器(2.2.19版本)配置基本没变,增加了http proxy模块作为反向代理。
Nginx服务器(1.0.4版本)配置基本没变,增加了反向代理。
Jetty服务器(7.1.6版本)配置基本没变。Jetty的Lazy解析缓存为8k。
部署如下,外部请求可以通过三个入口访问应用真实逻辑。(apache,nginx,jetty)
测试代码:
服务端:
简单描述一下逻辑:
1. 根据http消息头判断采用lazy还是普通方式解析。
2. 输出start test表示开始。
3. 获取key1,key2的内容,并记录消耗时间输出phase 1 use:xxx作为获取这两个参数的消耗。
4. 获取key4的内容,并记录消耗时间输出phase 2 use:xxx作为获取这个参数的消耗。
5. 获取key3的内容,并记录整个请求消耗的时间,输出end total use:xxx,作为整个处理消耗的时间。
客户端代码:
1. 配置不同入口访问应用。
2. 是否设置使用lazy的http header来引导服务端处理。
3. 构建参数集合,参数顺序为(key1,key2,key3,key4)。其中key3作为一个大数据字段可变,用于多个场景测试。
测试结果及分析:
1. 设置key3大小为1000个char,对比多个场景:
a. 不用lazy解析模式
(1) 通过nginx访问:
Nginx日志(第一位是消耗时间单位秒):0.002 115.193.162.12 - - [20/Jun/2011:10:50:44 -0400] "POST /cometpipe/slowtest?key1=1 HTTP/1.1" 200 19 "-" "Jakarta Commons-HttpClient/3.0.1" "-"
Jetty日志:
start test: not use lazy
phase 1 use :0
phase 2 use :1
end total use:1
(2) 通过 apache访问:
Apache日志:(第二位消耗时间单位微秒):0 3513 115.193.162.12 - - [20/Jun/2011:10:53:24 -0400] "POST /cometpipe/slowtest?key1=1 HTTP/1.1" 200 9
Jetty日志:
start test: not use lazy
phase 1 use :0
phase 2 use :0
end total use:0
(3) 直接访问jetty:
Jetty日志:
start test: not use lazy
phase 1 use :1
phase 2 use :0
end total use:1
b. 用lazy解析模式
同样是上面三种模式,web容器的日志就不写出来了结果一样,下面主要是贴一下应用服务器的情况:
----------------------------------------------------jetty
start test : uselazy
Jun 20, 2011 10:57:24 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1019
phase 1 use :1
Jun 20, 2011 10:57:24 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: -1
phase 2 use :0
end total use:1
-----------------------------------------------------------nginx
start test : uselazy
Jun 20, 2011 10:58:37 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1019
phase 1 use :0
Jun 20, 2011 10:58:37 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: -1
phase 2 use :0
end total use:0
-----------------------------------------------------------apache
start test : uselazy
Jun 20, 2011 10:58:45 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1019
phase 1 use :0
Jun 20, 2011 10:58:45 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: -1
phase 2 use :1
end total use:1
上面的输出增加了一些,其实lazyparser在逐块解析字节流的时候每次装载数据的输出,lazyparser的缓冲区当前设置最大为8k,根据上面的情况可以看到不论哪一种方式,数据一次性都被装载,不存在后端处理的差异。
2. 设置key3大小为100000个char,对比多个场景:
a. 不用lazy解析模式
(1) 通过nginx访问:
Nginx日志(第一位是消耗时间单位秒):1.528 115.193.162.12 - - [20/Jun/2011:11:05:34 -0400] "POST /cometpipe/slowtest?key1=1 HTTP/1.1" 200 19 "-" "Jakarta Commons-HttpClient/3.0.1" "-"(消耗时间大幅上升)
Jetty日志:
start test: not use lazy
phase 1 use :5
phase 2 use :0
end total use:6
(2) 通过 apache访问:
Apache日志:(第二位消耗时间单位微秒):1 1502243 115.193.162.12 - - [20/Jun/2011:11:07:10 -0400] "POST /cometpipe/slowtest?key1=1 HTTP/1.1" 200 9
Jetty日志:
start test: not use lazy
phase 1 use :609
phase 2 use :0
end total use:609
(3) 直接访问jetty:
Jetty日志:
start test: not use lazy
phase 1 use :1463
phase 2 use :0
end total use:1463
从上面几个数据来看,首先不论哪个入口进去,总的时间处理都在1.5秒左右(我的网络状况还是比较烂),但nginx的数据堆积效果对jetty起到了明显的保护作用,使得jetty整个容器线程池生命周期较短,可以处理更多的请求,apache数据堆积不是全量堆积,因此对于jetty来说还需要自身的一些堆积处理(这点在后面的lazy模式下将会更加直观的看到过程)
b. 用lazy解析模式
(1) 通过nginx访问:
Nginx日志(第一位是消耗时间单位秒):1.513 115.193.162.12 - - [20/Jun/2011:11:13:22 -0400] "POST /cometpipe/slowtest?key1=1 HTTP/1.1" 200 19 "-" "Jakarta Commons-HttpClient/3.0.1" "-"(消耗时间大幅上升)
Jetty日志:
start test : uselazy
Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 5911
phase 1 use :1
Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 8192
Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 8192
Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 8192
Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 8192
Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 8192
Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 8192
Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 8192
Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 8192
Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 8192
Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 8192
Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 8192
Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 3996
Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: -1
phase 2 use :7
end total use:8
从上面的结果可以看到,nginx的数据堆积效果很好,jetty都是塞满lazyparser的缓存大小来处理的,所以Java IO次数少,整体消耗时间短。
(2) 通过 apache访问:
Apache日志:(第二位消耗时间单位微秒):1 1521576 115.193.162.12 - - [20/Jun/2011:11:16:37 -0400] "POST /cometpipe/slowtest?key1=1 HTTP/1.1" 200 9
Jetty日志:
start test : uselazy
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 5787
phase 1 use :1
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 8192
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 2405
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:13,count: 8096
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:280,count: 8192
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 448
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:6,count: 8192
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 448
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:13,count: 8192
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 448
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:10,count: 8192
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 448
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:265,count: 8192
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 448
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:7,count: 8192
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 448
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:13,count: 8192
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 448
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:7,count: 8192
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 448
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:6,count: 6419
Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: -1
phase 2 use :627
end total use:628
可以看到第一阶段处理由于是lazy的模式,没有像普通请求处理那样消耗都在第一阶段,而是把消耗时间落在了真正要拿那些数据处理的第二阶段,同时可以看到apache有满cache和非满cache的数据后传,同时由于是变积累边传递,每次后传所消耗的时间都要远大于nginx,因此对于jetty的保护较弱。(所以如果你不是用mod_jk去直接反向代理到后段的应用容器(jboss,tomcat,jetty)都会使得应用服务器load比较高,线程生命周期长了,线程切换频繁)
(3) 直接访问jetty:
Jetty日志:
start test : uselazy
Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1217
phase 1 use :1
Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1440
Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:294,count: 1440
Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1440
Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:309,count: 1440
Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1440
Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:2,count: 1440
Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:2,count: 1440
Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:287,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:2,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:4,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:2,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:3,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:2,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:2,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:273,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:16,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:2,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:2,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:246,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:23,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:1,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 1440
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: 882
Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes
SEVERE: timconsume:0,count: -1
phase 2 use :1532
end total use:1533
上面的输出大家会看到虽然我给了8k的lazy解析缓冲区,但是每次过来的数据都是1440,这个数字的含义大家可以去查一下TCP传输的数据包大小定义。可以看到,其实如果网络速度不佳,我们就会一个一个的得到数据包,Java IO次数及每次消耗的时间都会较长,同时这也是直接把Java应用服务器对外接收请求在高并发,慢请求的状况下,系统压力会远高于前端假设反向代理http服务器。
总结:
测试很简单,但说明了几个问题:
1. 互联网上的请求和内网测试环境完全是两码事情(如果你还打算支持mobile)。
2. Nginx和apache作为反向代理,对于后端的web容器的处理是有一定帮助的,特别是nginx,作为数据堆积和海量连接的并发支持能够很好的充分利用后端应用服务器的线程资源。
3. 不论哪一种模式,总体请求时间都是差不多的,因此RT在后端资源不是瓶颈的时候,不会由于你架设了反向代理而得到优化,反而会有所增长(毕竟多了一层中转)
4. Lazy处理可以极大提高串行化分阶段处理的性能(特别是在没有数据堆积的情况下或者是apache这样的半数据堆积的情况下,在nginx模式下失效)。比如一个很大的请求,如果在第一阶段就被判断系统参数校验错误,那么后续的请求数据将直接拒绝(或者类似于有图片大小限制或者是图片个数限制的判断)。
5. 应用服务器(jetty,tomcat,jboss等等)不论使用nio或者bio模式,在慢连接的情况下都会有不小的性能消耗。
对于开放平台来说,每天处理几十亿的api call,和普通的web应用不同,每一次请求的时间就贯穿于容器对于数据流的载入,处理,一点优化都可以极大地提高整体的处理能力和资源使用效率,当前开放平台采用nginx+jetty,虽然可以保护到jetty对于高并发的慢连接支持,但是整体的响应时间及资源消耗状况都没有被充分利用到(虽然Lazy解析已经被装配上,apache+jboss时代比较有效果),因此后续考虑要做三种改进:1.让nginx支持部分数据堆积模式。2.优化jetty的bio模式的nio。3.替换掉jetty的nio模块(netty)。最终不是让前端采用部分堆积,就是直接暴露应用容器到外部,再加上lazyparser,来完成对于慢连接的优化。
相关推荐
“LazyParser.NET”和“SharpTemplate.NET”可能是项目中使用的两个组件或子模块,前者可能是一个懒加载解析器,用于提高性能,后者可能是用于生成动态HTML模板的库。而“ProMesh.NET”可能是一个项目的主干代码文件...
吴伟(lazyparser)是目前仓库的主要维护者。具体介绍可以从 看到。PLCT实验室 全称是程序语言与编译技术实验室。PLCT致力于成为编译技术领域的开源领导者,推进开源工具链及运行时系统等软件基础设施的技术革新,...
毕业论文- 深蓝健身房瑜伽馆行业小程序V4.15.0 前端+后端-整站商业源码.zip
36氪:2019中国开放式创新观察.pdf
毕业论文-化妆品商城-整站商业源码.zip
毕业论文-MNews2.4-整站商业源码.zip
X-AnyLabeling自动标注模型
【鼎软天下】科技赋能物流,数字驱动变革.pdf
实训商业源码-王中王掌上游戏机网页源码,怀旧小游戏-毕业设计.zip
内容概要:本文提出了一种基于强化学习(RL)的前向纠错(FEC)调整方法——R-FEC,旨在优化WebRTC视频会议中的用户体验质量(QoE)。传统方法在确定适当的FEC比例时面临挑战,因为过高的FEC会增加延迟并降低视频质量,而过低则无法有效应对丢包。R-FEC通过RL算法动态调整视频和FEC比特率,在不同的网络条件下最大化QoE,同时最小化网络拥塞。实验表明,R-FEC相比现有最佳解决方案可提高视频速率达27%,并改善视频质量6dB。 适合人群:对视频会议系统优化、网络通信协议、机器学习特别是强化学习有兴趣的研究人员和技术人员。 使用场景及目标:①需要在视频会议中实现实时通信的应用开发者;②希望提升视频通话质量、减少延迟的技术团队;③研究如何在动态网络环境中优化数据传输的研究机构。 其他说明:R-FEC不仅解决了现有方法中FEC设置不合理的问题,还展示了在实际网络环境下显著优于其他方法的表现。此外,作者指出未来工作将扩展到多方通话场景,并考虑更多复杂的网络条件。该研究得到了Cisco Systems和韩国国家研究基金会的支持。
内容概要:本文介绍了流量整形(Traffic Shaping)与增强传输选择(Enhanced Transmission Selection, ETS)技术在多虚拟函数(VFs)共享单个物理网络接口控制器(NIC)端口情况下的应用。流量整形通过对数据发送速率进行限制来管理网络流量,确保节点不会超过设定的最大带宽,同时保证最小带宽。ETS是IEEE 802.1Qaz标准的一部分,旨在数据中心桥接环境中为不同类型的流量分配带宽。文章详细描述了在多VF组中实现每类流量带宽保证的技术挑战和解决方案,包括使用令牌桶算法、加权循环调度(DWRR)、多队列优先级(MQPRIO)以及信任模式(Trust Mode)进行流量分类。此外,还探讨了如何通过扩展devlink-rate工具指定每个流量类别的带宽比例。 适合人群:网络工程师、系统管理员、云服务提供商以及对网络流量管理和优化感兴趣的IT专业人员。 使用场景及目标:①理解流量整形的基本概念及其在网络通信中的作用;②掌握如何配置虚拟功能(VF)以实现对特定流量类别的带宽控制;③学习如何利用ETS机制确保关键业务获得足够的网络资源;④了解最新的devlink-rate扩展功能及其在实际部署中的应用。 其他说明:本文基于Netdev 0x19会议上的演讲整理而成,提供了从背景介绍到具体实施步骤的全面讲解,并附有详细的参考资料链接供进一步研究。
实训商业源码-自适应极简多引擎搜索源码-毕业设计.zip
该源码库为LilyGo T_QT开发板量身定制,专注于物联网通信功能,包含1792个文件,涵盖512个头文件、448个C语言源文件、213个Arduino脚本文件、151个Python脚本、139个Markdown文档、63个PNG图片文件、55个reStructuredText文件、38个Vera Lite Widget文件、18个文本文件、18个C++源文件。语言多样,支持C、C++、Python、C++、Shell、HTML、CSS和Ruby。库内容丰富,是进行物联网通信开发不可或缺的资源。
学生心理健康服务平台是一个集心理咨询、心理测评、资源共享和社区互动于一体的综合服务平台,包含Web/移动端应用和管理后台两部分。该项目旨在为高校学生提供便捷、专业的心理健康服务,帮助学生缓解心理压力,促进心理健康发展。
毕业论文-二次元应用下载页源码 带弹幕-整站商业源码.zip
实训商业源码-影视资源站源码 电脑+手机模板-毕业设计.zip
Baidunetdisk_AndroidPhone_1023843j (6).apk
《Creo Simulation Live》数据表.pdf
实训商业源码-源授权V1.5-毕业设计.zip
实训商业源码-微信淘宝客5.99.78 加密-毕业设计.zip