Skip to content

Commit

Permalink
Make sending server httpstartstopevents configurable
Browse files Browse the repository at this point in the history
#159

Switching off these events reduces the CPU load on gorouter and
doppler VMS significantly.

These events are of type "timer".
  • Loading branch information
stefanlay authored and ameowlia committed Mar 2, 2021
1 parent 6f67774 commit 2cacb51
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ type Config struct {
HTMLErrorTemplateFile string `yaml:"html_error_template_file,omitempty"`

PerRequestMetricsReporting bool `yaml:"per_request_metrics_reporting,omitempty"`

SendHttpStartStopServerEvent bool `yaml:"send_http_start_stop_server_event,omitempty"`
}

var defaultConfig = Config{
Expand Down Expand Up @@ -330,6 +332,8 @@ var defaultConfig = Config{
StickySessionCookieNames: StringSet{"JSESSIONID": struct{}{}},

PerRequestMetricsReporting: true,

SendHttpStartStopServerEvent: true,
}

func DefaultConfig() (*Config, error) {
Expand Down
11 changes: 11 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,17 @@ backends:
Expect(config.PerRequestMetricsReporting).To(BeFalse())
})

It("defaults SendHttpStartStopServerEvent to true", func() {
Expect(config.SendHttpStartStopServerEvent).To(Equal(true))
})

It("sets SendHttpStartStopServerEvent", func() {
var b = []byte(`send_http_start_stop_server_event: false`)
err := config.Initialize(b)
Expect(err).ToNot(HaveOccurred())
Expect(config.SendHttpStartStopServerEvent).To(BeFalse())
})

})

Describe("Process", func() {
Expand Down
4 changes: 3 additions & 1 deletion proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ func NewProxy(
n.Use(handlers.NewRequestInfo())
n.Use(handlers.NewProxyWriter(logger))
n.Use(handlers.NewVcapRequestIdHeader(logger))
n.Use(handlers.NewHTTPStartStop(dropsonde.DefaultEmitter, logger))
if cfg.SendHttpStartStopServerEvent {
n.Use(handlers.NewHTTPStartStop(dropsonde.DefaultEmitter, logger))
}
n.Use(handlers.NewAccessLog(accessLogger, headersToLog, logger))
n.Use(handlers.NewReporter(reporter, logger))
n.Use(handlers.NewHTTPRewriteHandler(cfg.HTTPRewrite, headersToAlwaysRemove))
Expand Down

0 comments on commit 2cacb51

Please sign in to comment.