appleboy / gorush

A push notification server written in Go (Golang).
MIT License
7.84k stars 829 forks source link

Feedback endpoint doesn't close tcp connections #751

Closed alikhanz closed 9 months ago

alikhanz commented 9 months ago

Hello. We using gorush in our stack, and i see how my service instance memory usage and goroutines count grows constantly. image

After a lot of debugging i found that GoRush initialize new http.Client for every feedback request: https://github.com/appleboy/gorush/blob/master/notify/feedback.go#L56

There is a line in documentation:

The Client's Transport typically has internal state (cached TCP connections), so Clients should be reused instead of created as needed. Clients are safe for concurrent use by multiple goroutines.

Im fixed this problem with http.Server.IdleTimeout parameter in my application. But this means that each request now opens a new connection.

I think it would be better if we reused the client.