Timeseries indexing at scale
Datadog replaced its timeseries index, which auto-generated materialized indexes from a log of slow queries, with an inverted index that unconditionally indexes every metric;tag pair, much like search engines map words to documents. The original Go service used SQLite for index definitions and the query log and RocksDB for Tagsets, Metrics and Indexes. It worked for predictable programmatic queries, but unpredictable user queries fell back to full scans, causing timeouts and manual index toil. The next-gen design drops SQLite, keeps RocksDB, and answers tag filters by intersecting posting lists of timeseries IDs. The two generations are compared on performance and reliability.
Related posts
- Evolving the Backend Storage for Platform Metrics
Heroku Engineering mediumAdeptHeroku migrated the time-series store behind MetaaS, its internal metrics service, from self-managed Apache Cassandra to AWS DynamoDB without user-visible impact. MetaaS ingests a couple hundred thousand observations per second into Kafka and aggregates them with stream-processing jobs, writing tens of thousands of points per second to the database. The migration used parallel dual-writes from Kafka and GitHub Scientist-style shadow reads, ramped to 100% of traffic, to catch edge cases. TTL-based retention meant no data backfill was needed: they waited for old Cassandra data to expire, then incrementally cut reads over. p99 query latency dropped from a variable 20–80 ms to a steady 15 ms, and costs fell.
- 10x improved response times, cheaper to operate, and 30% storage reduction: why Instabug chose ClickHouse for APM
ClickHouse mediumAdept
Instabug moved its mobile APM backend (about 3 billion events per day at roughly 2 million per minute) from Elasticsearch to self-managed ClickHouse after shard tuning and daily indexes failed to keep up with reads and writes. The migration took about five months behind a config-driven datastore abstraction that allowed dual writes and per-user rollout. Queries read only from pre-aggregated TO-form materialized views on top of ReplicatedMergeTree tables with date partitions, retention is done by dropping partitions, and writes go in through buffer tables. Lessons include avoiding NULLs and random UUID keys (which hurt compression), lowering materialized-view cardinality, and building their own histograms, a query layer and schema-migration automation. Reported results are roughly 10x faster responses, at least 30% less storage and fewer machines.
- Evolving our real-time timeseries storage again: Built in Rust for performance at scale
Datadog Engineering hardMasterDatadog's sixth-generation real-time timeseries database (RTDB) is a Rust rewrite that unifies two earlier engines, one for scalar metrics and one for DDSketch distributions, after earlier generations built on Cassandra, Redis, MDBM, a Go B+ tree and RocksDB. Its storage engine, Monocle, is an LSM tree with a worker-per-shard, thread-per-core design. Kafka intake tasks route data over per-shard MPSC channels to single-threaded Tokio shards, which keeps locks off the write path. Permit-based throttling and CoDel-based cost scheduling keep the system stable under load, and snapshots provide recovery. Datadog reports 60x higher ingestion throughput and 5x faster queries at peak scale.
- Clever ingests 200x more logs at the same cost with ClickHouse Cloud
ClickHouse mediumAdept
Clever replaced a split Datadog/Athena logging setup with ClickHouse Cloud. It now indexes all ~150 TB/month of logs from 400 services and 200 Lambdas with 60-day retention, a 200x increase in searchable volume, at no extra cost and with 10x compression. The schema extracts hot fields into columns and stores the rest as raw JSON plus an attributes map. It uses token bloom filter indexes at granularity 32 for full-text search, date partitions with a 60-day TTL, and orders by negative Unix timestamp for an 8-10x query speedup. Resilience comes from separate dev and per-region prod services joined via remoteSecure and merge tables, all managed with Terraform and Goose. A custom LogQL-to-SQL layer keeps Grafana familiar for engineers.
- Bloom filters: the niche trick behind a 16× faster API
incident.io mediumAdeptincident.io cut P95 latency of its alert-filtering API for large organisations from 5s to 0.3s by pushing JSONB attribute filters into Postgres using bloom filters. Attribute key-value pairs are string-encoded, hashed with seven hash functions into a 512-bit bitmap stored as a bit(512) column, and queried with bitwise AND against bitmasks. With a 1% false-positive rate, only about 1% of the previous in-memory deserialization work remains. The bottleneck had been fetching and deserializing 500-row batches into Go structs. The team spiked a GIN index with jsonb_path_ops as the alternative and benchmarked both options before choosing.