cloudwego / hertz

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

hertz默认情况下,底层tcp连接数量是怎么控制的 #1245

Open zhouguanglong1 opened 15 hours ago

zhouguanglong1 commented 15 hours ago

Describe the Question

hertz默认情况下,底层tcp连接数量是怎么控制的?

Reproducible Code

opts := []hconfig.Option{
        server.WithHostPorts(bind),
        server.WithReadTimeout(readTimeout),
        server.WithWriteTimeout(writeTimeout),
        server.WithBindConfig(bindConfig),
    }

    h := server.Default(
        opts...,
    )

Expected behavior

日常服务的QPS在几百,观察机器的socket连接time_wait数,达到十几k;在极端情况下,服务QPS达到几千之后,机器的socket连接time_wait数飙升到10w,超过机器默认的65536,导致服务假死,重启也无法解决。最后只能扩容节点分散请求才解决。

Screenshots

image

Hertz version:

github.com/cloudwego/hertz v0.9.0

Environment:

go 1.21

Additional context

Add any other context about the question here. 服务默认没有设置WithIdleTimeout,启动方式如上 想问一下需要怎么优化服务启动参数,能让连接复用,而不是大量的time_wait

github-actions[bot] commented 15 hours 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.