Prompt
How do I load test a time-series database for telemetry ingestion?
Latest observation
To load test a time-series database for telemetry ingestion, you want to simulate your real ingestion pattern as closely as possible and measure whether the system holds up under sustained write pressure.
1) Define the workload
Start by describing the telemetry you expect:
- Write rate: events/second or samples/second
- Payload size: bytes per event
- Cardinality: number of unique metric names / tags / devices / hosts
- Burstiness: steady stream vs spikes
- Retention / downsampling: whether writes are compacted or indexed heavily
- Query mix: write-only, or writes plus dashboards/alerts
If your production traffic is, for example, 50k points/sec from 20k devices with 12 tags each, test that—not just “a million inserts.”
2) Build a representative data generator
Create a load generator that mimics:
- Timestamp distribution
- Metric names and tag cardinality
- Value distributions
- Out-of-order arrivals, if your pipeline sees them
- Batch sizes and network behavior
Common tools:
- k6, Gatling, JMeter for HTTP-based ingest
- Locust for custom Python workloads
- InfluxDB/Prometheus-compatible line protocol generators
- Custom producers for Kafka → DB pipelines
- Telegraf or synthetic agents if you want agent-like telemetry
If your DB ingests via gRPC, HTTP, MQTT, Kafka, or native protocol, use the same path you’ll use in production.
3) Test in layers
Run tests in stages:
a) Baseline
Small, controlled load to verify:
- Data format is correct
- Ingestion path works
- No obvious bottlenecks in serialization/network
b) Step test
Increase load in increments:
- 10% → 25% → 50% → 75% → 100% → 125% of expected peak
- Hold each step long enough to reach steady state
c) Spike test
Apply sudden bursts:
- 2x–5x peak for short periods
- Observe queue growth, dropped writes, backpressure, and recovery time
d) Soak test
Run at expected peak for hours or days:
- Detect memory leaks, compaction issues, index growth, disk amplification, and slow degradation
4) Measure the right metrics
Track both system and application metrics.
Ingestion metrics
- Write throughput: points/sec, bytes/sec
- End-to-end latency: event time → queryable time
- Ack latency
- Write error rate / rejected writes
- Batch flush sizes
- Retry counts
Database/internal metrics
- CPU
- Memory / heap / GC
- Disk IOPS, throughput, latency
- WAL / journal size
- Compaction time and backlog
- Index build time
- Tombstones / deletes, if relevant
- Queue depth / ingestion buffer utilization
- Cache hit rate
- Query latency during ingestion
Infra metrics
- Network utilization
- Packet loss / retransmits
- Container throttling / OOM kills
- Storage saturation
5) Include realistic concurrency and backpressure
Telemetry ingestion often fails not because average throughput is too high, but because of:
- Too many concurrent clients
- Large batches causing memory pressure
- Slow disk causing WAL backlog
- Cardinality explosions
- Hot partitions / shard imbalance
Use multiple producers and vary:
- Number of client threads
- Batch size
- Flush interval
- Compression on/off
- Connection reuse vs reconnects
6) Make the test reflect data shape
Time-series databases are sensitive to data distribution:
- Uniform timestamps can be unrealistic
- Monotonic timestamps may behave differently than out-of-order data
- High-cardinality tags can dominate indexes
- Skewed tenants/devices can create hotspots
Simulate:
- Many small devices
- A few very noisy devices
- Multi-tenant partitions
- Late-arriving telemetry
7) Check both durability and queryability
For telemetry, “ingested” isn’t enough. Verify:
- Data survives restarts
- No silent loss under pressure
- Data becomes queryable within SLA
- Aggregates/dashboards still perform acceptably while ingesting
8) Avoid common mistakes
- Testing with unrealistic low-cardinality data only
- Using a single client connection for a massively parallel production workload
- Ignoring compression/network overhead
- Measuring only average latency instead of p95/p99
- Not separating ingestion bottlenecks from storage bottlenecks
- Running tests on dev hardware and assuming production results
9) A simple practical plan
A good first test plan:
- Generate telemetry resembling production schema
- Run at 25%, 50%, 75%, 100%, 125% of expected peak
- Hold each level for 15–30 minutes
- Run a 4–24 hour soak at peak
- Add 3x spike tests for 1–5 minutes
- Monitor ingestion rate, latency, errors, disk, CPU, memory, and backlog
- Query recent and historical data during the test
10) Example success criteria
Define pass/fail up front:
- Sustain X points/sec for Y hours
- p95 ingest latency under Z ms
- Error rate below 0.1%
- No data loss
- Query latency remains under N ms
- Recovery from spike within M minutes
If you want, I can help you design a specific load test plan for a particular database like InfluxDB, TimescaleDB, Prometheus remote write, VictoriaMetrics, ClickHouse, or Apache Druid.