klzgrad/naiveproxy

是否支持单端口复用?

sophauer opened this issue · 11 comments

我想把旁路由的CPU效能发挥起来,每个Core执行一个naiveproxy线程,全listen在同一个1080端口
但貌似naiveproxy的usage文档里找不到关于port reuse的描述

请问是否不支持单端口复用?
如果是,有没有其他路线可以实现?

5l2 commented

每个Core执行一个naiveproxy线程,全listen在同一个1080端口

Why for that?

每个Core执行一个naiveproxy线程,全listen在同一个1080端口

Why for that?

旁路由支撑一百多台电脑翻墙,单一个naiveproxy只用一个CPU Core,负载太高.,
所以用4个线程.,listten在同一个端口.可以发挥软路由最大性能

5l2 commented

No possible. Different processes cannot use the same TCP port.

No possible. Different processes cannot use the same TCP port.

ss-libev,xray.v2ray,都有这个功能

5l2 commented

Because naiveproxy does not support the SO_REUSEPORT option.
Oh, it looks like the option has been added to support in the latest commit.

Because naiveproxy does not support the SO_REUSEPORT option. Oh, it looks like the option has been added to support in the latest commit.

yes,我也是刚看到,但是似乎还没更新下载.只能自己compile

Run 8 workers for port 1080:

for i in $(seq 8); do
  ./naive --listen=socks://0.0.0.0:1080 &
done

It might be better if you pin the process to a specific core such as:

for i in $(seq 8); do
  taskset -c $i ./naive --listen=socks://0.0.0.0:1080 &
done

Ref: https://stackoverflow.com/questions/33994983/assigning-a-cpu-core-to-a-process-linux

I'm wondering if it would be better (or possible) to harness multiple CPU core by multi-threading within naiveproxy?

Edit: I found https://github.com/valyala/fasthttp/issues/23. Looks like this fork & port reusing approach should be a good practice.