onesuren
V2EX  ›  Docker

docker 如何支持高并发 10W+连接?

  •  
  •   onesuren · Aug 26, 2024 · 2617 views
    This topic created in 633 days ago, the information mentioned may be changed or developed.

    请教有这方面经验的朋友

    • 1.是在宿主机需要设定还是直接在 docker 容器内设定,怎么设置?
    • 2.如果是 docker 容器里面设定如何在 dockerfile 里面设定好的?
    13 replies    2024-08-27 16:23:02 +08:00
    yinmin
        1
    yinmin  
       Aug 26, 2024 via iPhone
    首先你要搞定程序在 linux 裸机上能支持高并发 10W+,然后迁移到 docker 容器,网络模式选 host 即可
    yinmin
        2
    yinmin  
       Aug 26, 2024 via iPhone
    如果有高负载的写文件操作(如日志等),也需要 volume 到宿主机上
    csys
        3
    csys  
       Aug 26, 2024
    什么细节都没有,说的好像某个地方存在着某个神奇“开关”,一打开就可以解决问题了一样
    盲猜想问的是 ulimit -u unlimited
    julyclyde
        4
    julyclyde  
       Aug 26, 2024
    这事跟 docker 有啥关系?
    julyclyde
        5
    julyclyde  
       Aug 26, 2024
    @csys ulimit 仅在 shell 里生效
    opengps
        6
    opengps  
       Aug 26, 2024
    docker 没经验,但我看了这题目想问下哪里表现出不支持了?
    standchan
        7
    standchan  
       Aug 26, 2024
    这个跟 docker 有什么关系?没搞懂
    ala2008
        8
    ala2008  
       Aug 26, 2024
    nginx 支持 10w+吗,docker 部署 nginx ?
    onesuren
        9
    onesuren  
    OP
       Aug 27, 2024
    @yinmin
    @julyclyde
    @standchan 感谢,综合看也就是需要在宿主机把这个问题解决,我研究研究


    @csys 我感觉是这样的 等我先把宿主机搞定


    @opengps 在环境下 测试并发在 2000 就会存在拒绝,应该是宿主机的事情


    @ala2008 我研究研究 主要是测试 Waf Proxy 性能
    opengps
        10
    opengps  
       Aug 27, 2024
    @onesuren 这么规整的数字,估计是程序对连接池里设置了上限,如果单纯考虑 socket 服务端,不考虑其他资源是否跟得上,这里是没有上限的,甚至我在生产环境也用到过几万连接,只是实测有些其他问题,所以后来在内部规定单机负载不予许超过 2 万
    onesuren
        11
    onesuren  
    OP
       Aug 27, 2024
    @opengps 感谢,等我找个合适的机器再测测
    julyclyde
        12
    julyclyde  
       Aug 27, 2024
    @onesuren 2000 的时候是 too many open files 故障吗?
    我也感觉 @opengps 的想法是对的
    onesuren
        13
    onesuren  
    OP
       Aug 27, 2024
    @julyclyde
    背景是:开发机( win10 ), waf 和 web 站点分别都是在 docker 里面不同实例。

    我用 go-stress-testing-win -c 2000 -n 1 -u http://localhost
    有以下两种提示:
    Get "http://localhost": read tcp [::1]:59763->[::1]:80: wsarecv: An existing connection was forcibly closed by the remote host.
    Get "http://localhost": EOF
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5052 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 05:42 · PVG 13:42 · LAX 22:42 · JFK 01:42
    ♥ Do have faith in what you're doing.