From c9ac2e2bf2fc18b926fab2133836c9526fca697e Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Sun, 7 Apr 2024 16:17:38 +0000 Subject: [PATCH 1/5] add benchmarks for the prometheus bridge --- bridges/prometheus/BENCHMARKS.md | 24 ++++++++++++++++++++++++ bridges/prometheus/doc.go | 5 +++++ 2 files changed, 29 insertions(+) create mode 100644 bridges/prometheus/BENCHMARKS.md diff --git a/bridges/prometheus/BENCHMARKS.md b/bridges/prometheus/BENCHMARKS.md new file mode 100644 index 00000000000..5b3463f7364 --- /dev/null +++ b/bridges/prometheus/BENCHMARKS.md @@ -0,0 +1,24 @@ +## Summary + +Using the Promethues bridge and the OTLP exporter adds roughly ~50% to the CPU and memory overhead of an application compared to serving a Prometheus HTTP endpoint for metrics. + +However, unless the application has extremely high cardinality for metrics, this is unlikely to represent a significant amount of additional overhead because the base-line memory consumption of client libraries is relatively low. For an application with 30k timeseries (which is a very high number), the additional overhead is about 50MB and about 0.1 CPU cores. + +The using the bridge is particularly useful if you are exporting to an OpenTelemetry Collector, since the OTLP receiver is much more efficient than the Prometheus receiver. For the same 30k timeseries, the Prometheus receiver uses 3x the amount of memory, and 20x the amount of CPU. In concrete numbers, this is an additional 228 MB of memory, and 0.57 CPU cores. + +For an application using the Promethues client library, and exporting to an OpenTelemetry collector, the total CPU usage is 55% lower and total memory usage is 45% lower when using the bridge and the OTLP receiver compared to using a Prometheus endpoint and the collector's Promethehus receiver. + +## Methods and Results + +The sample application uses the Prometheus client library, and defines one histogram with the default 12 buckets, one counter, and one gauge. Each metric has a single label with 10k values, which are observed every second. + +The memory usage of the sample application is measured using the `/memory/classes/total:bytes` metric from the go runtime. The CPU usage of the application is measured using `top`. The CPU and memory usage of the collector are measured using `docker stats`. + +The OpenTelemetry Collector is configured with only the OTLP or Prometheus receiver, and the debug (logging) exporter with only the basic output. + +| Experiment | Memory Usage (MB) | CPU Usage (millicores) | +|---|---|---| +| App w/ Prometheus Export | 94 | 220 | +| App w/ Bridge + OTLP Export | 140 | 330 | +| Collector w/ Prometheus Receiver | 320 | 600 | +| Collector w/ OTLP Receiver | 92 | 30 | diff --git a/bridges/prometheus/doc.go b/bridges/prometheus/doc.go index 8f3fb6c8b2b..44145a1032b 100644 --- a/bridges/prometheus/doc.go +++ b/bridges/prometheus/doc.go @@ -12,6 +12,11 @@ // Prometheus native histograms, set the (currently experimental) NativeHistogram... // options of the prometheus [HistogramOpts] when creating prometheus histograms. // +// While the Prometheus Bridge has some overhead, it can significantly reduce the +// combined overall CPU and Memory footprint when sending to an OpenTelemetry +// Collector. See the [benchmarks] for more details. +// // [Prometheus Golang client library]: https://github.com/prometheus/client_golang // [HistogramOpts]: https://pkg.go.dev/github.com/prometheus/client_golang/prometheus#HistogramOpts +// [benchmarks]: https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/bridges/prometheus/BENCHMARKS.md package prometheus // import "go.opentelemetry.io/contrib/bridges/prometheus" From 392bb648c5137bdcaf7a82a282a1e53e032f3567 Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Mon, 8 Apr 2024 14:20:32 +0000 Subject: [PATCH 2/5] make precommit and address comment --- bridges/prometheus/BENCHMARKS.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bridges/prometheus/BENCHMARKS.md b/bridges/prometheus/BENCHMARKS.md index 5b3463f7364..5f791360fbc 100644 --- a/bridges/prometheus/BENCHMARKS.md +++ b/bridges/prometheus/BENCHMARKS.md @@ -1,12 +1,12 @@ ## Summary -Using the Promethues bridge and the OTLP exporter adds roughly ~50% to the CPU and memory overhead of an application compared to serving a Prometheus HTTP endpoint for metrics. +Using the Prometheus bridge and the OTLP exporter adds roughly ~50% to the CPU and memory overhead of an application compared to serving a Prometheus HTTP endpoint for metrics. However, unless the application has extremely high cardinality for metrics, this is unlikely to represent a significant amount of additional overhead because the base-line memory consumption of client libraries is relatively low. For an application with 30k timeseries (which is a very high number), the additional overhead is about 50MB and about 0.1 CPU cores. -The using the bridge is particularly useful if you are exporting to an OpenTelemetry Collector, since the OTLP receiver is much more efficient than the Prometheus receiver. For the same 30k timeseries, the Prometheus receiver uses 3x the amount of memory, and 20x the amount of CPU. In concrete numbers, this is an additional 228 MB of memory, and 0.57 CPU cores. +The bridge is particularly useful if you are exporting to an OpenTelemetry Collector, since the OTLP receiver is much more efficient than the Prometheus receiver. For the same 30k timeseries, the Prometheus receiver uses 3x the amount of memory, and 20x the amount of CPU. In concrete numbers, this is an additional 228 MB of memory, and 0.57 CPU cores. -For an application using the Promethues client library, and exporting to an OpenTelemetry collector, the total CPU usage is 55% lower and total memory usage is 45% lower when using the bridge and the OTLP receiver compared to using a Prometheus endpoint and the collector's Promethehus receiver. +For an application using the Prometheus client library, and exporting to an OpenTelemetry collector, the total CPU usage is 55% lower and total memory usage is 45% lower when using the bridge and the OTLP receiver compared to using a Prometheus endpoint and the collector's Promethehus receiver. ## Methods and Results From b0f0fd5c5681fb51be82350dc84bdfe58e2b5597 Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Mon, 8 Apr 2024 14:23:55 +0000 Subject: [PATCH 3/5] add versions of dependencies used so benchmarks can be reproduced --- bridges/prometheus/BENCHMARKS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridges/prometheus/BENCHMARKS.md b/bridges/prometheus/BENCHMARKS.md index 5f791360fbc..cff076f0b60 100644 --- a/bridges/prometheus/BENCHMARKS.md +++ b/bridges/prometheus/BENCHMARKS.md @@ -12,9 +12,9 @@ For an application using the Prometheus client library, and exporting to an Open The sample application uses the Prometheus client library, and defines one histogram with the default 12 buckets, one counter, and one gauge. Each metric has a single label with 10k values, which are observed every second. -The memory usage of the sample application is measured using the `/memory/classes/total:bytes` metric from the go runtime. The CPU usage of the application is measured using `top`. The CPU and memory usage of the collector are measured using `docker stats`. +The memory usage of the sample application is measured using the `/memory/classes/total:bytes` metric from the go runtime. The CPU usage of the application is measured using `top`. The CPU and memory usage of the collector are measured using `docker stats`. It was built using v0.50.0 of the bridge, v1.25.0 of the OpenTelemetry API and SDK, and v1.19.0 of the Prometheus client. -The OpenTelemetry Collector is configured with only the OTLP or Prometheus receiver, and the debug (logging) exporter with only the basic output. +The OpenTelemetry Collector is configured with only the OTLP or Prometheus receiver, and the debug (logging) exporter with only the basic output. The benchmark uses the Contrib distribution at v0.97.0. | Experiment | Memory Usage (MB) | CPU Usage (millicores) | |---|---|---| From 85c02c10989408b5a8d3dd00b924bf06702b9239 Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Mon, 8 Apr 2024 15:12:00 +0000 Subject: [PATCH 4/5] add link to source --- bridges/prometheus/BENCHMARKS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/prometheus/BENCHMARKS.md b/bridges/prometheus/BENCHMARKS.md index cff076f0b60..a491ec2e3a9 100644 --- a/bridges/prometheus/BENCHMARKS.md +++ b/bridges/prometheus/BENCHMARKS.md @@ -10,7 +10,7 @@ For an application using the Prometheus client library, and exporting to an Open ## Methods and Results -The sample application uses the Prometheus client library, and defines one histogram with the default 12 buckets, one counter, and one gauge. Each metric has a single label with 10k values, which are observed every second. +The sample application uses the Prometheus client library, and defines one histogram with the default 12 buckets, one counter, and one gauge. Each metric has a single label with 10k values, which are observed every second. See the [sample application's source](https://github.com/dashpole/client_golang/pull/1). The memory usage of the sample application is measured using the `/memory/classes/total:bytes` metric from the go runtime. The CPU usage of the application is measured using `top`. The CPU and memory usage of the collector are measured using `docker stats`. It was built using v0.50.0 of the bridge, v1.25.0 of the OpenTelemetry API and SDK, and v1.19.0 of the Prometheus client. From 9b9d10a4cb115913fe6ea82c3f17313f0c31a5fe Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Mon, 8 Apr 2024 16:40:05 -0400 Subject: [PATCH 5/5] Update bridges/prometheus/BENCHMARKS.md --- bridges/prometheus/BENCHMARKS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/prometheus/BENCHMARKS.md b/bridges/prometheus/BENCHMARKS.md index a491ec2e3a9..7360d188c66 100644 --- a/bridges/prometheus/BENCHMARKS.md +++ b/bridges/prometheus/BENCHMARKS.md @@ -6,7 +6,7 @@ However, unless the application has extremely high cardinality for metrics, this The bridge is particularly useful if you are exporting to an OpenTelemetry Collector, since the OTLP receiver is much more efficient than the Prometheus receiver. For the same 30k timeseries, the Prometheus receiver uses 3x the amount of memory, and 20x the amount of CPU. In concrete numbers, this is an additional 228 MB of memory, and 0.57 CPU cores. -For an application using the Prometheus client library, and exporting to an OpenTelemetry collector, the total CPU usage is 55% lower and total memory usage is 45% lower when using the bridge and the OTLP receiver compared to using a Prometheus endpoint and the collector's Promethehus receiver. +For an application using the Prometheus client library, and exporting to an OpenTelemetry collector, the total CPU usage is 55% lower and total memory usage is 45% lower when using the bridge and the OTLP receiver compared to using a Prometheus endpoint and the collector's Prometheus receiver. ## Methods and Results