go-graphite / carbon-clickhouse

Graphite metrics receiver with ClickHouse as storage
MIT License
186 stars 47 forks source link

Renew connection for POST requests from time to time for load balancing #53

Closed Felixoid closed 4 years ago

Felixoid commented 4 years ago

Use a new connection each POST for balancing the load over CH nodes under an LB.

Closes #52

Felixoid commented 4 years ago

I'm testing it right now. Even with timeout 1ns the connection reuse is significant, but it's recreated eventually, so the load balancing is much better.

lomik commented 4 years ago

I implemented it differently. Check it, please

https://github.com/lomik/carbon-clickhouse/commit/56fceb969ddb283838d9aa4b4c55fc7e9bbef9e7

Felixoid commented 4 years ago

It's fine, but http.Client still defined for each upload. Don't you think it's more optimal to define it once?

upd: I'm not sure if disabling KeepAlive solves the problem, btw

Felixoid commented 4 years ago

Yes, 56fceb9 works. I still have little doubts regarding http.Client declaration in upload, but disabling keep-alive works perfectly