NutzCN Logo
问答 nb启用jetty的性能疑问
发布于 2250天前 作者 文涛(wentao) 1603 次浏览 复制 上一个帖子 下一个帖子
标签:

请问nb采用jetty容器启动,性能如何,是默认nio还是bio,并发如何,有人测试过没

14 回复

nio的, 看JettyStarter的源码呗

嗯,之前项目用的netty做的http,但是并发高的时候会出现too many open files这样的错误,就担心更换nb后也会这样

而且修改了系统ulimit参数,同样出现上面的错误,且之后来的请求都不响应,必须重启服务

too many open file 得看具体的fd是哪些, 不能简单归咎于netty的原因

/proc/$pid/fd/ 下面的文件, fd == 句柄

是这个吗 /proc/$pid/fd/

pid是进程的id, 得替换成真实id啊...

(tensorflow) root@danoo-P65xHP:/opt/test# ll /proc/2045/fd
总用量 0
dr-x------ 2 elasticsearch elasticsearch  0 2月  16 01:07 ./
dr-xr-xr-x 9 elasticsearch elasticsearch  0 2月  16 01:07 ../
lr-x------ 1 elasticsearch elasticsearch 64 2月  16 01:07 0 -> /dev/null
l-wx------ 1 elasticsearch elasticsearch 64 2月  16 01:07 1 -> /dev/null
lr-x------ 1 elasticsearch elasticsearch 64 2月  16 01:07 10 -> /usr/share/elasticsearch/lib/lucene-spatial-extras-6.6.1.jar
l-wx------ 1 elasticsearch elasticsearch 64 2月  16 01:08 100 -> pipe:[39492]
lrwx------ 1 elasticsearch elasticsearch 64 2月  16 01:08 101 -> anon_inode:[eventpoll]
lr-x------ 1 elasticsearch elasticsearch 64 2月  16 01:08 102 -> pipe:[39493]
l-wx------ 1 elasticsearch elasticsearch 64 2月  16 01:08 103 -> pipe:[39493]
lrwx------ 1 elasticsearch elasticsearch 64 2月  16 01:08 104 -> anon_inode:[eventpoll]
lr-x------ 1 elasticsearch elasticsearch 64 2月  16 01:08 105 -> pipe:[39494]
l-wx------ 1 elasticsearch elasticsearch 64 2月  16 01:08 106 -> pipe:[39494]
lrwx------ 1 elasticsearch elasticsearch 64 2月  16 01:08 107 -> anon_inode:[eventpoll]
lr-x------ 1 elasticsearch elasticsearch 64 2月  16 01:08 108 -> pipe:[39495]
l-wx------ 1 elasticsearch elasticsearch 64 2月  16 01:08 109 -> pipe:[39495]
lr-x------ 1 elasticsearch elasticsearch 64 2月  16 01:07 11 -> /usr/share/elasticsearch/lib/log4j-core-2.9.1.jar
lrwx------ 1 elasticsearch elasticsearch 64 2月  16 01:08 110 -> anon_inode:[eventpoll]
lr-x------ 1 elasticsearch elasticsearch 64 2月  16 01:08 111 -> pipe:[39496]
l-wx------ 1 elasticsearch elasticsearch 64 2月  16 01:08 112 -> pipe:[39496]
lrwx------ 1 elasticsearch elasticsearch 64 2月  16 01:08 113 -> anon_inode:[eventpoll]
lr-x------ 1 elasticsearch elasticsearch 64 2月  16 01:08 114 -> pipe:[39497]
l-wx------ 1 elasticsearch elasticsearch 64 2月  16 01:08 115 -> pipe:[39497]
lrwx------ 1 elasticsearch elasticsearch 64 2月  16 01:08 116 -> anon_inode:[eventpoll]

@wendal 我看了jettyStarter的源码,看不出是不是启用的nio,能指导下吗?另外想知道默认的最小线程数20,最大500,是有什么依据或经验吗,如果服务器配置和网络带宽高,这个有没有向上调整提升并发量的可能,另外,如果同意台机器多实例运行,能否提高并发量呢,能否讨论下,谢谢!

首先, NIO的问题: https://www.eclipse.org/jetty/documentation/9.4.x/quickstart-config-what.html "which is NIO based"

Prior to Jetty 9, the type of the connector reflected both the protocol supported (HTTP, HTTPS, AJP, SPDY), and the nature of the implementation (NIO or BIO). From Jetty 9 onwards there is only one prime Connector type (ServerConnector), which is NIO based and uses Connection Factories to handle one or more protocols.

然后, 线程池默认最少200,最大500, 算是经验吧, 起码线上是这样,没出问题

这些都是可配置项, 需要根据业务进行调整

恩,知道了,那么如果一台机器开多个实例呢,不知道jetty有没有充分利用多核cpu性能

添加回复
请先登陆
回到顶部