tstorage logo

tstorage

Fast, goroutine-safe on-disk time-series storage for Go

tstorage provides a lightweight, high-performance TSDB engine with simple Go API, supporting in-memory and persistent disk partitions, goroutine-safe writes, and fast range queries.

Overview

Overview

tstorage is aimed at Go developers who need to ingest massive time‑series streams while keeping heap usage low. It offers a straightforward API for inserting rows and selecting data by metric, optional labels, and time range. By default it runs fully in memory, but can persist data to disk via the WithDataPath option, automatically partitioning points by timestamp.

Deployment

Create a storage instance with tstorage.NewStorage, configure timestamp precision, and use InsertRows and Select for writes and reads. The engine maintains a write‑ahead log, moves full memory partitions to compressed, memory‑mapped disk files, and keeps recent partitions cached for ultra‑fast queries (≈56 B per read). Benchmarks on an i7‑8559U show sub‑microsecond write latency and low allocation overhead, making it suitable for real‑time analysis tools and edge services.

Highlights

Goroutine-safe ingestion with nanosecond-level performance
Automatic time-partitioning keeps recent data in memory and older data on disk
Simple API supporting labeled metrics and configurable timestamp precision
Minimal allocation reads (~56 B) and fast range queries demonstrated in benchmarks

Pros

  • High write throughput with low heap overhead
  • Seamless transition from in‑memory to on‑disk storage
  • Easy integration into Go projects via a minimal API
  • Fast range queries thanks to time‑ordered partitions

Considerations

  • Limited to the Go ecosystem; no native bindings for other languages
  • No built-in query language beyond simple range selects
  • Partition size and retention policies are not configurable via the API
  • Does not provide clustering or replication features

Managed products teams compare with

When teams consider tstorage, these hosted platforms usually appear on the same shortlist.

Amazon Timestream logo

Amazon Timestream

Serverless time-series database for IoT, metrics, and operational telemetry

Azure Data Explorer logo

Azure Data Explorer

Fast analytics database for logs, telemetry, and time-series (Kusto)

KX kdb+ logo

KX kdb+

High-performance time-series database and real-time analytics engine

Looking for a hosted option? These are the services engineering teams benchmark against before choosing open source.

Fit guide

Great for

  • Real-time monitoring agents that need local TSDB storage
  • Load-testing tools requiring stable memory usage under high ingest rates
  • Edge services that must persist sensor data without external databases
  • Go applications that prefer an embedded time-series engine

Not ideal when

  • Distributed analytics platforms needing multi-node replication
  • Workloads requiring complex aggregations or SQL‑like queries
  • Environments where a language‑agnostic storage solution is required
  • Systems that demand configurable partition sizing or retention policies

How teams use it

Load-testing metrics collection

Capture millions of latency points with sub-microsecond write latency, keeping heap usage stable.

Edge device sensor logging

Persist time-stamped sensor readings locally, with automatic roll-off to disk and fast retrieval for alerts.

In-process monitoring for microservices

Store per-service counters and histograms without external DB, enabling instant dashboards.

Ad-hoc analysis of recent data

Query the last hour of data directly from memory for real-time visualizations.

Tech snapshot

Go100%
Makefile1%

Tags

metricstime-series-databasetime-seriesdatabasegolanggolang-library

Frequently asked questions

Does tstorage support concurrent reads and writes?

Yes, the API is goroutine-safe for both operations.

How is data persisted to disk?

When a memory partition fills, it is compacted and written as compressed, read-only files with accompanying meta.json; a write-ahead log protects against loss.

Can I change the time-partition size?

Partition size is determined by timestamp range; the library does not expose a configurable size parameter.

What Go versions are required?

Go 1.16 or newer.

Is there a built-in query language?

No, tstorage provides simple range-select APIs; more complex queries must be implemented by the caller.

Project at a glance

Stable
Stars
1,231
Watchers
1,231
Forks
83
LicenseApache-2.0
Repo age4 years old
Last commit6 months ago
Primary languageGo

Last synced 3 hours ago