`
youxinrencwx
  • 浏览: 73020 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

慢连接&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版本)配置基本没变。JettyLazy解析缓存为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. 是否设置使用lazyhttp header来引导服务端处理。

3. 构建参数集合,参数顺序为(key1,key2,key3,key4)。其中key3作为一个大数据字段可变,用于多个场景测试。

测试结果及分析:

1. 设置key3大小为1000char,对比多个场景:

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大小为100000char,对比多个场景:

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

上面的输出大家会看到虽然我给了8klazy解析缓冲区,但是每次过来的数据都是1440,这个数字的含义大家可以去查一下TCP传输的数据包大小定义。可以看到,其实如果网络速度不佳,我们就会一个一个的得到数据包,Java IO次数及每次消耗的时间都会较长,同时这也是直接把Java应用服务器对外接收请求在高并发,慢请求的状况下,系统压力会远高于前端假设反向代理http服务器。

总结:

测试很简单,但说明了几个问题:

1. 互联网上的请求和内网测试环境完全是两码事情(如果你还打算支持mobile)。

2. Nginxapache作为反向代理,对于后端的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.优化jettybio模式的nio3.替换掉jettynio模块(netty)。最终不是让前端采用部分堆积,就是直接暴露应用容器到外部,再加上lazyparser,来完成对于慢连接的优化。

分享到:
评论

相关推荐

    ProMesh-25584

    “LazyParser.NET”和“SharpTemplate.NET”可能是项目中使用的两个组件或子模块,前者可能是一个懒加载解析器,用于提高性能,后者可能是用于生成动态HTML模板的库。而“ProMesh.NET”可能是一个项目的主干代码文件...

    weloveinterns:中科院软件所智能软件中心实习生社区

    吴伟(lazyparser)是目前仓库的主要维护者。具体介绍可以从 看到。PLCT实验室 全称是程序语言与编译技术实验室。PLCT致力于成为编译技术领域的开源领导者,推进开源工具链及运行时系统等软件基础设施的技术革新,...

    基于ARM架构服务器部署docker-compose

    基于arm64版本的docker-compose文件

    附件3-4:台区智能融合终端全性能试验增值税发票开具确认单.docx

    台区终端电科院送检文档

    埃夫特机器人Ethernet IP 通讯配置步骤

    埃夫特机器人Ethernet IP 通讯配置步骤

    rv320e机器人重型关节行星摆线减速传动装置研发.rar

    rv320e机器人重型关节行星摆线减速传动装置研发

    气缸驱动爬杆机器人的设计().zip

    气缸驱动爬杆机器人的设计().zip

    软件工程中期答辩1234567

    56tgyhujikolp[

    基于OpenCV的数字身份验证系统:人脸检测、训练与识别的Python实现

    内容概要:本文档提供了基于OpenCV的数字身份验证系统的Python代码示例,涵盖人脸检测、训练和识别三个主要功能模块。首先,通过调用OpenCV的CascadeClassifier加载预训练模型,实现人脸检测并采集多张人脸图像用于后续训练。接着,利用LBPH(局部二值模式直方图)算法对面部特征进行训练,生成训练数据集。最后,在实际应用中,系统能够实时捕获视频流,对比已有的人脸数据库完成身份验证。此外,还介绍了必要的环境配置如依赖库安装、文件路径设置以及摄像头兼容性的处理。 适合人群:对计算机视觉感兴趣的研发人员,尤其是希望深入了解OpenCV库及其在人脸识别领域的应用者。 使用场景及目标:适用于构建安全认证系统的企业或机构,旨在提高出入管理的安全性和效率。具体应用场景包括但不限于门禁控制系统、考勤打卡机等。 其他说明:文中提供的代码片段仅为基本框架,可根据实际需求调整参数优化性能。同时提醒开发者注意隐私保护法规,合法合规地收集和使用个人生物识别信息。

    Java并发编程面试题详解:123道经典题目解析与实战技巧

    内容概要:本文档详细介绍了Java并发编程的核心知识点,涵盖基础知识、并发理论、线程池、并发容器、并发队列及并发工具类等方面。主要内容包括但不限于:多线程应用场景及其优劣、线程与进程的区别、线程同步方法、线程池的工作原理及配置、常见并发容器的特点及使用场景、并发队列的分类及常用队列介绍、以及常用的并发工具类。文档旨在帮助开发者深入理解和掌握Java并发编程的关键技术和最佳实践。 适合人群:具备一定Java编程经验的研发人员,尤其是希望深入了解并发编程机制、提高多线程应用性能的中级及以上水平的Java开发者。 使用场景及目标:①帮助开发者理解并发编程的基本概念和技术细节;②指导开发者在实际项目中合理运用多线程和并发工具,提升应用程序的性能和可靠性;③为准备Java技术面试的候选人提供全面的知识参考。 其他说明:文档内容详尽,适合用作深度学习资料或面试复习指南。建议读者结合实际编码练习,逐步掌握并发编程技巧。文中提到的多种并发工具类和容器,均附有具体的应用场景和注意事项,有助于读者更好地应用于实际工作中。

    个人健康与健身追踪数据集,包含了日常步数统计、睡眠时长、活跃分钟数以及消耗的卡路里,适用于数据分析、机器学习

    这个数据集包含了日常步数统计、睡眠时长、活跃分钟数以及消耗的卡路里,是个人健康与健身追踪的一部分。 该数据集非常适合用于以下实践: 数据清洗:现实世界中的数据往往包含缺失值、异常值或不一致之处。例如,某些天的步数可能缺失,或者存在不切实际的数值(如10,000小时的睡眠或负数的卡路里消耗)。通过处理这些问题,可以学习如何清理和准备数据进行分析。 探索性分析(发现日常习惯中的模式):可以通过分析找出日常生活中的模式和趋势,比如一周中哪一天人们通常走得最多,或是睡眠时间与活跃程度之间的关系等。 构建可视化图表(步数趋势、睡眠与活动对比图):将数据转换成易于理解的图形形式,有助于更直观地看出数据的趋势和关联。例如,绘制步数随时间变化的趋势图,或是比较睡眠时间和活动量之间的关系图。 数据叙事(将个人风格的追踪转化为可操作的见解):通过讲述故事的方式,把从数据中得到的洞察变成具体的行动建议。例如,根据某人特定时间段内的活动水平和睡眠质量,提供改善健康状况的具体建议。

    《基于YOLOv8的港口船舶靠泊角度偏差预警系统》(包含源码、可视化界面、完整数据集、部署教程)简单部署即可运行。功能完善、操作简单,适合毕设或课程设计.zip

    资源内项目源码是来自个人的毕业设计,代码都测试ok,包含源码、数据集、可视化页面和部署说明,可产生核心指标曲线图、混淆矩阵、F1分数曲线、精确率-召回率曲线、验证集预测结果、标签分布图。都是运行成功后才上传资源,毕设答辩评审绝对信服的保底85分以上,放心下载使用,拿来就能用。包含源码、数据集、可视化页面和部署说明一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.txt文件,仅供学习参考, 切勿用于商业用途。

    nginx 访问访问日志按天切割 shell脚本

    nginx

    《基于YOLOv8的核废料运输容器密封性检测系统》(包含源码、可视化界面、完整数据集、部署教程)简单部署即可运行。功能完善、操作简单,适合毕设或课程设计.zip

    资源内项目源码是来自个人的毕业设计,代码都测试ok,包含源码、数据集、可视化页面和部署说明,可产生核心指标曲线图、混淆矩阵、F1分数曲线、精确率-召回率曲线、验证集预测结果、标签分布图。都是运行成功后才上传资源,毕设答辩评审绝对信服的保底85分以上,放心下载使用,拿来就能用。包含源码、数据集、可视化页面和部署说明一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.txt文件,仅供学习参考, 切勿用于商业用途。

    《基于YOLOv8的农业无人机播种深度监测系统》(包含源码、可视化界面、完整数据集、部署教程)简单部署即可运行。功能完善、操作简单,适合毕设或课程设计.zip

    资源内项目源码是来自个人的毕业设计,代码都测试ok,包含源码、数据集、可视化页面和部署说明,可产生核心指标曲线图、混淆矩阵、F1分数曲线、精确率-召回率曲线、验证集预测结果、标签分布图。都是运行成功后才上传资源,毕设答辩评审绝对信服的保底85分以上,放心下载使用,拿来就能用。包含源码、数据集、可视化页面和部署说明一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.txt文件,仅供学习参考, 切勿用于商业用途。

    uniapp知识付费(流量主)demo

    模拟知识付费小程序,可流量主运营模式

    java高并发之分片上传

    什么是普通上传 调用接口一次性完成一个文件的上传。 普通上传2个缺点 文件无法续传,比如上传了一个比较大的文件,中间突然断掉了,需要重来 大文件上传太慢 解决方案 分片上传

    英二2010-2021阅读理解 Part A 题干单词(补).pdf

    英二2010-2021阅读理解 Part A 题干单词(补).pdf

    2023-04-06-项目笔记 - 第四百五十五阶段 - 4.4.2.453全局变量的作用域-453 -2025.04-01

    2023-04-06-项目笔记-第四百五十五阶段-课前小分享_小分享1.坚持提交gitee 小分享2.作业中提交代码 小分享3.写代码注意代码风格 4.3.1变量的使用 4.4变量的作用域与生命周期 4.4.1局部变量的作用域 4.4.2全局变量的作用域 4.4.2.1全局变量的作用域_1 4.4.2.453局变量的作用域_453- 2025-04-01

    友缘公司钢材管理平台微信小程序的设计与实现.zip

    微信小程序项目课程设计,包含LW+ppt

Global site tag (gtag.js) - Google Analytics