如何每秒测试10k套接字请求/响应 [英] How to Test 10k socket requests/responses per sec
问题描述
大家好,
阅读完C10K问题后,我想出了一个测试它的想法。我有两个家用桌面PC在家庭网络上测试,两个不同的动态IP。两台PC也都在便宜的路由器之下。
服务器端:
我用Java构建了一个非常简单的阻塞服务器程序,'One thread一个客户的想法。
它在一个循环中接受()客户端,一旦接受()ed它将创建一个服务线程。然后将服务线程传递给线程池。服务线程只有recv()/ send()10个字节来自/到客户端。
客户端:
我建立了客户端C ++创建100个线程,每个线程每10ms向服务器发送10个字节,因此如果我是正确的话,数学就像每秒10k个请求。
Tcp设置:
在两台PC上,最大端口号设置为60000+,tcptimewaitdelay为30秒。
Symtoms:
但是服务器端网络一直在濒临死亡。我必须重置调制解调器和路由器。
客户端无法连接或接收来自服务器的响应,如1/100。
我的问题是......(假设代码不应该责怪..)
'这是一个测试它的好方法吗?还是网络容量?还是硬件apec?'
谢谢,
期待阅读你的意见。
Hi guys,
After reading C10K problem, I came to an idea to test it. I got two home deskop PCs to test on home network, two different dynamic IPs. Both PC is under cheap routers as well.
Server Side:
I built a very simple blocking server program in Java, 'the One thread One client idea.
It accept() clients in a loop and once accept()ed it'll create a service thread. Then the service thread is passed to the thread pool. The service threads only recv()/send() 10 bytes from/to clients.
Client Side:
I built the client in C++ that creates 100 threads and each thread sends 10 bytes to the server every 10ms, so the math is like 10k requests per sec if I'm right.
Tcp Setting:
On both PCs, max port number is set to 60000+, and tcptimewaitdelay is 30s.
Symtoms:
But the server side network keeps dying. I have to reset the modem and router.
And client can't connect or receive response from the server like 1/100.
My questions are... (assuming the code is not to blame..)
'Is this a OK approach to test it? or is it the network capacity? or the hardware apec?'
Thank you,
looking forward to reading your opinions.
推荐答案
我的拙见是,这种方法有点不对,特别是在家庭环境中。
10字节的有用数据真的很少这会导致巨大的tcp / ip开销,所以我不会惊讶于SOHO路由器需要重新启动。
My humble opinion is, that this approach is a bit wrong, especially in home environment.
10 bytes of useful data is really little amount and this causes a huge tcp/ip overhead, so I'm not amazed that a SOHO router needs to be restarted.
或硬件apec?
我的猜测是,路由器无法处理这么多连接。
我怀疑该代码有错误,因为它工作,路由器似乎是瓶颈。
我希望,我帮助了一点:)。
My guess is, that the router can't handle so many connections.
I doubt that the code has errors,since it works and the router seems to be the bottleneck.
I hope, I helped a little :).
这篇关于如何每秒测试10k套接字请求/响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!