I have a very overloaded question that will be har...
# general
h
I have a very overloaded question that will be hard to answer. I know druid excels as analytical storage. The usecase we have is that we need a timeseries database. This will be the primary database and be treated as source of truth. We got regulatory requirement to ensure data correctness, integrity and durability. It will host billions of rows, per day, up to 10 years. Most solution require a very deep dive to uncover some of the limitations which has (very large) cost. Given the scenario, where would the major pain points be if this was druid? For example, my understanding is that there is no WAL, so how does druid recover from a crash?
g
i think you're right, it will be tough to answer a question like this without doing a deep dive, for any system. i will try to give you a pointer about where to look at as you evaluate Druid
when it comes to correctness / integrity / durability on the ingestion and storage side, the main thing to recognize is that all data ingested into Druid is stored in "segment" files on object storage (e.g. S3, HDFS, etc) with pointers to those files in a "metadata store" (typically relational database like cloud-managed MySQL or PostgreSQL). this design is similar to a data lake, and it means that data is just as durable as your underlying object storage. you need to make sure to take periodic backups of your metadata store, but that's about it.
you should think a bit about how data gets ingested into those segment files. there are two ways in Druid: batch and streaming (realtime). with batch, each batch job is essentially an atomic transaction that writes out new segment files. no WAL is needed in this case. if the job fails, you would just retry it with streaming (realtime), we are reading from kafka, and we essentially use kafka as WAL. if the Druid task reading from kafka fails, then after it restarts, it will resume reading from the last committed checkpoint. our design commits checkpoints to the Druid metadata store itself, which achieves exactly-once ingestion.
a
If you are looking for a big data solution to store timeseries data, I would suggest that you also look at HBase if you have access to a Hadoop cluster. We store timeseries data in it (millions of points per day) and it works fantastically well. It even supports multi-cluster replication for failover/resiliency. You can look at OpenTSDB as an example of how to store timeseries data in HBase.
h
Thank you @Gian Merlino for taking the time to reply.
when it comes to correctness / integrity / durability on the ingestion and storage side, the main thing to recognize is that all data ingested into Druid is stored in "segment" files on object storage (e.g. S3, HDFS, etc) with pointers to those files in a "metadata store" (typically relational database like cloud-managed MySQL or PostgreSQL).
In case when S3 is the storage mechanism, wouldn't writing every segment create a TPS bottleneck? In the official documentation it is mentioned that segments are pushed to deep storage (eg s3) after they are constructed. I cannot find where they are stored before they are pushed to S3. This is the part that I'm most concerned about in terms of durability
m
@HEPBO3AH Are you thinking of using batch ingestion or streaming ingestion? For batch ingestion, while writing the segments, they are not queryable so the storage (while writing the segment) doesn’t matter. They will only be queryable once they are pushed to S3 and Druid historical nodes download them. For realtime ingestion, while writing the segments, they are stored on the ingestion tasks (Peon, K8 pod, etc) and are available for query right away. You can increase durability by setting the
replicas
setting on SupervisorSpec.
g
Loss of segments before pushing to S3 doesn't affect long-term durability, because: • for batch ingest, the expectation is whatever is driving the ingest (Airflow, etc) will retry any failed batch ingest jobs. • for streaming (realtime) ingest, we will re-read whatever is lost from upstream (Kafka or Kinesis) automatically.
It affects short-term durability for streaming (realtime). If the Druid server reading from Kafka fails, there will be some period of time where some recent data becomes unavailable. But it will be re-read from Kafka automatically, so that's why long-term durability is not a problem. And as @Maytas Monsereenusorn says there is a
replicas
feature to mitigate even short-term durability concerns
Although many people run with
replicas: 1
b/c they're mostly concerned about long-term durability, and
replicas: 1
is enough to get long-term durability
In case when S3 is the storage mechanism, wouldn't writing every segment create a TPS bottleneck?
for this- we avoid bottlenecks by making the segments relatively large. typically a segment has 3–6 million rows in it
m
Another thing to add... You can also set replication per each datasource on the Retention (Load/Drop) rules. This can replicate the segments on more than one Historical nodes. This make sure that if a Historical node goes down, your data is still available. (Historical node pulls down data from S3 and make them available for query). However, one pain point we have (@Gian Merlino Please let me know if I am overlooking something) is that if many historical nodes are down due to OOM caused by a query, the replication may not be enough. For example, some topN, or timeseries data can caused a wide spread oom. When this happens, query will still return successful querying whatever data is left on the remaining UP historical nodes. This can be a data integrity issue as we do not know that data is missing (query still returns 200). There was a PR to address this: https://github.com/apache/druid/pull/13967 but it was closed (@Gian Merlino do you know why we abandon the PR?)
g
hmm, i'm not sure what happened with that one… it looks like it lost steam
at any rate, that would definitely be a short-term unavailability issue; the data in this case is still there (on S3) and would be restored when the historicals are back online
m
restored when the historicals are back online
That can take some time (~30mins for us with our 4-7TB per historical). During that time, you would have query returning incorrect query results (missing data, gaps, etc.). You can setup alert from Druid metrics to detect when Historicals are down and/or segments are unavailable though.
g
yeah, that's true. i am just trying to be clear about whether any particular data consistency/integrity issue is temporary or permanent
👍 1
this one would be temporary (although as you point out "temporary" can be many minutes)
it would occur if you have widespread crashes/failures of historical servers and would be recovered when the historicals are all back online
m
yep. agree
h
> • for batch ingest, the expectation is whatever is driving the ingest (Airflow, etc) will retry any failed batch ingest jobs. Would you know if the
flush & fsync
is called before the 200 is returned to ensure that the data in the buffer is written to the disk?
g
for Druid, durability is achieved via object storage, not local storage (local storage is always assumed by Druid to be non-durable)
💯 1
so we don't use
fsync
because the local storage isn't expected to be durable anyway
to answer the spirit of your question: for batch ingest, we do confirm the S3 PUT actually happened before the ingestion task returns SUCCESS
✅ 1