- 浏览: 67455 次
- 性别:
- 来自: 北京
最新评论
慢连接&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)是目前仓库的主要维护者。具体介绍可以从 看到。PLCT实验室 全称是程序语言与编译技术实验室。PLCT致力于成为编译技术领域的开源领导者,推进开源工具链及运行时系统等软件基础设施的技术革新,...
天然气汽车供气系统减压装置毕业设计(cad+设计方案)
PHP+SQL考勤系统安全性实现(源代码+论文+答辩PPT+指导书)
NumPy 的用途是什么
毕业设计 基于javaweb的在线答题平台
基于MATLAB的pca人脸识别.zip
课设毕设基于SSM的系统源码可运行
JAVAWML信息查询与后端信息发布系统实现——WML信息查询设计(源代码+LW)
毕业设计[整站程序]情感家园站 v3.0 For 个人版_qgweb30fp.zip
可以自动刷课,执行重复的脚本工作,内有详细操作教程。支持WIN7---WIN10系统。
Java项目之实验室计算机故障报修系统(源码) 开发语言:Java 框架:ssm 技术:JSP JDK版本:JDK1.8 服务器:tomcat7 数据库:mysql 5.7(一定要5.7版本) 数据库工具:Navicat11 开发软件:eclipse/myeclipse/idea Maven包:Maven3.3.9
协同过滤算法(Collaborative Filtering)是一种经典的推荐算法,其基本原理是“协同大家的反馈、评价和意见,一起对海量的信息进行过滤,从中筛选出用户可能感兴趣的信息”。它主要依赖于用户和物品之间的行为关系进行推荐。 协同过滤算法主要分为两类: 基于物品的协同过滤算法:给用户推荐与他之前喜欢的物品相似的物品。 基于用户的协同过滤算法:给用户推荐与他兴趣相似的用户喜欢的物品。 协同过滤算法的优点包括: 无需事先对商品或用户进行分类或标注,适用于各种类型的数据。 算法简单易懂,容易实现和部署。 推荐结果准确性较高,能够为用户提供个性化的推荐服务。 然而,协同过滤算法也存在一些缺点: 对数据量和数据质量要求较高,需要大量的历史数据和较高的数据质量。 容易受到“冷启动”问题的影响,即对新用户或新商品的推荐效果较差。 存在“同质化”问题,即推荐结果容易出现重复或相似的情况。 协同过滤算法在多个场景中有广泛的应用,如电商推荐系统、社交网络推荐和视频推荐系统等。在这些场景中,协同过滤算法可以根据用户的历史行为数据,推荐与用户兴趣相似的商品、用户或内容,从而提高用户的购买转化率、活跃度和社交体验。 未来,协同过滤算法的发展方向可能是结合其他推荐算法形成混合推荐系统,以充分发挥各算法的优势。
JAVAWEB校园二手平台项目,基本功能包括:个人信息、商品管理;交易商品板块管理等。本系统结构如下: (1)本月推荐交易板块: 电脑及配件:实现对该类商品的查询、用户留言功能 通讯器材:实现对该类商品的查询、用户留言功能 视听设备:实现对该类商品的查询、用户留言功能 书籍报刊:实现对该类商品的查询、用户留言功能 生活服务:实现对该类商品的查询、用户留言功能 房屋信息:实现对该类商品的查询、用户留言功能 交通工具:实现对该类商品的查询、用户留言功能 其他商品:实现对该类商品的查询、用户留言功能 (2)载入个人用户: 用户登陆 用户注册 (3)个人平台: 信息管理:实现对商品的删除、修改、查询功能 添加二手信息:实现对新商品的添加 修改个人资料:实现对用户个人信息的修改 注销
协同过滤算法(Collaborative Filtering)是一种经典的推荐算法,其基本原理是“协同大家的反馈、评价和意见,一起对海量的信息进行过滤,从中筛选出用户可能感兴趣的信息”。它主要依赖于用户和物品之间的行为关系进行推荐。 协同过滤算法主要分为两类: 基于物品的协同过滤算法:给用户推荐与他之前喜欢的物品相似的物品。 基于用户的协同过滤算法:给用户推荐与他兴趣相似的用户喜欢的物品。 协同过滤算法的优点包括: 无需事先对商品或用户进行分类或标注,适用于各种类型的数据。 算法简单易懂,容易实现和部署。 推荐结果准确性较高,能够为用户提供个性化的推荐服务。 然而,协同过滤算法也存在一些缺点: 对数据量和数据质量要求较高,需要大量的历史数据和较高的数据质量。 容易受到“冷启动”问题的影响,即对新用户或新商品的推荐效果较差。 存在“同质化”问题,即推荐结果容易出现重复或相似的情况。 协同过滤算法在多个场景中有广泛的应用,如电商推荐系统、社交网络推荐和视频推荐系统等。在这些场景中,协同过滤算法可以根据用户的历史行为数据,推荐与用户兴趣相似的商品、用户或内容,从而提高用户的购买转化率、活跃度和社交体验。 未来,协同过滤算法的发展方向可能是结合其他推荐算法形成混合推荐系统,以充分发挥各算法的优势。
Java游戏设计打飞机程序(源代码+LW)
Matlab实现CoMP多用户注水算法在最最基础的注水算法的基础上,实现了在功率受限速率受限的情况下CoMP多用户的功率分配.zip
自己写代码实现 Eigenface 人脸识别的训练与识别过程,纯手工实现 假设每张人脸图像只有一张人脸,且两只眼睛位置已知(即可人工标注给出)。每张图像的眼睛位置存在相应目录下的一个与图像文件名相同但后缀名为 txt 的文本文件里,文本文件中用一行、以空格分隔的 4 个数字表示,分别对应于两只眼睛中心在图像中的位置; 实现两个程序过程(两个执行文件),分别对应训练与识别; 自己构建一个人脸库(至少 40 人,包括自己),课程主页提供一个人脸库可选用; 不能直接调用 OpenCV 里面与 Eigenface 相关的一些函数,特征值与特征向量求解函数可以调用;只能用 C/C++/Python,不能用其他编程语言;GUI 只能用 OpenCV 自带的 HighGUI,不能用 QT 或其他的;平台可以用 Win/Linux/MacOS,建议 Win 优先;
有源电力滤波器的控制在MATLAB下的发展。三相电源电压是基于hysterezis正弦电流调节器.zip
BCH码的MATLAB程序源代码.zip
基于java的一个简单的即时通讯工具的设计与开发(源代码+LW)