Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

Unclosed network connections #14

Closed
joshbenner opened this issue Dec 23, 2016 · 8 comments
Closed

Unclosed network connections #14

joshbenner opened this issue Dec 23, 2016 · 8 comments

Comments

@joshbenner
Copy link
Contributor

I was running latest (tag 12) today, and noticed a lot (over 10k) of open connections on my node. I restarted the rancher exporter, and all the connections went away. Connections are not being closed.

graph

@joshbenner
Copy link
Contributor Author

I'm watching netstat inside the prometheus-rancher-exporter, and every time the 3 JSON requests are made, the number of ESTABLISHED connections increment by 3.

@joshbenner
Copy link
Contributor Author

Took a look at the code, and I think I've tracked the issue to https://github.com/infinityworksltd/prometheus-rancher-exporter/blob/master/utils/utils.go#L24

The HTTP Client caches connections for reuse, and we're creating a new client each time we call any of the GetJson functions. Ideally, a single client should be created for the application (single client is safe to use across multiple goroutines). Alternately, one client per exporter. Finally... we could create/destroy each invocation.

See: https://golang.org/pkg/net/http/#Client

@Rucknar
Copy link
Contributor

Rucknar commented Dec 23, 2016

Thanks @joshbenner, again well spotted and good write up.

Just having a look at the options now and doing some testing, though i appreciate creating a long-running client would have the least overhead, i'm worried how that would perform over extended periods of time. I'll see what works well locally.

@Rucknar
Copy link
Contributor

Rucknar commented Dec 23, 2016

Oddly, despite hitting it with apache bench... i'm not seeing the same issues. If i open up 1k connections, they are all recovered within a minute. I'm wondering if testing locally is distorting the issue. I've just pushed up an update, and a new image version (13). Any chance you could test with version 13?

@joshbenner
Copy link
Contributor Author

joshbenner commented Dec 23, 2016

I confirm this addresses the issue in both environments where I was seeing the open connection behavior.

@metalmatze
Copy link

That might explain the exporter crashing every few days for me. Didn't dig deeper, but it sounds reasonable. 👍

@Rucknar
Copy link
Contributor

Rucknar commented Dec 24, 2016

Had the same thought @metalmatze. I've done some testing and tag 13 seems to behave okay on my test setup too. Pull request raised for those of you using this as part of the catalog entry: rancher/community-catalog#382

@Rucknar
Copy link
Contributor

Rucknar commented Dec 24, 2016

Closing this one, feel free to re-open if you think it might still be an issue.

@Rucknar Rucknar closed this as completed Dec 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants