From 7cdfc48a7bc8a136ec908cc2ff68c41862e4c234 Mon Sep 17 00:00:00 2001 From: Stefan Lay Date: Fri, 29 Jan 2021 09:01:51 +0100 Subject: [PATCH] Make sending client httpstartstopevents configurable https://github.com/cloudfoundry/gorouter/issues/159 Switching off these events reduces the CPU load on gorouter and doppler VMS significantly. These events are of type "timer". Note that they should not be switched off when the app-autoscaler is used. --- config/config.go | 4 ++++ config/config_test.go | 11 +++++++++++ proxy/proxy.go | 1 + proxy/round_tripper/dropsonde_round_tripper.go | 8 +++++++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 5f8568d80..5817472c4 100644 --- a/config/config.go +++ b/config/config.go @@ -277,6 +277,8 @@ type Config struct { PerRequestMetricsReporting bool `yaml:"per_request_metrics_reporting,omitempty"` SendHttpStartStopServerEvent bool `yaml:"send_http_start_stop_server_event,omitempty"` + + SendHttpStartStopClientEvent bool `yaml:"send_http_start_stop_client_event,omitempty"` } var defaultConfig = Config{ @@ -334,6 +336,8 @@ var defaultConfig = Config{ PerRequestMetricsReporting: true, SendHttpStartStopServerEvent: true, + + SendHttpStartStopClientEvent: true, } func DefaultConfig() (*Config, error) { diff --git a/config/config_test.go b/config/config_test.go index e8245845c..6d2f0d5d2 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -639,6 +639,17 @@ backends: Expect(config.SendHttpStartStopServerEvent).To(BeFalse()) }) + It("defaults SendHttpStartStopClientEvent to true", func() { + Expect(config.SendHttpStartStopClientEvent).To(Equal(true)) + }) + + It("sets SendHttpStartStopClientEvent", func() { + var b = []byte(`send_http_start_stop_client_event: false`) + err := config.Initialize(b) + Expect(err).ToNot(HaveOccurred()) + Expect(config.SendHttpStartStopClientEvent).To(BeFalse()) + }) + }) Describe("Process", func() { diff --git a/proxy/proxy.go b/proxy/proxy.go index a2914304e..05dd1dfee 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -125,6 +125,7 @@ func NewProxy( DisableCompression: true, TLSClientConfig: routeServiceTLSConfig, }, + IsInstrumented: cfg.SendHttpStartStopClientEvent, } prt := round_tripper.NewProxyRoundTripper( diff --git a/proxy/round_tripper/dropsonde_round_tripper.go b/proxy/round_tripper/dropsonde_round_tripper.go index 89ac69a12..0b2f2202a 100644 --- a/proxy/round_tripper/dropsonde_round_tripper.go +++ b/proxy/round_tripper/dropsonde_round_tripper.go @@ -30,6 +30,7 @@ func (d *dropsondeRoundTripper) CancelRequest(r *http.Request) { type FactoryImpl struct { BackendTemplate *http.Transport RouteServiceTemplate *http.Transport + IsInstrumented bool } func (t *FactoryImpl) New(expectedServerName string, isRouteService bool) ProxyRoundTripper { @@ -52,5 +53,10 @@ func (t *FactoryImpl) New(expectedServerName string, isRouteService bool) ProxyR TLSClientConfig: customTLSConfig, TLSHandshakeTimeout: template.TLSHandshakeTimeout, } - return NewDropsondeRoundTripper(newTransport) + if t.IsInstrumented { + return NewDropsondeRoundTripper(newTransport) + } else { + return newTransport + } + }