volantmq
volantmq copied to clipboard
Optimize goroutine and memory usage
Currently active connection requires 4 running goroutines with 4K of stack per each plus incoming ring buffer of 8K. If scale to 1M active connections we get into 12G of memory. If client does send nothing and no publishes for subscribed topics it just waste of memory. Reasonable to optimize by packing into less goroutines and spin them only when events available.
-
Receiving packets. If there is no data on socket it blocked on epoll until there is some data. On github.com/golang/go, there is the issue. Wait until it's completed
-
Sending goroutine spin only when there is messages to transmit otherwise it should be down
greate idea
There are existed experience with using epoll explicitely for websocket server: https://medium.freecodecamp.org/million-websockets-and-go-cc58418460bb
Was using it for a bit in the project. Still does not comply with all the requirements for example DeadLines does not work properly. Btw, did you get them working?