VolantMQ / volantmq

High-Performance MQTT Server
Apache License 2.0
981 stars 169 forks source link

Ever-increasing worker goroutines #182

Open 4nte opened 2 years ago

4nte commented 2 years ago

My volantmq broker eventually stops working due to too many workers. I have unstable clients that frequently reconnect due to flaky network connections.

What is the best way to mitigate this?

goroutine profile: total 404
365 @ 0x63f430 0x614108 0x6140de 0x613e0b 0xa2c7cf 0x66a611
#   0xa2c7ce    github.com/VolantMQ/volantmq/types.(*pool).worker+0x9e  /go/src/github.com/VolantMQ/volantmq/types/pool.go:103

23 @ 0x63f430 0x63952a 0x638af5 0x6d29d5 0x6d394f 0x6d3931 0x7a3acf 0x7b7138 0xa40bd5 0x764403 0x76456f 0xa4c84a 0xa4c13e 0x66a611
#   0x638af4    internal/poll.runtime_pollWait+0x54                 /usr/local/go/src/runtime/netpoll.go:184
#   0x6d29d4    internal/poll.(*pollDesc).wait+0x44                 /usr/local/go/src/internal/poll/fd_poll_runtime.go:87
#   0x6d394e    internal/poll.(*pollDesc).waitRead+0x1ce                /usr/local/go/src/internal/poll/fd_poll_runtime.go:92
#   0x6d3930    internal/poll.(*FD).Read+0x1b0                      /usr/local/go/src/internal/poll/fd_unix.go:169
#   0x7a3ace    net.(*netFD).Read+0x4e                          /usr/local/go/src/net/fd_unix.go:202
#   0x7b7137    net.(*conn).Read+0x67                           /usr/local/go/src/net/net.go:184
#   0xa40bd4    github.com/VolantMQ/volantmq/transport.(*conn).Read+0x54        /go/src/github.com/VolantMQ/volantmq/transport/conn.go:41
#   0x764402    bufio.(*Reader).fill+0x102                      /usr/local/go/src/bufio/bufio.go:100
#   0x76456e    bufio.(*Reader).Peek+0x4e                       /usr/local/go/src/bufio/bufio.go:138
#   0xa4c849    github.com/VolantMQ/volantmq/connection.(*reader).readPacket+0x79   /go/src/github.com/VolantMQ/volantmq/connection/reader.go:129
#   0xa4c13d    github.com/VolantMQ/volantmq/connection.(*reader).routine+0x11d     /go/src/github.com/VolantMQ/volantmq/connection/reader.go:80
troian commented 2 years ago

thanks, i'll give it a think

4nte commented 2 years ago

@troian have you figured anything out? Any general pointers would be appreciated (if you have any, of course). I'll try to open a PR in the following days.