cloudwego / hertz

Go HTTP framework with high-performance and strong-extensibility for building micro-services.
https://www.cloudwego.io
Apache License 2.0
5.04k stars 491 forks source link

now 1 connection uses 1 goroutine. how to ensure can support unlimited connections? #1125

Closed sprappcom closed 2 months ago

sprappcom commented 2 months ago
Server Connection limitation:

If you are using the standard network library, there is no such restriction.
If netpoll is used, the maximum number of connections is 10000 (this is the [gopool](https://github.com/bytedance/gopkg/blob/b9c1c36b51a6837cef4c2223e11522e3a647460c/util/gopool/gopool.go#L46)) used at the bottom of netpoll. Yes, the modification method is also very simple, just call the function provided by gopool: gopool.SetCap(xxx) (you can call it once in main.go).

is this the correct way to use standard library? it's not working,

        h := server.New(
                server.WithHostPorts(":8888"),
                server.WithALPN(true),
                server.WithTLS(cfg),
              server.WithTransport(
                      standard.NewTransporter,
              ),
        )

a) still uses 1 goroutine per connection 1:1 b) doing gopool.SetCap(...) doesnt work. how to setcap? already put under func main()

  1. how can i support unlimited connections? do i have to do ulimit -n 10240000000 etc using linux?

  2. how NOT to have 1 go routine per connection? would prefer all connections use as few goroutine as possible. maybe just 1 goroutine

  3. goroutine pool (gopool) will support how many connections with 10000 goroutines spawned?

github-actions[bot] commented 2 months ago

This issue has been marked as invalid question, please give more information by following the issue template. The issue will be closed in 1 days if no further activity occurs.

sprappcom commented 2 months ago

@li-jin-gou can help answer pls?

li-jin-gou commented 2 months ago

The latest netpoll does not have the 1w limit.

github-actions[bot] commented 2 months ago

This issue has been marked as invalid question, please give more information by following the issue template. The issue will be closed in 1 days if no further activity occurs.

sprappcom commented 2 months ago

@li-jin-gou it is still using 1 goroutine : 1 connection. how not to have 1 goroutine per connection? what if i have >1mil connection for websocket?

github-actions[bot] commented 2 months ago

This issue has been marked as invalid question, please give more information by following the issue template. The issue will be closed in 1 days if no further activity occurs.