XnLemon commented on issue #820: URL: https://github.com/apache/dubbo-go-pixiu/issues/820#issuecomment-5101837551
@Alanxtl 雪涛老师 看了一下这个背景 然后我也看了目前的更改情况比如 Tsukikage 的这个pr #856 是更改了评测 然后目前这个issue的问题没暴露出来 或者说确实不明显 变到这样的一个情况 <!DOCTYPE html><head></head><markdown-accessiblity-table data-catalyst="" style="box-sizing: border-box; display: block;"> Protocol | Direct (Median) | via Pixiu (Median) | Overhead -- | -- | -- | -- gRPC | ~200µs | ~1.3ms | ~1.1ms Triple | ~1.4ms | ~2ms | ~0.6ms Dubbo | ~200µs | ~700µs | ~0.5ms </markdown-accessiblity-table><div class="markdown-heading" dir="auto" style="box-sizing: border-box; position: relative;"></h1><br class="Apple-interchange-newline"> 先提一下第一点是 en 和 zh 的 readme 没同步 然后第二点是经过我个人的测试发现 使用 Pixiu 的 HTTP gRPC/Triple 代理时,每个请求可能都会新建一个后端 `grpc.ClientConn`,而不是复用已有连接。 当请求数量为 N=500 时,后端观察到约 500 条 `ESTABLISHED` TCP 连接 流程大概是 - 每个请求都会创建一个临时 pool。 - 每个请求都会执行 `grpc.DialContext`。 - `p.Put(clientConn)` 只会把连接放回临时 pool。 - 该连接后续不会被复用,也没有被关闭。 CPU profile 中的主要热点如下 <img width="2940" height="1774" alt="Image" src="https://github.com/user-attachments/assets/cbe22289-ad6d-4499-9da0-34ad1f2482fd" /> - `grpc.(*addrConn).connect` - `grpc.(*addrConn).createTransport` - `grpc/internal/transport.newHTTP2Client` - `net.(*sysDialer).dialSingle` 方案如下 连接管理改为: - 在 FilterFactory 层维护共享连接池。 - 每个 cluster + endpoint 保存一个 grpc.ClientConn。 - 使用 sync.Map 支持并发访问。 - 使用 singleflight 防止同一 endpoint 被并发重复建连。 - 连接进入异常状态后移除并重新建立。 - 多个请求现在可以通过同一个 HTTP/2 连接的不同 stream 并发执行。 看一下优化方向可以吗 然后我目前其实有一个实现 对比一下效果是这样的 <!DOCTYPE html><head></head><markdown-accessiblity-table data-catalyst="" style="box-sizing: border-box; display: block;"> 协议 | Baseline 经 Pixiu | 优化后经 Pixiu -- | -- | -- gRPC | 约 1.0–1.4ms | 约 0.6ms Triple | 约 1.2–1.6ms | 约 0.4–0.5ms </markdown-accessiblity-table><div class="markdown-heading" dir="auto" style="box-sizing: border-box; position: relative;"></h1><br class="Apple-interchange-newline"> 以grpc的评测为例 ### Baseline <img width="2200" height="1372" alt="Image" src="https://github.com/user-attachments/assets/9d951e97-17e9-409a-b61b-eed92e9dd1c3" /> --- ### Now <img width="2940" height="1774" alt="Image" src="https://github.com/user-attachments/assets/beed8e00-7f27-40a3-8334-bd0ddaadd43d" /> <img width="2202" height="1722" alt="Image" src="https://github.com/user-attachments/assets/9cd84f43-bfe9-4e15-8016-f69afb1054f3" /> 上文内的建连热点在分析内消失了 这个优化方向可以的话我就去提个pr -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
