Time-Series Platform Draft Specification
Overview
This document outlines the core features for a scalable, multi-tenant time-series database (TSDB) platform. The platform handles high-volume metrics ingestion, storage, querying, and visualization, with built-in safeguards for cardinality explosion, storage efficiency, and operational stability. Key focus areas: cardinality controls, downsampling, retention, and guardrails.
-
Target Use Cases: Monitoring (Prometheus-compatible), IoT, APM, financial tick data.
-
Core Components:
| Component | Description |
|---|
| Ingester | Handles write paths, validates metrics, applies controls. |
| Compactor | Manages downsampling, retention, and compaction. |
| Querier | Reads data, applies downsampling views. |
| API Gateway | Tenant isolation, rate limiting, auth. |
| Storage | Object storage (S3-compatible) + local cache (RocksDB/WAL). |
-
Data Model: Metrics as (name, labels) -> [timestamp, value]. Prometheus remote_write/read compatible.
-
Tenancy: Namespaces for isolation (quotas per tenant).
1. Cardinality Controls
High cardinality (unique series count) is the #1 killer of TSDB scalability. Controls enforce limits at ingestion to prevent OOM, hotspots, and query slowdowns.
Key Features
-
Global/Tenant Limits:
| Limit Type | Default | Configurable | Enforcement |
|---|
| Max series per tenant | 1M | Yes (1K-100M) | Reject writes exceeding. |
| Max labels per series | 10 | Yes (5-20) | Strip excess on ingest. |
| Max label values per label name (per tenant) | 100K | Yes | Reject or hash-collide. |
| Max active series (scraped) | 500K/tenant | Yes | Circuit breaker on scrape. |
-
Label Management:
__name__ required; dynamic labels allowed but sanitized (no IPs, UUIDs by regex).
- Label Clustering: Auto-group high-cardinality labels (e.g.,
user_id >10K values → hashed to buckets).
- Drop Rules: Tenant-configurable regex drops (e.g., drop
trace_id).
-
Metrics & Alerts:
- Expose
tsdb_cardinality_series{tenant}, tsdb_cardinality_dropped.
- Alert if >80% of quota.
-
Implementation:
- Ingester uses in-memory Bloom filters + Redis for tenant state.
- Reject response: HTTP 429 with
X-Cardinality-Violation: series_limit.
2. Downsampling
Reduces storage/query costs by pre-aggregating raw data into coarser resolutions. Automatic, configurable per tenant/metric.
Aggregation Policies
3. Retention
Tiered, infinite-forward retention with cost controls. No data loss within policy.
Policies
-
Default Tiers (per tenant, GB/month pricing):
| Tier | Duration | Resolution | Cost Factor |
|---|
| Hot | 7d | Raw | 1x |
| Warm | 90d | 1m+ | 0.3x |
| Cold | 1y | 5m+ | 0.1x |
| Frozen | Infinite | 1h+/1d | 0.01x (optional archive) |
-
Config:
- Tenant sets per-namespace:
retention: {default: 90d, high_value: infinite}.
- Soft-delete: Quarantined data queryable for 7d post-expiry.
-
Deletion:
- Compactor marks blocks expired → lazy delete from storage (TTL on objects).
-
Metrics: tsdb_storage_usage_bytes{tenant, tier}, tsdb_retention_dropped_bytes.
4. Guardrails
Prevent abuse, DoS, and misconfigs. Multi-layered: ingress, runtime, storage.
Core Guardrails
| Guardrail | Trigger | Action | Recovery |
|---|
| Ingestion Rate | >10K series/s/tenant | Throttle (50% drop) | Backoff + alert. |
| Query Concurrency | >100qps/tenant | Queue + 429 | Tenant quota bump. |
| Query Time | >30s | Cancel + sample response. | Async jobs for long queries. |
| Storage Quota | >90% tenant limit | Reject writes. | Auto-scale or notify. |
| Hotspot Detection | Single series >1% ingest | Label hashing + alert. | - |
| Burst Protection | >5x baseline | Token bucket (1M tokens/tenant). | - |
| Cross-Tenant Leak | Auth fail | 403 + ban IP 1h. | Audit logs. |
-
Circuit Breakers: Per-ingester (e.g., WAL full → read-only).
-
Fail-Closed Defaults: Unknown metrics dropped.
-
Observability: All rejections logged + Grafana dashboards.
-
Tenant Self-Service:
- API:
/v1/quotas, /v1/rules/cardinality.
- Web UI for rules editor.
Implementation Roadmap
| Phase | Features | Timeline |
|---|
| MVP | Basic ingest/query + cardinality limits + 30d retention. | 4 weeks |
| V1 | Downsampling + tiered retention + basic guardrails. | 8 weeks |
| V2 | Advanced clustering, infinite retention, query federation. | 12 weeks |
Risks & Mitigations
- Cardinality Evasion: Regex/ML anomaly detection.
- Downsampling Skew: Histogram validation.
- Storage Costs: Predictive quotas + compression (ZSTD + Gorilla).
This draft provides a production-ready foundation. Feedback welcome for iterations! 🚀