V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
yxaaa123
V2EX  ›  Linux

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

  •  
  •   yxaaa123 · 2015-08-11 11:05:30 +08:00 · 4648 次点击
    这是一个创建于 3191 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    18 条回复    2015-08-12 13:06:14 +08:00
    mhycy
        1
    mhycy  
       2015-08-11 11:16:30 +08:00
    1000000*1480/1024/1024=1411.437988MB/S 先看看网络有没有可能做到这个带宽再说。
    yxaaa123
        2
    yxaaa123  
    OP
       2015-08-11 11:24:38 +08:00
    @mhycy 先不考虑带宽,只考虑如何建立,呵呵
    tabris17
        3
    tabris17  
       2015-08-11 11:29:15 +08:00   ❤️ 1
    yxaaa123
        4
    yxaaa123  
    OP
       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
        5
    9hills  
       2015-08-11 11:42:42 +08:00
    @yxaaa123 用虚拟网卡

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

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

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

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

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

    不过感觉还是修改client来的方便。。
    zhicheng
        13
    zhicheng  
       2015-08-11 13:54:05 +08:00
    会玩儿,我都是本机设置成吨的 127/8 loopback 测。。。
    pmsg863
        14
    pmsg863  
       2015-08-11 16:12:15 +08:00
    @tabris17 博客很多干货,感谢。
    alexapollo
        15
    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
        16
    xiyangyang  
       2015-08-11 18:40:35 +08:00
    用多个服务器是肯定的了,关键代码和数据库怎么弄?
    数据库必须是分布式的吗?还是可以像amazon的RDS?阿里云有类似的服务吗?
    usernametoolong
        17
    usernametoolong  
       2015-08-12 12:31:18 +08:00
    单点测试都不易实现,就别说模拟百万级的用户了。
    chinawrj
        18
    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 添加具体路由策略。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1023 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:16 · PVG 03:16 · LAX 12:16 · JFK 15:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.