-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Any Idea to improve GC? #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@yushengery What version of Go are you running? |
@elithrar thanks for you reply |
I have some issue |
GC is clear your memory,your 70K uers are shot client or long client? |
@zcdj1987 |
@yushengery |
Because the net/http package returns a new bufio.ReadWriter from the hijack method, the original bufio.Reader and bufio.Writer can be returned to the buffer pool. This is an issue for the net/http package.
Yes, the upgrade method should attempt to use the slices from the bufio.ReadWriter returned from the hijack method. |
My previous comment is not correct. The bufio.Reader is returned from hijack and is therefore not pooled on connection cleanup. The http connection's bufio.Writer is not returned in Hijack and can be returned to the buffer pool. |
Change 286b5c9 reuses the reader returned from hijack. To take advantage of this feature, set Upgrader.ReadBufferSize to 0. |
Greetings,
I am deploying the websocket service for about 70K concurrent users, however, I find the GC cause too much STW, which reached up to 2 seconds
Then I pprof the program, the most malloc comes from net/http.newBufioReader net/http.newBufioWriteSize and the net/http.(*conn).hijackLocked, I found that the hijack breaks the put to the buffer pool when a connection ended, besides, the hijacked connection has to malloc a pair of new read/write buf, is there any way to improve this ?
Best Regards.
The text was updated successfully, but these errors were encountered: