v2fly / discussion

5 stars 0 forks source link

V2Ray对Unix domain socket的处理是不是有些问题 #69

Closed ghost closed 3 years ago

ghost commented 3 years ago

根据https://github.com/badO1a5A90/v2ray-doc/blob/master/performance_test/DS/20201030.md 做的测试,发现domain socket对性能影响巨大。我自己也做了很多类似的测试,发现确实如此。 后来我又对此做了进一步的实验,发现只要是v2ray对domain socket进行接收(listen)或者fallbacks处理,性能都很差。而排除v2ray的处理之后domain socket性能并不比tcp弱。 以下是我做的实验:

nginx配置

server {
    listen 81;
    listen unix:/dev/shm/test.sock;
    root /dev/shm/nginx;
}
server {
    listen 82;
    location / {
        proxy_pass http://127.0.0.1:81;
    }
}
server {
    listen 83;
    location / {
        proxy_pass http://unix:/dev/shm/test.sock;
    }
}

v2ray配置:

{
    "log": {
        "loglevel": "none"
    },
    "inbounds": [
        {
            "port": 84,
            "protocol": "vless",
            "settings": {
                "decryption": "none",
                "fallbacks": [
                    {
                        "dest": 81,
                        "xver": 0
                    }
                ]
            },
            "streamSettings": {
                "network": "tcp"
            }
        },
        {
            "port": 85,
            "protocol": "vless",
            "settings": {
                "decryption": "none",
                "fallbacks": [
                    {
                        "dest": "/dev/shm/test.sock",
                        "xver": 0
                    }
                ]
            }
        }
    ]
}

/dev/shm/nginx下放置着一个大小为300m的名为file的文件(因为内存不够了,我的机器内存只有1gb),/dev/shm还剩下约200m的空间

分别执行

wget 127.0.0.1:81/file -O /dev/null
wget 127.0.0.1:82/file -O /dev/null
wget 127.0.0.1:83/file -O /dev/null
wget 127.0.0.1:84/file -O /dev/null
wget 127.0.0.1:85/file -O /dev/null

每条命令都重复执行多次,用wget自带的速度显示进行测速,类似下面这样:

# wget 127.0.0.1:81/file -O /dev/null
--2020-10-31 20:05:39--  http://127.0.0.1:81/file
Connecting to 127.0.0.1:81... connected.
HTTP request sent, awaiting response... 200 OK
Length: 314572800 (300M) [application/octet-stream]
Saving to: ‘/dev/null’

/dev/null                            100%[===================================================================>] 300.00M  1.05GB/s    in 0.3s    

2020-10-31 20:05:39 (1.05 GB/s) - ‘/dev/null’ saved [314572800/314572800]

发现 第一条命令平均速度为 1.02GB/s 第二条 510MB/s 速度刚好为第一条的一半 第三条和第二条速度几乎相同 第四条 480MB/s 第五条 110MB/s,连tcp回落的四分之一速度都不到

其他信息: 1.我的机器用iperf测到的回路极限速度为20Gbps 2.系统为 Ubuntu 21.04 3.内核为 5.10.0-051000rc1-generic 4.nginx版本为1.19.4 5.v2ray版本为4.31.3

@rprx @badO1a5A90

RPRX commented 3 years ago

请在这里讨论

https://github.com/v2fly/v2ray-core/issues/373

ghost commented 3 years ago

请在这里讨论

v2fly/v2ray-core#373

好的,那我转移过去