Comments (13)
Please excuse the unnecessary confusion and unnecessary work.
Don't be sorry for that, feel free to open an issue when you encounter any problem when using gnet
😄, it is my duty to help gnet
users solve problems.
Also glad to hear that GC works, but still I have a doubt that Golang GC takes that long time(30 minutes) to collect garbages cuz GC is triggered by a fixed and short time(2 minutes) if the last GC finishes over 2 minutes ago, so it is still odd. But on the other hand, it also could be a GC mutator assist which might cause a long time pause to GC, maybe that is it.
Anyway, I will keep an eye on the GC in gnet
, thanks for your discovery on this.
from gnet.
That is odd, it has nothing to do with the ring-buffer size but its number based on your desc, gnet
will recycle ring-buffers after connections are closed, so it ought to save some memories in my expectation.
Could you tell it more detailedly about the I have 40k open websocket sessions, if I now reduce them to 20k
? It could be some bugs in gnet
and I want to ensure it.
from gnet.
Besides, which version of gnet are you using?
from gnet.
Hi panjf2000,
first of all: Thank you for your response. I use version v1.0.0-rc.4. I close the connections and gnet also sees that since it triggers OnClosed
.
I benchmark my service by docker container. So I have the service running on the host with gnet and then spawn several containers that connect to the service on the host. Every connection is registered via OnOpened
and every disconnect via OnClosed
. Then I stop half of the containers to get 20k connections.
from gnet.
Could you use pprof tool to find out which part that occupies the most of memory? In that way, we will have an overall view about the memory usage of your gnet server.
from gnet.
Opening 20k connections that send every second a text
Close 10k connections so we still have 10k connections
from gnet.
It seems that ring-buffers weren't GCed after connections were closed but I can't tell why that was happening because ring-buffers would be put back to sync.Pool
which would be GCed at the next GC time, I will go investigate it further to figure out the root cause.
from gnet.
Or could you add some logs to see if the releasing code have been executed?
from gnet.
Added breakpoint, gets triggered:
from gnet.
Then I have no idea why those ring-buffers from closed connections weren't GCed, that makes no sense, I would have to take some time to investigate it.
from gnet.
Hi @panjf2000,
I run the test for longer time and it looks like it's working.
Here's what I did:
- started the server
- 40k connections established
- 82 MB memory consumption
- All connections disconnected
- 82 MB memory consumption
- 5 min. later: 166 MB memory consumption with the ring buffer
- 30 minutes later:
Looks like sometimes the Golang GC takes longer.
Please excuse the unnecessary confusion and unnecessary work.
from gnet.
Have just discovered Gnet myself and am starting some work with websockets. Is the work you've done publicly available (eg github) or is closed source? Would definitely like to see what you've done (saves me from re-inventing the wheel).
Thanks
Ken
from gnet.
Hi @kpfaulkner,
sorry, it's closed source. But the gnet examples may help you: https://github.com/gnet-io/gnet-examples
Regards,
Patrick
from gnet.
Related Issues (20)
- [Question]: 异步 API 简化问题 HOT 5
- [Question]: compatibility, gnet 2.x Client request gnet 1.5.3 Server HOT 2
- [Question]: TCP设置KeepAlive不生效 HOT 2
- [Bug]: Keepalive 设置不生效 HOT 2
- [Question]: 请教一下关于v2版本TCP粘包的问题 HOT 4
- [Question]: 应该如何支持 tls HOT 4
- [Feature]: 使用Engine.Stop退出时,会通过DefaultLogger输出很多错误日志 HOT 3
- [Question]: Why are http examples incompatible with MicroPython urequests
- [Bug]: bind: address already in use when using without reuseAddr parameter HOT 2
- UDP resets Context and creates new gnet.Conn OnTraffic() HOT 1
- [Feature]: 实现异步非阻塞的PacketConn接口,从而支持quic协议 HOT 2
- [Bug]: windows下的实现似乎有bug HOT 2
- [Question]: Does gnet support a websocket server that can handle different URL patterns HOT 1
- [Question]:详细的说明文档,说明什么情况下应用程序应该主动调用close方法呢 HOT 19
- [Question]: 请问 多网卡情况下,在 udp 的 OnTraffic 事件里面,怎么得到接收数据的网络接口呢 HOT 1
- [Question]: 请教运行在serverless中http的Keep-Alive应该如何配置 HOT 2
- [Question]: 数据超过65535时多次触发OnTraffic如何处理数据? HOT 2
- [Question]: 重启gnet.server需要如何做? HOT 6
- [Question]: 请问作者是否有异步读取的最佳实践示例呢? HOT 1
- [Question]:自定义codec中是否会存在接受header失败导致后续数据都无法正确获取的情况 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gnet.