diff --git a/README.md b/README.md index 5782d279..6bb3320e 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ This is recommended for dev environments only. * `SELECTED_MONITORING_METRICS`: Name of the metrics that you want to monitor and add using comma seprated values. List of the metrics that are supported in the metrics modules are given below * `REFRESH_SPLUNK_CONNECTION`: If set to true, PCF will periodically refresh connection to Splunk (how often depends on KEEP_ALIVE_TIMER value). If set to false connection will be kept alive and reused. (Default: false) * `KEEP_ALIVE_TIMER`: Time after which connection to Splunk will be refreshed, if REFRESH_SPLUNK_CONNECTION is set to true (in s/m/h. For example, 3600s or 60m or 1h). (Default: 30s) +* `MEMORY_BALLAST_SIZE`: Size of memory allocated to reduce GC cycles. Default is 0, Size should be less than the total memory. __About app cache params:__ diff --git a/main.go b/main.go index b14ea70a..5998208b 100644 --- a/main.go +++ b/main.go @@ -27,6 +27,11 @@ func main() { signal.Notify(shutdownChan, syscall.SIGINT, syscall.SIGTERM) config := splunknozzle.NewConfigFromCmdFlags(version, branch, commit, buildos) + if config.MemoryBallastSize > 0 { + ballast := make([]byte, config.MemoryBallastSize<<20) + _ = ballast + } + if config.AppCacheTTL == 0 && config.OrgSpaceCacheTTL > 0 { logger.Info("Apps are not being cached. When apps are not cached, the org and space caching TTL is ineffective") } diff --git a/splunknozzle/config.go b/splunknozzle/config.go index d0ec491f..32e823d3 100644 --- a/splunknozzle/config.go +++ b/splunknozzle/config.go @@ -60,6 +60,7 @@ type Config struct { StatusMonitorInterval time.Duration `json:"mem-queue-monitor-interval"` SelectedMonitoringMetrics string `json:"selected-monitoring-metrics"` SplunkMetricIndex string `json:"splunk-metric-index"` + MemoryBallastSize int `json:"memory-ballast-size"` } func NewConfigFromCmdFlags(version, branch, commit, buildos string) *Config { @@ -150,6 +151,8 @@ func NewConfigFromCmdFlags(version, branch, commit, buildos string) *Config { OverrideDefaultFromEnvar("SELECTED_MONITORING_METRICS").Default("nozzle.queue.percentage,splunk.events.dropped.count,splunk.events.sent.count,firehose.events.dropped.count,firehose.events.received.count,splunk.events.throughput,nozzle.usage.ram,nozzle.usage.cpu,nozzle.cache.memory.hit,nozzle.cache.memory.miss,nozzle.cache.remote.hit,nozzle.cache.remote.miss,nozzle.cache.boltdb.hit,nozzle.cache.boltdb.miss").StringVar(&c.SelectedMonitoringMetrics) kingpin.Flag("splunk-metric-index", "Splunk metric index"). OverrideDefaultFromEnvar("SPLUNK_METRIC_INDEX").StringVar(&c.SplunkMetricIndex) + kingpin.Flag("memory-ballast-size", "Size of ballast in MB"). + OverrideDefaultFromEnvar("MEMORY_BALLAST_SIZE").Default("0").IntVar(&c.MemoryBallastSize) kingpin.Parse() c.ApiEndpoint = strings.TrimSpace(c.ApiEndpoint) diff --git a/splunknozzle/config_test.go b/splunknozzle/config_test.go index 13ae0efc..bc37869f 100644 --- a/splunknozzle/config_test.go +++ b/splunknozzle/config_test.go @@ -65,6 +65,7 @@ var _ = Describe("Config", func() { os.Setenv("ENABLE_EVENT_TRACING", "true") os.Setenv("DEBUG", "true") os.Setenv("DROP_WARN_THRESHOLD", "100") + os.Setenv("MEMORY_BALLAST_SIZE", "512") c := NewConfigFromCmdFlags(version, branch, commit, buildos) @@ -110,6 +111,7 @@ var _ = Describe("Config", func() { Expect(c.TraceLogging).To(BeTrue()) Expect(c.Debug).To(BeTrue()) + Expect(c.MemoryBallastSize).To(Equal(512)) }) It("check defaults", func() { @@ -141,6 +143,7 @@ var _ = Describe("Config", func() { Expect(c.TraceLogging).To(BeFalse()) Expect(c.Debug).To(BeFalse()) + Expect(c.MemoryBallastSize).To(Equal(0)) }) }) @@ -187,6 +190,7 @@ var _ = Describe("Config", func() { "--enable-event-tracing", "--debug", "--splunk-metric-index=metric", + "--memory-ballast-size=512", } os.Args = args }) @@ -230,6 +234,8 @@ var _ = Describe("Config", func() { Expect(c.Debug).To(BeTrue()) Expect(c.TraceLogging).To(BeTrue()) + Expect(c.MemoryBallastSize).To(Equal(512)) + Expect(c.Version).To(Equal(version)) Expect(c.Branch).To(Equal(branch)) Expect(c.Commit).To(Equal(commit)) diff --git a/tile/tile.yml b/tile/tile.yml index a6bd763e..b71144e2 100644 --- a/tile/tile.yml +++ b/tile/tile.yml @@ -272,6 +272,11 @@ forms: label: Keep alive timer description: Interval used to close and refresh connection to Splunk optional: true + - name: memory_ballast_size + type: integer + label: Memory Ballast Size + default: 0 + description: Size of memory allocated to reduce GC cycles. Default is 0, Size should be less than the total memory. migration: | if (typeof properties['properties']['.properties.add_app_info']['value'] == "boolean") {