压测,单机建立 100W 客户端,如何实现?

2015-08-11 11:05:30 +08:00
 yxaaa123

配置了20个虚拟ip来突破6W端口限制,但是客户端不提供配置本地ip的接口,如何实现?

4673 次点击
所在节点    Linux
18 条回复
mhycy
2015-08-11 11:16:30 +08:00
1000000*1480/1024/1024=1411.437988MB/S 先看看网络有没有可能做到这个带宽再说。
yxaaa123
2015-08-11 11:24:38 +08:00
@mhycy 先不考虑带宽,只考虑如何建立,呵呵
tabris17
2015-08-11 11:29:15 +08:00
yxaaa123
2015-08-11 11:35:52 +08:00
@tabris17 “两个配置为6G左右的centos测试端机器(绑定7个桥接或NAT连接)各自发出640007 = 448000。也就是 1024000 = (64000) + (64000) + (640007) + (64000*7), 共使用了16个网卡(物理网卡+虚拟网卡)。 ”关键这句话,不知道这么实现的。。。

假如:

物理ip 192.168.10.200

虚拟ip:192.168.10.201
192.168.10.202
.......
192.168.10.220

程序内 socket.connect(****),如果不配置本地ip,是没有办法用上虚拟ip的,那么,单个ip最多6W端口,也就只能开6W连接
9hills
2015-08-11 11:42:42 +08:00
@yxaaa123 用虚拟网卡

socket.connect 可以选择绑定的网卡
tabris17
2015-08-11 11:45:33 +08:00
@yxaaa123 你客户端程序不是自己写的吗?绑定IP都不行?
yxaaa123
2015-08-11 11:45:37 +08:00
@9hills 配置了虚拟网卡,只是不知道怎么使用。。。

没办法改程序,connect方法也只是使用默认的
yxaaa123
2015-08-11 11:46:55 +08:00
9hills
2015-08-11 11:56:35 +08:00
@yxaaa123 用iptables 也能实现
yxaaa123
2015-08-11 11:58:54 +08:00
@9hills 求教!
jarlyyn
2015-08-11 12:00:43 +08:00
实在不会搞上虚拟机不就行了……

感觉同时100w客户端不论怎么说一台机器都架不住吧,必然会使用反代之类?

ip的话不是会通过代理来获取么?
9hills
2015-08-11 12:28:45 +08:00
@yxaaa123 具体我没试过,不过大抵是这个方法:
1. 用iptables给不同的用户的流量打上不同标记
2. 用iprouter根据不同的标记设定不同的路由表和网卡

大概这样。。然后你创建N个用户,每个用户起6w连接。搜『 iptables route interface』

不过感觉还是修改client来的方便。。
zhicheng
2015-08-11 13:54:05 +08:00
会玩儿,我都是本机设置成吨的 127/8 loopback 测。。。
pmsg863
2015-08-11 16:12:15 +08:00
@tabris17 博客很多干货,感谢。
alexapollo
2015-08-11 16:42:55 +08:00
A server socket listens on a single port. All established client connections on that server are associated with that same listening port on the server side of the connection. An established connection is uniquely identified by the combination of client-side and server-side IP/Port pairs. Multiple connections on the same server can share the same server-side IP/Port pair as long as they are associated with different client-side IP/Port pairs, and the server would be able to handle as many clients as available system resources allow it to.

On the client-side, it is common practice for new outbound connections to use a random client-side port, in which case it is possible to run out of available ports if you make a lot of connections in a short amount of time.

-- http://stackoverflow.com/questions/11129212/tcp-two-different-sockets-sharing-a-port
xiyangyang
2015-08-11 18:40:35 +08:00
用多个服务器是肯定的了,关键代码和数据库怎么弄?
数据库必须是分布式的吗?还是可以像amazon的RDS?阿里云有类似的服务吗?
usernametoolong
2015-08-12 12:31:18 +08:00
单点测试都不易实现,就别说模拟百万级的用户了。
chinawrj
2015-08-12 13:06:14 +08:00
iptables 可以配合pid match以及策略路由可以实现。简单点说就是:
1. iptables 在nat中的OUTPUT匹配包所属的pid并且做fwmark
2. ip rule add 添加fwmark匹配规则
3. ip route add 添加具体路由策略。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/212304

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX