Prompt
I'm building a high traffic API and need trace storage at scale
Latest observation
For a high-traffic API, trace storage at scale usually comes down to four things:
- High ingestion throughput
- Low-cost long-term retention
- Fast query for recent traces
- Good sampling/cardinality control
Recommended architecture
1) Collect and buffer traces
Use an OpenTelemetry Collector fleet in front of storage.
- Receives traces from services
- Batches/compresses spans
- Applies tail sampling, filtering, enrichment
- Buffers during downstream incidents
Good setup:
- App → OTel SDK → OTel Collector → storage pipeline
2) Separate hot vs cold storage
Don’t keep all traces in one system.
- Hot storage: recent traces for fast debugging, e.g. 1–7 days
- Cold storage: long-term archive in object storage, e.g. S3/GCS/Azure Blob
- Optional: index only key metadata in a fast DB/search engine
This keeps costs reasonable while preserving observability.
3) Use sampling strategically
At high traffic, storing every trace is often too expensive.
Common strategies:
- Head sampling: sample at the edge, simple and cheap
- Tail sampling: keep slow/error traces after seeing the full trace
- Adaptive sampling: increase sampling for errors, latency spikes, new deploys, specific tenants, etc.
A practical pattern:
- Always keep:
- errors
- p95/p99 latency traces
- traces for premium tenants
- traces during incidents
- Sample the rest at a low baseline rate
Storage options
Option A: Purpose-built tracing backend
Examples:
- Grafana Tempo
- Jaeger with scalable backend
- Honeycomb / managed observability platforms
- Datadog / New Relic / Lightstep if you want managed scale
Best when:
- you want trace-native querying
- you want less operational burden
Option B: Object storage + index
Store full spans in:
- S3/GCS/Blob and keep an index in:
- Cassandra / DynamoDB / Elasticsearch / ClickHouse / PostgreSQL depending on access patterns
Good for:
- huge scale
- cheaper retention
- custom query models
Option C: ClickHouse-based storage
Often a strong choice for high-volume observability.
Pros:
- excellent compression
- fast analytical queries
- good for large trace datasets
- can store both spans and derived rollups
Cons:
- requires careful schema and operational tuning
What I’d recommend in practice
If you’re starting from scratch and expect serious scale:
- OpenTelemetry everywhere
- OTel Collector with batching + tail sampling
- ClickHouse or Tempo for hot searchable storage
- Object storage for long-term retention
- Metrics/logs correlation via trace IDs
- Adaptive sampling based on error/latency/tenant
Key design decisions
Retention
Define tiers:
- 24h–7d hot
- 30d+ cold archive
Indexing
Don’t index every span attribute. Index only:
- trace ID
- service name
- operation name
- timestamp
- status/error
- tenant/customer ID if needed
- latency bucket
Compression
Use:
- zstd/gzip at the collector or storage layer
- batch writes
- columnar storage where possible
Cardinality controls
Avoid exploding labels like:
- user IDs
- full URLs with IDs
- unbounded custom attributes
Use normalized fields and hashed IDs if needed.
Scaling concerns
At high traffic, watch for:
- storage write amplification
- expensive ad hoc queries
- hot partitions by timestamp/tenant
- collector bottlenecks
- tail sampling memory use
- per-span attribute explosion
A solid reference architecture
- Services instrumented with OpenTelemetry
- Regional OTel Collectors
- Kafka/NATS optional buffer
- Tail sampling at collector
- Hot trace store: Tempo or ClickHouse
- Cold archive: S3
- Query layer/dashboard on top
- Alerts from metrics, not traces
Quick recommendation by priority
- Lowest ops burden: managed observability platform
- Best open-source scalable option: Grafana Tempo + OTel Collector + S3
- Best query performance/flexibility: ClickHouse-based pipeline
- Best for custom massive scale: object storage + metadata index + adaptive sampling
If you want, I can help you design a specific trace storage architecture for your expected volume, e.g.:
- requests/sec
- average spans per request
- retention period
- cloud provider
- query latency goals
and I’ll propose a concrete setup and rough cost model.