Live data from Hacker News

Ask HN: What DB to use for huge time series?

news.ycombinator.com

101–110 of 135 posts

Re: Ask HN: What DB to use for huge time series?

#101
post #76

First, ask if you really need "massive" scale. Is this an idea, or a well-defined product? I'd imagine if you knew what you were building, you wouldn't be here asking. So "massive" -- why not prototype on Postgres, and then migrate when you actually have projections on size. Different orders of magnitude change the technology you work with. Additionally, the latency with which you need to access the metrics (real tim…

See also this talk by two Metamarkets devs: https://www.youtube.com/watch?v=Hpd3f_MLdXo

If accuracy doesn't have to be 100%, a number of options open up.

Re: Ask HN: What DB to use for huge time series?

#103
post #98

So many people suggesting relational databases or just plain "big data" solutions. Time series databases tend to have quite unique features like interpolation of data (i.e. you can query a specific datapoint at a specific date and time for a value, and you will get an interpolated value if there is no specific sample for that data point.) Anyway, no one has mentioned RRD tool yet: http://oss.oetiker.ch/rrdtool/ "RRDt…

The title has "huge time series" in it. How well does RRDTool scale?

That's a very open question, but RRD tool offers many modes of operation for data consolidation:

---

Data Acquisition

When monitoring the state of a system, it is convenient to have the data available at a constant time interval. Unfortunately, you may not always be able to fetch data at exactly the time you want to. Therefore RRDtool lets you update the log file at any time you want. It will automatically interpolate the value of the data-source (DS) at the latest official time-slot (interval) and write this interpolated value to the log. The original value you have supplied is stored as well and is also taken into account when interpolating the next log entry.

Consolidation

You may log data at a 1 minute interval, but you might also be interested to know the development of the data over the last year. You could do this by simply storing the data in 1 minute intervals for the whole year. While this would take considerable disk space it would also take a lot of time to analyze the data when you wanted to create a graph covering the whole year. RRDtool offers a solution to this problem through its data consolidation feature. When setting up an Round Robin Database (RRD), you can define at which interval this consolidation should occur, and what consolidation function (CF) (average, minimum, maximum, last) should be used to build the consolidated values (see rrdcreate). You can define any number of different consolidation setups within one RRD. They will all be maintained on the fly when new data is loaded into the RRD.

Round Robin Archives

Data values of the same consolidation setup are stored into Round Robin Archives (RRA). This is a very efficient manner to store data for a certain amount of time, while using a known and constant amount of storage space.

It works like this: If you want to store 1000 values in 5 minute interval, RRDtool will allocate space for 1000 data values and a header area. In the header it will store a pointer telling which slots (value) in the storage area was last written to. New values are written to the Round Robin Archive in, you guessed it, a round robin manner. This automatically limits the history to the last 1000 values (in our example). Because you can define several RRAs within a single RRD, you can setup another one, for storing 750 data values at a 2 hour interval, for example, and thus keep a log for the last two months at a lower resolution.

The use of RRAs guarantees that the RRD does not grow over time and that old data is automatically eliminated. By using the consolidation feature, you can still keep data for a very long time, while gradually reducing the resolution of the data along the time axis.

Using different consolidation functions (CF) allows you to store exactly the type of information that actually interests you: the maximum one minute traffic on the LAN, the minimum temperature of your wine cellar, ... etc.

Re: Ask HN: What DB to use for huge time series?

#104

DataDog uses elasticsearch for their timeseries data store: http://www.elasticsearch.org/content/uploads/2013/11/es_case... Elasticsearch might seem like a strange option at first since it's historically a text search engine, but it's main datastructure is a compressed bit array which is ideal for OLAP processing.

I work at Datadog - we're only using ElasticSearch for full-text structured events, not time-series, which represent 10,000 - 100,000 times more data in volume.

We had to build our own Time-Series streaming / storage / query so we could handle millions of points per second and years of retention.

(we love ElasticSearch, though)

Re: Ask HN: What DB to use for huge time series?

#105
RavenDB - they recently switched to a new engine and did some time series related work. Send them an email and you'll probably get a few free licenses. It's a very well selling commercial product, so the risk of deprecation minimal.

I have personally seen millions of records saved per minute on a top end SSD server.

Re: Ask HN: What DB to use for huge time series?

#106
post #98

So many people suggesting relational databases or just plain "big data" solutions. Time series databases tend to have quite unique features like interpolation of data (i.e. you can query a specific datapoint at a specific date and time for a value, and you will get an interpolated value if there is no specific sample for that data point.) Anyway, no one has mentioned RRD tool yet: http://oss.oetiker.ch/rrdtool/ "RRDt…

with RRDtool the older your data is the less of it you have. You might be logging at 1s period, and you get a nice graph for the last year, but if you want to look back at a 1 minute period from a year ago your 60 samples are gone and have been aggregated.

Historians like Pi etc will 'compress' time series by only storing data points where data has changed by some threshold. If you look back 5 years all the resolution is still there.

Re: Ask HN: What DB to use for huge time series?

#107
Approximately, if you have something like 10+ billion items, use Cassandra.

If you have less than 10 billion items, Postgres will be fine, and is easier to manage IMO.

If you do use postgres, you should vertically partition the table. This will help keep indexes smaller, improve the the cache hit rate, vastly improve the ease with which you can drop older data, and make various other admin tasks easier.

I've done this in the past with a compound primary key of (topic_id, t) where t was a microseconds-past-the-epoch timestamp (bigint) unique within a topic. Then set up a parent table: CREATE TABLE events (topic_id, t, data_fields..) and "CREATE TABLE .. INHERITS events" from it into multiple subtables, named based on the timespan they will hold, like events_2013, events_2014.

Depending on how much data you have, either partition by day/month/year/etc. I partitioned every million seconds (~11 days), since that kept the resulting table sizes a bit more manageable (gigs not TBs).

Add a CHECK CONSTRAINT to each sub-table to constrain the timespan (ie, WHERE t BETWEEN ?? and ??).

When you do a SELECT * FROM events WHERE topic_id = 1 AND t BETWEEN $x AND $y ORDER BY t DESC; the query planner knows which sub-table(s) to query, and doesn't touch the other tables at all.

You can also add a BEFORE INSERT trigger to the parent table that inserts into the correct sub-table, otherwise get clients to compute the correct table name when inserting.

Re: Ask HN: What DB to use for huge time series?

#108
We're an established team with a stealth product that we're releasing soon. If you'd like to participate in an early trial, send us an email. We're also happy to talk to anyone with time series needs or related needs like analytics on big data. Maybe we can build you something custom or cut you a deal. Drop us a line at bigdata.queries@gmail.com

Re: Ask HN: What DB to use for huge time series?

#110
post #29

Maybe check this out? https://github.com/soundcloud/roshi Roshi is basically a high-performance index for timestamped data. It's designed to sit in the critical (request) path of your application or service. The originating use case is the SoundCloud stream; see this blog post for details.

Roshi sits on top of Redis, so this solution can be quite expensive.
Post reply on HN