Reducing Remote Read Footprint Bartek Plotka @bwplotka Getting - - PowerPoint PPT Presentation
Reducing Remote Read Footprint Bartek Plotka @bwplotka Getting - - PowerPoint PPT Presentation
Reducing Remote Read Footprint Bartek Plotka @bwplotka Getting samples from TSDB /api/v1/query /api/v1/query_range Prometheus PromQL Engine Select() Select() /read Queryable Interface TSDB @bwplotka Remote Read: Response /read
@bwplotka
Prometheus PromQL Engine TSDB Queryable Interface Select()
Getting samples from TSDB
Select() /api/v1/query /api/v1/query_range /read
@bwplotka
Remote Read: Response
/read
<proto> message QueryResult { repeated prometheus.TimeSeries timeseries = 1; } message TimeSeries { repeated Label labels = 1; repeated Sample samples = 2; }
SAMPLES
https://developers.google.com/protocol-buffers over HTTP
Prometheus
Chunks Chunks Series C
@bwplotka
TSDB
Remote Read: Bottlenecks
Select()
Chunks Chunks Chunks Series B Chunks Chunks Chunks Series A
Filling… Huge RemoteRead Response
Decode samples
Prometheus
@bwplotka
Remote Read: Bottlenecks
Done! Huge RemoteRead Response
Marshall
proto binary
Compress
@bwplotka
Remote Read Request: Allocations on heap
Single request for 8h, 10 000 series Prometheus: 1.5GB Thanos: 2GB
@bwplotka
Remote Read: Response (Prometheus 2.13.0)
/read
<proto> message QueryResult { repeated prometheus.TimeSeries timeseries = 1; } message TimeSeries { repeated Label labels = 1; repeated Sample samples = 2; } <proto> message ChunkedReadResponse { repeated prometheus.ChunkedSeries chunked_series = 1; } message ChunkedSeries { repeated Label labels = 1; repeated Chunk chunks = 2; }
SAMPLES STREAMED_XOR_CHUNKS [NEW]
@bwplotka
Remote read: Response (Prometheus 2.13.0)
/read
<proto> message QueryResult { repeated prometheus.TimeSeries timeseries = 1; } message TimeSeries { repeated Label labels = 1; repeated Sample samples = 2; } <proto> message ChunkedReadResponse { repeated prometheus.ChunkedSeries chunked_series = 1; } message ChunkedSeries { repeated Label labels = 1; repeated Chunk chunks = 2; }
SAMPLES STREAMED_XOR_CHUNKS [NEW]
sample{Value, Timestamp} XOR chunk (~120 samples)
@bwplotka
Chunked protocol (Prometheus v2.13.0)
message ChunkedReadResponse { repeated prometheus.ChunkedSeries chunked_series = 1; } big-endian uint32 Checksum of ChunkedReadResponse uvarint64 of ChunkedReadResponse
1MB Max
Prometheus
Chunks Chunks Series E
@bwplotka
TSDB
Remote Read (Prometheus v2.13.0)
Select()
Chunks Chunks Chunks Chunks Chunks Chunks Series D Series C Chunked Read Response
Frame Marshall & Compress
1MB
@bwplotka
Remote Read Request: Heap Allocs
Prometheus: 150MB (was 1.5GB) Single request for 8h, 10 000 series Thanos: ~0B (was 2GB)
~2.5x reduced latency ~2x less CPU time
Bartek Plotka @bwplotka
Thanks!
Questions?
Links:
- APIs: https://prometheus.io/docs/prometheus/latest/querying/api/
- Remote read: https://github.com/prometheus/prometheus/blob/master/prompb/remote.proto#L27
- Go stream client: https://github.com/prometheus/prometheus/blob/master/storage/remote/chunked.go
- Blog: https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming/