From bd2707340d1248e2284aa08fc4879f7236e4ef0a Mon Sep 17 00:00:00 2001 From: Jason Harvey Date: Sat, 11 Mar 2017 18:20:46 -0900 Subject: [PATCH] cmd/tsdbrelay: Drain relay response so that connection is eligible for reuse. --- cmd/tsdbrelay/main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/tsdbrelay/main.go b/cmd/tsdbrelay/main.go index e0628c8396..3a612dfaee 100644 --- a/cmd/tsdbrelay/main.go +++ b/cmd/tsdbrelay/main.go @@ -8,6 +8,7 @@ import ( "flag" "fmt" "io" + "io/ioutil" "net/http" "net/http/httptest" "net/http/httputil" @@ -249,6 +250,8 @@ func (rp *relayProxy) relayPut(responseWriter http.ResponseWriter, r *http.Reque verbose("bosun relay error: %v", err) return } + // Drain up to 512 bytes and close the body to let the Transport reuse the connection + io.CopyN(ioutil.Discard, resp.Body, 512) resp.Body.Close() verbose("bosun relay success") }() @@ -283,6 +286,8 @@ func (rp *relayProxy) relayPut(responseWriter http.ResponseWriter, r *http.Reque collect.Add("additional.puts.error", tags, 1) continue } + // Drain up to 512 bytes and close the body to let the Transport reuse the connection + io.CopyN(ioutil.Discard, resp.Body, 512) resp.Body.Close() verbose("secondary relay success") collect.Add("additional.puts.relayed", tags, 1) @@ -383,6 +388,8 @@ func (rp *relayProxy) relayMetadata(responseWriter http.ResponseWriter, r *http. verbose("secondary relay metadata error: %v", err) continue } + // Drain up to 512 bytes and close the body to let the Transport reuse the connection + io.CopyN(ioutil.Discard, resp.Body, 512) resp.Body.Close() verbose("secondary relay metadata success") }