ListenBrainz moves to TimescaleDB(blog.metabrainz.org) |
ListenBrainz moves to TimescaleDB(blog.metabrainz.org) |
We first built TimescaleDB as "Postgres for time-series" for our own needs and then decided to open-source it for others. :-)
Here's some instructions on how to do so: https://github.com/slashdotdash/til/blob/master/postgres/ins...
Installing Timescaledb on Mac OS X with Postgres.app https://prathamesh.tech/2020/07/23/installing-timescaledb-on...
Not too long ago, I was asked to work on some analytics project and it required time-series data. I'm not a rockstar programmer and don't really know much about trends. So, I ended up googling and stumble upon InfluxDB. It felt like that right choice and I started playing with it. As the time passed, I realized that it might be a good software and I'm sure people love InfluxDB, but it wasn't the right choice for me. I didn't really like the docs, maybe its good now. And I had the same feeling about query syntax, it felt weird.
I moved to TimescaleDB and never looked back. I have it production for almost 2 months now. 20 tables and over 100Million writes/week. One of things I really liked was staging, I don't use docker and or anything fancy. I have bash script that and it runs on centos box and all timescale extension and postgres database are packaged together.
I was impressed by the timescale compression feature. I wasn't using it earlier because I had to be careful about what columns I need to segmentby. I would love to see some more features but I'm sure timescaledb team is already on it.
What new/other features would you like to see? (Also feel free to join slack.timescale.com or reach out at mike (at) timescale.com)
def get_escaped_measurement_name(user_name): # ... comment omitted
return '"\\"{}\\""'.format(user_name.replace('\\', '\\\\\\\\').replace('"', '\\"').replace('\n', '\\\\\\\\n'))I'll definitely be creating a ListenBrainz account. As a long time last.fm user I occasionally worry about the future of the platform. (There have been long stretches of time where it seems to have been in maintenance mode). You seem to support bulk importing last.fm data right?
We also have a Spotify importer that automatically imports stuff from Spotify, if you use Spotify, I would definitely recommend setting that up.
We're a really small team (all volunteers), so we don't move with as much urgency as I'd like to, but we've been making slow but steady progress over the years.
If you find any rough edges, or have any feedback, I'd be happy to hear, my email is in the HN profile. :)
For example, we have a pretty active Slack channel[0] where you can ask us anything. We've probably given away $$$$ of free support over the years ;-)
I was fully ready to just roll my own partitioned table and gave TimescaleDB a shot. It worked well. There was a bug we ran into, but it was an existing one documented on github and was addressed pretty quickly.
I still like influx, and would use it again but beware of the cardinality issues.
[1] https://medium.com/@valyala/insert-benchmarks-with-inch-infl...
postgres built-in RBAC is clunky or people would be relying on it, but an ecosystem of postgres plugins could include cleaner or smaller versions of this feature.
Even things like complex migrations (github's gh-ost, for example) could exist as DB plugins.
I'm familiar with some basics of kdb and use it often in my day job, but from what I understand that isn't widely used outside of finance?
* ClickHouse (this is a general-purpose OLAP database, but it is easy to adapt it to time series workloads)
* InfluxDB
* TimescaleDB
* M3DB
* Cortex
* VictoriaMetrics
The last three of these TSDBs support PromQL query language - the most practical query language for typical time series queries [1]. So I'd recommend starting from learning PromQL and then evaluating time series databases from the list above.
[1] https://medium.com/@valyala/promql-tutorial-for-beginners-9a...
If you are familiar with Postgres and/or SQL, then you may want to start with TimescaleDB. It's just Postgres for time-series. Full SQL, so it's possible to be productive instantly.
Object objectId objectName other...
Property propertyId objectId FK propertyName other...
Time timeId time other..
Value timeId FK propertyId FK value
Correct me if I'm wrong, but I'm fairly certain you can just write data with the same timestamp again and it gets updated. Deleting is also easily possible.
Another thing that's not mentioned in the post but was a pain point for us was that it's not easy to query for fields with "null" values [1].
I figure a lot of our pain might be because we're not as good at Influx as we are at PostgreSQL. We've been running MusicBrainz[2] for ~18 years on PostgreSQL, that knowledge will hopefully transfer over a little with Timescale.
[0]: https://github.com/influxdata/influxdb/issues/3210
[1]: https://github.com/influxdata/docs.influxdata.com/issues/717
Only works on jailbroken devices but it works well, has a local backup, and has been maintained (by me) for 2 years now.
Server costs are $2.50/mo, so this will stay up as long as I am alive.
I'd assume that most anyone building a system like this at scale has to solve these problems; does everyone roll their own?
Feel free to ask over there :)
(Btw - TimescaleDB is designed to work with Prometheus. You can see more here: https://github.com/timescale/timescale-prometheus)
Here is a page from our docs on how to perform Backup & Restore: https://docs.timescale.com/latest/using-timescaledb/backup
Not sure what's going on in that one Github issue, but we are looking into it.
The warnings are produced by COPY TO, which is used by pg_dump, since COPY TO doesn't copy chunks. It is not an issue for pg_dump, since it also do COPY TO on each chunk table.
Timescale engineer here - was part of discussion about this warning. We need to do another round and see how to remove this confusion.
That issue is now closed by the original author:
"Data is successfully dumped. also i can see the constraints, indexes are also copied successfully."
Does a WAL backup approach work?
https://docs.timescale.com/latest/using-timescaledb/backup
There are hundreds of thousands of TimescaleDB databases in production so this is generally not an issue.
100% opposite of what a CLI interface should be.
Timescale brings its own issues. If your goal is performance, you will be better served by clickhouse.
Plus my actual use case is even more complex, not only do I need something like MAX(temperature) > 10, I need (MAX(temperature)) > 10 && (MAX(temperature) - MAX(dewpoint)) > 4.5).
How do you delete points from a specific measurement in a specific retention policy?
secondly, I don't get where you're coming from faulting a columnar database for using SIMD! why is memcpy better? it comes across as, 'they worked too hard making it fast'!
Timescale builds connector and entire workflow to run Prometheus on top of TimescaleDB and support Grafana in flexible way: https://github.com/timescale/timescale-prometheus
"Data is successfully dumped. also i can see the constraints, indexes are also copied successfully."
`delete from meas_name where time='2020-07-22T15:40:58.375506762Z'` - just tried that and it deleted one row.
While it is indeed a rare occurence, it is also very slow.
Recently my colegue was testing some script and added some huge numbers on metric that is used for one of those reports. We had to delete those tests as customer complained that now his total invoice number jumped to trillions.
# Note: influxdb-python first replaces each backslash in the username with two backslashes
# and because in influx queries, we have to escape each backslash, overall each backslash
# must be replaced by 4 backslashes. Yes, this is hacky and ugly.Don't get me wrong, timescale is a great way to get started with time series - just like sqlite is a great way to get started with databases if all you know is nosql.
However, it quickly brings its own challenges - and the new license is the cherry on the cake: it is locking you down to your own infrastructure unless you want to pay for timescale own SAAS offering (and then prey they do not alter the condition of the deal too much later)
It is just not worth it, unless you have a very small problem, or you can afford to have people concentrating on timescale maintenance - and in this case, you would be getting better bang for bucks by having these people work on clickhouse.
I'm speaking only from my own experience. I have relatively large servers dedicated to time series (about 100T of disk space, between 128 and 256 Gb of RAM). They were going to be retired for even bigger servers. Instead, we experimented with clickhouse on one of the recently decommissioned servers. We could not believe the benchmarks! Moving to clickhouse has improved the performance on about every metric. Yes, it required some minor SQL rewrites, about 1 day of work total, but unless your hardware is free and your queries are set in stone, clickhouse makes more sense.
1. The TSL is not a new license, have had it in place since late 2018. What we recently announced is that multi-node TimescaleDB will be available for free under the TSL (free, source available), while (for example) clustered InfluxDB is purely proprietary (paid, closed source).
2. Our TSL license prevents offering TimescaleDB-as-a-service, it absolutely does NOT prevent you from running/offering a SaaS service or from utilizing cloud services/infra (you say "it is locking you down to your own infrastructure unless you want to pay for timescale own SAAS offering"). Specifically, Timescale offers a pure Apache-2 version and a "Timescale License" (TSL) Community version. For the TSL version, what it primarily restricts is the cloud providers like AWS and Azure from offering TimescaleDB-as-a-service (e.g., TimescaleDB Community on AWS RDS). Many thousands of companies use our community version for free to build SaaS services running on their own AWS instances.
And clickhouse is not. I just suggest skipping the timescaledb step to someone migrating from influx, and going straight to clickhouse.
> For the TSL version, what it primarily restricts is the cloud providers like AWS and Azure from offering TimescaleDB-as-a-service (e.g., TimescaleDB Community on AWS RDS)
If there is some kind of emergency and I need to have the database on the cloud, this is a serious restriction. It limits my choices and constrains my actions.
> Many thousands of companies use our community version for free to build SaaS services running on their own AWS instances.
We have our servers, so it wasn't an issue. It was more of a long term concern, a chilling effect: what else may be restricted in the future?
Again, I think timescaledb has a wonderful place. It will certainly become the entry level database for timeseries.
It is just not suite for our workload.
It won't match the pure scan and computation speed of Clickhouse but the continuous aggregation feature is the recommended approach for querying large datasets (similar to Clickhouse table engines like AggregatingMergeTree).
We've never seen a backup take down a machine. The backups we use are the same as Postgres which are used by millions of companies without a problem (and can be streaming incremental backups like pgBackrest, WAL-E, etc. or whole-database backups like pg_dump). As with any DB you do have to size and configure your database correctly (which these days isn't hard).
We've never seen anybody claim that ClickHouse offers significantly better compression than we do overall. Obviously compression depends heavily on data distribution and I'm sure you could make up a dataset where clickhouse does better (just as you could where TimescaleDB does better). But on real distributions we don't see this at all, we do pretty advanced columnar compression on a per-datatype basis [1], and see median space reduction of 95% from compression across users.
Large queries is a weird claim to make since Postgres has more different types of indexes than Clickhouse and has support for multiple indexes. If you are processing all of your data for all your queries then yes, click house sequential scans may be better. But that's less common, and also where TimescaleDB continuous aggregates come in.
We've seen customers successfully use our single-node version with 100s of billions of rows so claiming that we are just for small use-cases is simply untrue, and especially with the launch of multi-node TimescaleDB.
I understand people may have different preferences and experiences, but some of these felt a bit off to me.
[1] https://blog.timescale.com/blog/building-columnar-compressio...
So we stopped doing backups. Actually, that's how we started using clickhouse: for cold storage, as the files in /var/lib/clickhouse used far less storage space and issues. Eventually the same data was sent both to timescaledb and clickhouse, in a poor's man backup. Finally, timescaledb was removed.
> As with any DB you do have to size and configure your database correctly (which these days isn't hard).
Thanks for supposing we didn't try. We did not end up with 256Gb of RAM per server for no reason.
All I'm saying is that Timescale totally has a place, but not beyond a certain scale and complexity.
> We've never seen anybody claim that ClickHouse offers significantly better compression than we do overall
Altiny does, so do a few others. mandigandham above says that you are now at 70% of what clickhouse does. I'm not saying you're not improving. It was just one of the too many issues we had to fight.
Also, you have only recently introduced compression - good, but I'm not aware if you already offer something like DateTime Codec(DoubleDelta, LZ4), or the choice of compression algorithms. LZ4 can be slow, so there is a choice between various alternatives.
For example, T64 calculates the max and min values for the encoded range, and then strips the higher bits by transposing a 64-bit matrix. Sometimes it makes sense. zStd is slower than T64 but needs to scan less data, which makes up for it. Sometimes it makes more sense.
Large databases need more flexibility.
> If you are processing all of your data for all your queries then yes, click house sequential scans may be better
I confirm, it is better.
And for some workloads, continuous aggregates make no sense.
> We've seen customers successfully use our single-node version with 100s of billions of rows so claiming that we are just for small use-cases is simply untrue, and especially with the launch of multi-node TimescaleDB
I have about 50Tb of data per server. What is below 1Tb I call "small use cases".
> I understand people may have different preferences and experiences, but some of these felt a bit off to me.
When I was trying to use timescaledb and reported weird issues, I had the same return: my use case and bug report felt "off" to the person I reported them to.
Maybe it is why they weren't addressed - or maybe much later, when reported by more clients?
Personally, I have no horse in the game. If you become better than clickhouse for my workload, and if the license change to allow me to deploy to a cluster of AWS servers (just in case we ditch our own hardawre), I will consider timescale again in the future.
For now, I'm watching it evolve, and slowly address the outstanding issues, like disk usage, and performance. By your own admission and benchmarks, you are now at 70% of what clickhouse does - in my experience, the actual difference is much higher.
But I sincerely hope you succeed and catch up, as more software diversity is always better.
On the compression point:
- I believe the Altinity Benchmarks [0] are from 2018, on TimescaleDB 0.12.1. TimescaleDB has gotten much better since then (now on version 1.7.2), and most notably, offers native compression now (it did not then).
- I believe manigandham's 70% comment is more of an offhand estimate and not a concrete benchmark. But perhaps he can weigh in. :-)
- Re: compression algorithms, TimescaleDB now employs several best-in-class algorithms, including delta-delta, gorilla, Simple-8b RLE. Much more than just LZ4. [1]
Overall, I don't think anyone has done a real storage comparison between TimescaleDB and Clickhouse since we launched native compression. It's on our todo list, but we also welcome external benchmarks. But based on what we've found versus similar systems, I suspect our storage usage would be really similar.
[0] https://www.altinity.com/blog/clickhouse-for-time-series
[1] https://blog.timescale.com/blog/time-series-compression-algo...
> If there is some kind of emergency and I need to have
> the database on the cloud, this is a serious restriction.
> It limits my choices and constrains my actions.
> if the license change to allow me to deploy to a cluster
> of AWS servers (just in case we ditch our own hardawre),
You can deploy TimescaleDB on AWS servers (the TSL certainly allows it). Most of our users do. They don't run their own hardware.You can even use our Apache-2 k8s helm charts [1] to immediately spin up a cluster of replicated TimescaleDB nodes with automated leader-election/failover and continuous incremental backup. The helm charts have first-class support for AWS EKS.
What the TSL prevents is _Amazon_ offering TimescaleDB as a paid DBaaS service. To my knowledge, none of the major cloud vendors offer Clickhouse as a first-class paid service, so that's somewhat a moot point. I guess theoretically Amazon could launch Clickhouse-as-a-service, but that theoretical possibility doesn't help you in your emergency.
There are many things I'm willing to tolerate with that level of performance!