> For the complete documentation index, see [llms.txt](https://stephen-tsoi.gitbook.io/stephen-tsoi-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stephen-tsoi.gitbook.io/stephen-tsoi-docs/opentelemetry/from-missing-events-to-complete-visibility-tracing-enterprise-transactions-with-opentelemetry/day-15-34-minimize-the-bandwidth-usage-sampling.md).

# Day 15/34 Minimize the bandwidth usage - Sampling

The OTel offers comprehensive training for developers, enabling quick issue identification within components. However, this may lead to increased network traffic. For instance, with a system peak TPS of 100,000 and each trace containing 2 spans of 3Kb each, total bandwidth usage can reach 600Mb, impacting network performance during high traffic. OTel addresses this by facilitating data filtering in trace logs and implementing sampling to restrict trace numbers, reducing costs and enhancing efficiency.

## 1. Head Sampling:

Using OpenTelemetry, applications can set sampling\_percentage on the trace structure, allowing the OpenTelemetry Collector to filter traces based on this flag when triggered, eliminating the need for custom sampling logic. While most event buses lack head sampling support, the collector processor can implement it.

## 2. Remote Sampling:

Applications can utilize local sampling for individual services and leverage Remote Sampling via Jaeger to adjust sampling settings dynamically, optimizing resource usage based on specific time frames for improved efficiency.

## 3. Tail Sampling:

OpenTelemetry Collector employs Tail Sampling to filter data based on predefined criteria like error codes or latency. This method ensures all spans within a trace are processed by the same collector, requiring a two-tier collector architecture design for effective analysis and decision-making. The first layer calculates metrics and routes traces to a second layer based on trace IDs, which stores spans with the same ID for a set duration before deciding to send to the APM backend.

Developers prioritize failure cases over successful ones, making Tail Sampling crucial for 100% logging of failures while applying specific sampling ratios to successful cases. This approach, though effective, demands a sophisticated OTel cluster and high hardware requirements due to the need to store trace data before transmission to the APM backend.

## 🚀 Let's Connect Beyond GitBook!

If you found this article helpful, you can find more of my technical insights, daily discussions, and deep dives across these platforms:

* **Read more of my work:** Check out my articles on [dev.to](https://dev.to/stephen_tsoi_5b2c4055f3a9) and [Hashnode](https://stephentsoi.hashnode.dev/).
* **Join the daily conversation:** Connect with me directly on [LinkedIn](https://www.linkedin.com/in/stephen-tsoi-16309730/).

***

#### 📬 Stay Ahead of the Curve

Enjoyed this piece? I break down complex technical topics into bite-sized, actionable insights every week.

👉 **Subscribe to my** [**LinkedIn Newsletter**](https://www.linkedin.com/build-relation/newsletter-follow?entityUrn=7487299517642612736) to never miss an update and get the latest articles delivered straight to your feed!


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://stephen-tsoi.gitbook.io/stephen-tsoi-docs/opentelemetry/from-missing-events-to-complete-visibility-tracing-enterprise-transactions-with-opentelemetry/day-15-34-minimize-the-bandwidth-usage-sampling.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
