关于使用 SendBuffMsg 后,QPS 明显下降,并且存在『僵死』连接的问题
Problem 1: The current problem is that when there is a connection, each connection has at least two threads. One is connection.StartReader() used to read data, and the other is opened by the server.go ListenTcpConn function to call StartConn(), which in turn calls connection.go's Start(), and in connection's Start, the connection's read thread is opened. At this time, this thread does not exit, but instead waits for the connection to close and then performs cleanup work. By default, connection does not open a write thread, but only when each SendBuffMsg/SendToQueue call is made. When using SendBuffMsg, the QPS drops significantly, and there are often connections that do not close and become stuck. From the number of server threads, one connection has two threads when using SendMsg, which is the two I mentioned earlier. If using SendBuffMsg, one connection has three threads. As I explained above, this is normal.
内容来源: aceld/zinx