Skip to content
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

Examples to save memory using write buffer pool and freeing net.http default buffers #8

Open
tebruno99 opened this issue Dec 13, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@tebruno99
Copy link

Original PR: gorilla#761 by @FMLS

Add an example that uses the write buffer pool

The loop process of the websocket connection is inner the http handler at existing examples, This usage will cause the 8k buffer(4k read buffer + 4k write buffer) allocated by net.http can't be GC(Observed by heap profiling, see picture below) . The purpose of saving memory is not achieved even if the WriteBufferPool is used.

In example bufferpool, server process websocket connection in a new goroutine, and the goroutine created by the net.http will exit, then the 8k buffer will be GC.

image

@tebruno99 tebruno99 added the enhancement New feature or request label Dec 13, 2022
@tebruno99
Copy link
Author

Original PR comment by: @wraix gorilla#761 (comment)

Maybe the ideas posted here could be reflected to get even better at large volume connection handling or at least give the options to?

A Million WebSockets and Go

@tebruno99
Copy link
Author

Original PR comment by: @FMLS

Maybe the ideas posted here could be reflected to get even better at large volume connection handling or at least give the options to?

yes, it's a good idea in this blog, but golang did not provide a suitable mechanism now
see golang/go#15735

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant