由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Servlet的IO吞吐瓶颈在哪里?为什么测下来只有3M bytes 左右?
相关主题
请问JSP/SERVLET和MYSQL如何实现照片上载和调用请推荐servlet还有jsp的书
java可以直接去读txt file里指定的一行吗?InputStream.read() 被block的问题(陷入无限等待)
用Java 读LAN上面windows shared folder上的文件,performancejunit question
How do I send cookies from a servlet?servlet读取directory的基本问题
理解Java Servlets [fwd]运行servlet时出现的http status 404问题
Another Servlet Problem:Browser Caching问个很简单的问题?
need your commentshelp about bitstream writer
Tabs defined by user can't be saved怎样吧byte[]变成java.security.Key?
相关话题的讨论汇总
话题: servlet话题: gigabit话题: 100m话题: stream话题: 吞吐
进入Java版参与讨论
1 (共1页)
d********r
发帖数: 199
1
Servlet的IO吞吐瓶颈在哪里?为什么测下来只有3M bytes 左右?
想测一下Tomcat servlet 的输出能力,就写了如下代码段:
1. Server: P4 3.0G, 1G DDR400 memory
输出一个100M bytes的http 文本。servlet key code segment 如下:
m******t
发帖数: 2416
2

I doubt you can get much faster than that. There's lots of overhead incurred
by the whole stack. A 3.5MBps rate of *payload* transmission implies a much
higher actual transmission rate.
Really? My experience has been the opposite constantly. How did you
benchmark it? Note that by the time you see the "flying files" dialog,
some overhead has already happened, so you can't really get an
accurate benchmark by timing the dialog.
All said and done, I wouldn't worry too much about the 3.5MBps rate -

【在 d********r 的大作中提到】
: Servlet的IO吞吐瓶颈在哪里?为什么测下来只有3M bytes 左右?
: 想测一下Tomcat servlet 的输出能力,就写了如下代码段:
: 1. Server: P4 3.0G, 1G DDR400 memory
: 输出一个100M bytes的http 文本。servlet key code segment 如下:

d********r
发帖数: 199
3
有多种办法可以监测网络吞吐:
可以在Windows Task Manager中的Networking中
也可以用DUMeter,
我两者都用了,TCP overhead并不高。
我这两台电脑的硬盘对拷,双方都是SATA RAID0,Gigabit网络连接,
速度至少30MB /s ,GB网卡的利用率峰值可接近30% (300M bps)。
所以TCP overhead并不足以解释何以servlet的吞吐率只有3.5MBytes/s (30M bps),
仅为windows network neighbor 文件copy的 1/10。
不知何故?

【在 m******t 的大作中提到】
:
: I doubt you can get much faster than that. There's lots of overhead incurred
: by the whole stack. A 3.5MBps rate of *payload* transmission implies a much
: higher actual transmission rate.
: Really? My experience has been the opposite constantly. How did you
: benchmark it? Note that by the time you see the "flying files" dialog,
: some overhead has already happened, so you can't really get an
: accurate benchmark by timing the dialog.
: All said and done, I wouldn't worry too much about the 3.5MBps rate -

m******t
发帖数: 2416
4

I'm a bit confused. In the OP you only mentioned "100M LAN" instead of
Gigabit.
If you are getting this rate over a gigabit connection, I guess
you'd have to blame all the buffer copying inside the java stream
implementation. Did you try to open up a socket yourself and see
how fast that goes?

【在 d********r 的大作中提到】
: 有多种办法可以监测网络吞吐:
: 可以在Windows Task Manager中的Networking中
: 也可以用DUMeter,
: 我两者都用了,TCP overhead并不高。
: 我这两台电脑的硬盘对拷,双方都是SATA RAID0,Gigabit网络连接,
: 速度至少30MB /s ,GB网卡的利用率峰值可接近30% (300M bps)。
: 所以TCP overhead并不足以解释何以servlet的吞吐率只有3.5MBytes/s (30M bps),
: 仅为windows network neighbor 文件copy的 1/10。
: 不知何故?

p***p
发帖数: 559
5
Servlet just used ServetSocket's I/O Stream, nothing to do with Container.

【在 m******t 的大作中提到】
:
: I'm a bit confused. In the OP you only mentioned "100M LAN" instead of
: Gigabit.
: If you are getting this rate over a gigabit connection, I guess
: you'd have to blame all the buffer copying inside the java stream
: implementation. Did you try to open up a socket yourself and see
: how fast that goes?

m******t
发帖数: 2416
6

Hmm, no... servlet implementations (including HttpServletRequest and
HttpServletResponse) are container specific. I agree with you that ideally
when you get the output stream it should be exactly the underlying
socket stream, but there are too many layers in between to be sure
- for example, you never know if any filter suddenly decides to get
cute and wrap the output stream with its own buffered version.

【在 p***p 的大作中提到】
: Servlet just used ServetSocket's I/O Stream, nothing to do with Container.
d********r
发帖数: 199
7
我在gigabit网上测过windows文件对拷。知道速度是多少。
现在先在100M网卡上测servlet,如果发现100M NIC是瓶颈,
我就会再在Gigabit LAN上再测一次。
结果发现速度太低,100M上只利用了30%的带宽,就没兴趣再在giga LAN上测了。
因为我没有gigabit switch,平常都是用100M,
如果要测gigabit的话,得用一根网线把两台PC的gigabit网卡直接连起来。
平时都是走100M switch的

【在 m******t 的大作中提到】
:
: Hmm, no... servlet implementations (including HttpServletRequest and
: HttpServletResponse) are container specific. I agree with you that ideally
: when you get the output stream it should be exactly the underlying
: socket stream, but there are too many layers in between to be sure
: - for example, you never know if any filter suddenly decides to get
: cute and wrap the output stream with its own buffered version.

m******t
发帖数: 2416
8

So you did get 3.5MBps payload transmission rate
over a 100Mbps physical connection, and that's
what I was saying - that's about right,
I don't see anything too far off.

【在 d********r 的大作中提到】
: 我在gigabit网上测过windows文件对拷。知道速度是多少。
: 现在先在100M网卡上测servlet,如果发现100M NIC是瓶颈,
: 我就会再在Gigabit LAN上再测一次。
: 结果发现速度太低,100M上只利用了30%的带宽,就没兴趣再在giga LAN上测了。
: 因为我没有gigabit switch,平常都是用100M,
: 如果要测gigabit的话,得用一根网线把两台PC的gigabit网卡直接连起来。
: 平时都是走100M switch的

o**g
发帖数: 1
9
some java code somewhere is to blame (java Socket should be innocent)
to diagnose:
try not use BufferedIn/OutputStream (your buffer is already much bigger
than their buffers)
try run both server and client on localhost
try 2 concurrent clients
try a non java client, say a browser

【在 d********r 的大作中提到】
: Servlet的IO吞吐瓶颈在哪里?为什么测下来只有3M bytes 左右?
: 想测一下Tomcat servlet 的输出能力,就写了如下代码段:
: 1. Server: P4 3.0G, 1G DDR400 memory
: 输出一个100M bytes的http 文本。servlet key code segment 如下:

d********r
发帖数: 199
10
试过run server and client @ same PC,差别不大
也试过不用BufferedIn/OutputStream,差别也不大。
没试过2 concurrent clients,回头试试看。

【在 o**g 的大作中提到】
: some java code somewhere is to blame (java Socket should be innocent)
: to diagnose:
: try not use BufferedIn/OutputStream (your buffer is already much bigger
: than their buffers)
: try run both server and client on localhost
: try 2 concurrent clients
: try a non java client, say a browser

g*****g
发帖数: 34805
11
And try nio package see if it helps.

【在 d********r 的大作中提到】
: 试过run server and client @ same PC,差别不大
: 也试过不用BufferedIn/OutputStream,差别也不大。
: 没试过2 concurrent clients,回头试试看。

y***d
发帖数: 2330
12
你输出 http header 了吗?似乎没有啊,这样 http server 会瞅啊瞅啊瞅不到\r\n\r\n

【在 d********r 的大作中提到】
: Servlet的IO吞吐瓶颈在哪里?为什么测下来只有3M bytes 左右?
: 想测一下Tomcat servlet 的输出能力,就写了如下代码段:
: 1. Server: P4 3.0G, 1G DDR400 memory
: 输出一个100M bytes的http 文本。servlet key code segment 如下:

d********r
发帖数: 199
13
这位大侠果然高见,真是一针见血啊。
我在原servlet程序的buffer里,加了一个"\r\n",
结果在Gigabit网上测试,传输率轻松达到了40MB/s,也就是平均约320Mbps,
峰值可达400Mbps。
佩服佩服。
看来现在的瓶颈在系统本身的总线带宽了。

\n

【在 y***d 的大作中提到】
: 你输出 http header 了吗?似乎没有啊,这样 http server 会瞅啊瞅啊瞅不到\r\n\r\n
y***d
发帖数: 2330
14
哈哈,我牛吧;
注意 header 的结束是“\r\n\r\n”,不是“\r\n”;最好输出完整的 header。

【在 d********r 的大作中提到】
: 这位大侠果然高见,真是一针见血啊。
: 我在原servlet程序的buffer里,加了一个"\r\n",
: 结果在Gigabit网上测试,传输率轻松达到了40MB/s,也就是平均约320Mbps,
: 峰值可达400Mbps。
: 佩服佩服。
: 看来现在的瓶颈在系统本身的总线带宽了。
:
: \n

1 (共1页)
进入Java版参与讨论
相关主题
怎样吧byte[]变成java.security.Key?理解Java Servlets [fwd]
怎麼得到字符串中的raw bytes?Another Servlet Problem:Browser Caching
How to parse the bytes[]need your comments
JAVA 一族Tabs defined by user can't be saved
请问JSP/SERVLET和MYSQL如何实现照片上载和调用请推荐servlet还有jsp的书
java可以直接去读txt file里指定的一行吗?InputStream.read() 被block的问题(陷入无限等待)
用Java 读LAN上面windows shared folder上的文件,performancejunit question
How do I send cookies from a servlet?servlet读取directory的基本问题
相关话题的讨论汇总
话题: servlet话题: gigabit话题: 100m话题: stream话题: 吞吐