<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by EMRE DEMİR on Medium]]></title>
        <description><![CDATA[Stories by EMRE DEMİR on Medium]]></description>
        <link>https://medium.com/@dmremre28?source=rss-395a0625b227------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DEChIcGVMTz0Tt6y</url>
            <title>Stories by EMRE DEMİR on Medium</title>
            <link>https://medium.com/@dmremre28?source=rss-395a0625b227------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 16:45:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dmremre28/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Elasticsearch to ClickHouse: Keeping Jaeger While Cutting What Traces Actually Cost]]></title>
            <link>https://medium.com/trendyol-tech/from-elasticsearch-to-clickhouse-keeping-jaeger-while-cutting-what-traces-actually-cost-c8d931497a4f?source=rss-395a0625b227------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8d931497a4f</guid>
            <category><![CDATA[jaeger]]></category>
            <category><![CDATA[distributed-tracing]]></category>
            <category><![CDATA[opentelemetry]]></category>
            <category><![CDATA[clickhouse]]></category>
            <category><![CDATA[observability]]></category>
            <dc:creator><![CDATA[EMRE DEMİR]]></dc:creator>
            <pubDate>Fri, 16 Oct 2026 13:01:15 GMT</pubDate>
            <atom:updated>2026-11-25T07:38:28.795Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OrMMppm3cFzsMXElEiwvug.jpeg" /></figure><p><em>We used to run Elasticsearch behind Jaeger, but at our volume it did not scale. To fix the cost and retention limits without forcing a new UI on hundreds of engineers, we swapped Elasticsearch for ClickHouse. This post is how we made that transition, and what the pipeline looks like today.</em></p><h3>Where we started</h3><p>Roughly <strong>~250 Kubernetes clusters</strong> ship traces into our observability platform. Across two active-active regions, that lands on the order of <strong>~2.9 million spans per second</strong> on a daily average, with peaks around <strong>~4.6M/sec</strong>. Hundreds of billions of spans per day.</p><p>On Elasticsearch that volume meant a lot of nodes and a lot of CPU. Disk did not scale with it. We were not able to keep more than about <strong>6 hours</strong> of the traces people actually needed. Even inside that window, heavy searches could exhaust Jaeger Query and slow everyone else down: a service graph, a wide tag filter, or looking up one failed request across many services.</p><p>Most of the volume was successful traffic nobody opened. We were paying search-engine prices to hold it, and still throwing away the longer context our alerting and investigation flows needed.</p><p>We did not want a new UI. Teams already knew Jaeger. The constraint was simple: keep the Jaeger experience, change what sits underneath it.</p><h3>Why ClickHouse, and why Jaeger stayed</h3><p>We already ran ClickHouse for other observability workloads, so the question was natural: can traces live there too? Columnar storage, compression, and analytic queries fit this data better than Elasticsearch had. A fair worry at the time was the opposite of “it will be tiny”: once you stop squeezing retention down to a few hours, a new store might simply use more disk. What we measured later, at the <strong>same sampling and a 24-hour window</strong>, was that ClickHouse on disk was a fraction of Elasticsearch, because the bytes are compressed. That is what let us <strong>raise</strong> the hot window (toward <strong>48 hours</strong> today) instead of staying stuck at a few hours.</p><p>Jaeger was moving the same direction. This was early Jaeger v2. Remote storage over gRPC (trace_storage.proto) was already real: implement the query contract, point Jaeger Query at it, and the UI keeps working. Native ClickHouse support in Jaeger was still experimental. We did not wait for that to harden. We bet on the remote-storage API, wrote a small adapter, and put production traces on ClickHouse. That bet is the system this article describes.</p><p>We split the work along pieces we already trusted:</p><ul><li><strong>OpenTelemetry + Kafka</strong> already carried our ingest. We added a tail sampler and then a ClickHouse writer on that same path, instead of standing up a separate Jaeger Collector beside it. Those extra stages are still one pipeline, not a second product.</li><li><strong>Jaeger Query</strong> stayed where it is strong: the UI and the query experience engineers already use. “trace-api” is the adapter in front of ClickHouse. It takes Jaeger’s storage calls and turns them into SQL.</li></ul><p>We kept Jaeger Query as the presentation layer, swapped the storage engine for ClickHouse, and introduced tail sampling on the ingest path.</p><p>If a native ClickHouse backend in Jaeger becomes something we want later, it is another option. The sampling policy and the tables stay ours either way.</p><h3>Why we sample after the trace exists</h3><p>Putting the same firehose into ClickHouse would still leave you looking for a needle in a haystack, and it would fill disk with requests nobody queries. Most of the volume is successful traffic. The spans you actually need in an incident are the failures, the slow calls, and the key business transactions (KBT).</p><p><strong>Head sampling</strong> decides when the span shows up, before the rest of the trace has arrived. You cannot yet tell whether the request failed, was slow, or was a KBT. The control is coarse.</p><p><strong>Tail sampling</strong> happens later in the same pipeline, not inside ClickHouse and not inside the application. We hold the trace for a short window (<strong>15 seconds</strong>) until its spans have assembled, then keep or drop the whole thing. Errors and slow KBTs stay. Routine success is cut hard. In production about <strong>~0.8%</strong> of spans leave the sampler; the rest never become parts on disk. That is why the ClickHouse window stays small enough to query, even after we lengthened it.</p><p>Sampling chooses which traces are worth storing. Retention chooses how long they live. On Elasticsearch we were stuck at about <strong>6 hours</strong>. Compression plus tail sampling is what made a <strong>48-hour</strong> window affordable on ClickHouse.</p><h3>The shape of the system</h3><p>Ingest stays fast until a full trace exists. The tail sampler is where the keep-or-drop decision happens. Reads go through the API Jaeger Query already speaks.</p><p>Today, per region: <strong>80</strong> Head Collectors, <strong>100</strong> Tail Collectors (on the order of <strong>millions</strong> of in-flight traces across the fleet), <strong>10</strong> ClickHouse writers, and <strong>20</strong> Jaeger Query replicas in front of the adapter. What we keep lands in a <strong>7-shard</strong> ClickHouse install per region. The live 48h window is about ~2.0 TiB in one region and ~2.4 TiB in the other.</p><ul><li><strong>Head Collector:</strong> Accepts OTLP, Jaeger, and Zipkin from the fleet, filters and redacts, publishes to Kafka partitioned by `trace_id`. Stateless.</li><li><strong>Tail Collector:</strong> Holds complete traces, applies the sampling policy, republishes only what we keep. Stateful.</li><li><strong>ClickHouse writers:</strong> Enrich spans and async-insert them into the 48h tables.</li><li><strong>trace-api:</strong> Jaeger Query calls it over gRPC; it runs the SQL.</li></ul><p>The Head tier ingests. The Tail tier decides which traces to keep. ClickHouse stores them. The adapter runs the queries over SQL.</p><h3>The end-to-end picture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ouse5ThK7YmC8KNI.png" /><figcaption>Ingest runs on OpenTelemetry. Jaeger Query stays on the read path.</figcaption></figure><p>Reading it left to right:</p><ol><li><strong>In-cluster collectors</strong> across ~250 client clusters send spans into the central Head tier (OTLP, Jaeger, and Zipkin).</li><li><strong>Head Collectors</strong> (80 replicas/region) route and redact. They do not sample. Spans land on Kafka <strong>partitioned by trace_id</strong>, so every span of one trace is read by the same Tail replica. Without that, tail sampling cannot see a complete trace.</li><li><strong>Tail Collectors</strong> (100 replicas/region) hold traces for <strong>15 seconds</strong>, take the first matching policy, and republish only the kept traffic.</li><li><strong>ClickHouse Collectors</strong> (10 replicas/region) enrich and async-insert through a write-oriented distributed table. Schema comes from migrations (create_schema: false); the exporter does not create tables.</li><li><strong>Jaeger Query</strong> (20 replicas/region) calls <strong>trace-api</strong>, which reads through a TraceId-hashed distributed table so one trace hits one shard.</li></ol><h3>The path of a sampled span</h3><p>Assemble the trace, decide once, then either drop it or write it into the 48h store:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UJEXOfciaxbPGNyN.png" /><figcaption>Judgment happens after the trace exists, and before anything is written.</figcaption></figure><h3>How a trace gets kept</h3><p>The tail sampler walks an ordered list and stops on the first match:</p><ol><li><strong>Oversized traces</strong> (&gt;4000 spans) → drop</li><li><strong>Test / debug services</strong> → keep 100%</li><li><strong>KBT error</strong> → keep 100%</li><li><strong>KBT latency &gt;5s</strong> → keep 100%</li><li><strong>Other errors</strong> → keep 20%</li><li><strong>Everything else (success)</strong> → keep <strong>1%</strong></li></ol><h3>The detail that mattered most</h3><p>Sampling in does not by itself give you a useful window, and a longer TTL without sampling just stores the success firehose. Both have to move together: keep the error and KBT signal, cut routine success to about 1%, and let what remains expire on the hot window (<strong>48 hours</strong> today).</p><p>Under that, <strong>Kafka has to be partitioned by trace_id.</strong> If spans of one trace land on different tail replicas, the sampler never sees the whole trace. Partitioning is what makes the decision correct. Replica count is what lets us hold <strong>~5–6M</strong> in-flight traces while we wait.</p><h3>Writing into ClickHouse</h3><p>The ClickHouse collector batches, compresses, and inserts. Migrations own the tables:</p><pre>exporters:<br>  clickhouse/traces:<br>    endpoint: https://clickhouse.internal.example.com?dial_timeout=10s&amp;compress=lz4<br>    database: default<br>    traces_table_name: otel_traces_dist   # write entry (spread)<br>    create_schema: false                  # migrations own DDL<br>    async_insert: true<br>    sending_queue:<br>      batch:<br>        min_size: 5000<br>        max_size: 10000<br>        flush_timeout: 60s</pre><p>The exporter has its own short buffer ttl. That is not how long traces live. The <strong>48h</strong> window is the table TTL in ClickHouse.</p><h3>The read path</h3><p>“trace-api” is what Jaeger Query calls. It implements the reads Jaeger already does (list services, list operations, fetch a trace, search) and turns each call into SQL. It is a separate service we ship on our own cycle, not code compiled into the Jaeger binary, so we can change it without taking a Jaeger release. The same API is what our internal tools use. Engineers still open Jaeger. They do not open ClickHouse.</p><p>Jaeger Query only needs to point at that endpoint:</p><pre>extensions:<br>  jaeger_query:<br>    storage:<br>      traces: custom-storage-backend<br>  jaeger_storage:<br>    backends:<br>      custom-storage-backend:<br>        grpc:<br>          endpoint: &lt;your-internal-grpc-endpoint&gt;:50051<br>          tls:<br>            enabled: true<br>          max_recv_msg_size_mib: 16</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o1z16VhQ88cXVKnN.png" /><figcaption>ClickHouse stays behind the adapter. The UI does not change.</figcaption></figure><p>Jaeger for the UI, OpenTelemetry for ingest, ClickHouse for the store, a small translator in between.</p><h3>Schema boundaries worth keeping</h3><p>ClickHouse here is not one big span table. Three boundaries matter more than any column list:</p><ul><li><strong>Hot spans expire.</strong> MergeTree, partitioned by day, <strong>TTL 48 hours</strong>. This is the investigation window, not an archive.</li><li><strong>Writes and reads enter through different tables.</strong> otel_traces_dist spreads writes. otel_traces_dist_api hashes by TraceId, so fetching one trace does not hit every shard.</li><li><strong>Small helper tables answer the cheap calls.</strong> Service and operation lists, and per-trace time bounds, do not scan the span table.</li></ul><h3>What we measured</h3><p>These are the numbers we used when we promoted the migration.</p><p><strong>Query isolation.</strong> Heavy SRE workloads (service graphs and wide analytics) used to exhaust Jaeger Query and slow other clients. Those queries now run as ClickHouse SQL. Other teams are no longer waiting on the same query workers.</p><p><strong>A longer useful window.</strong> Error-path context that used to stop at about <strong>6 hours</strong> now lives for <strong>48 hours</strong>. The comparison below is the same sampling and the same <strong>24-hour</strong> window, so the saving is compression and query shape, not a shorter TTL.</p><p><strong>Same sampling, 24-hour retention:</strong></p><ul><li><strong>Memory:</strong> Elasticsearch ~350–400 GB → ClickHouse ~150–200 GB (<strong>≈53% less</strong>)</li><li><strong>CPU:</strong> Elasticsearch ~250–300 cores → ClickHouse ~45–50 cores (<strong>≈83% less</strong>)</li><li><strong>Disk:</strong> Elasticsearch ~7.86 TiB → ClickHouse ~1.01 TiB compressed (<strong>≈87% less</strong>, ~6.85 TiB saved)</li></ul><p>That is about <strong>53% less memory</strong>, <strong>83% less CPU</strong>, and <strong>87% less disk</strong> (~6.85 TiB). On-disk compression was about <strong>11.7×</strong> (uncompressed ~11.83 TiB → compressed ~1.01 TiB).</p><p><strong>What the fleet looks like today.</strong> <strong>~250</strong> client clusters, <strong>~2.9M spans/sec</strong> average (peaks <strong>~4.6M</strong>), about <strong>~0.8%</strong> kept after tail sampling, <strong>~4.3 TiB</strong> used across both regions for the live 48h window.</p><h3>Closing</h3><p>We kept Jaeger Query as the UI, moved spans to ClickHouse, and sampled only after the trace existed. At the same sampling and a 24-hour window that cut memory roughly in half, CPU by about five times, and disk by about eight times. The store we run today holds 48 hours, not 6.</p><h3>About Us</h3><p>Want to know more? Or contribute by researching it yourself?</p><p>We’re building a team of the brightest minds in our industry. Interested in joining us? Visit the pages below to learn more about our open positions.</p><p>Home — Trendyol Careers<br><a href="https://careers.trendyol.com/">https://careers.trendyol.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8d931497a4f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/trendyol-tech/from-elasticsearch-to-clickhouse-keeping-jaeger-while-cutting-what-traces-actually-cost-c8d931497a4f">From Elasticsearch to ClickHouse: Keeping Jaeger While Cutting What Traces Actually Cost</a> was originally published in <a href="https://medium.com/trendyol-tech">Trendyol Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>