News for hackers. Stuff that matters.
Re:Using ClickHouse to scale an events engine by joshstrange on Thursday April 11, 2024 @03:25PM (#40005842)
I feel like with all the Clickhouse praise on HN that we /must/ be doing something fundamentally wrong because I hate every interaction I have with Clickhouse.

* Timeouts (only 30s???) unless I used the cli client

* Cancelling rows - Just kill me, so many bugs and FINAL/PREWHERE are massive foot-guns

* Cluster just feels annoying and fragile don't forget "ON CLUSTER" or you'll have a bad time

Again, I feel like we must be doing something wrong but we are paying an arm and a leg for that "privilege".

Re:Using ClickHouse to scale an events engine by zX41ZdbW on Thursday April 11, 2024 @03:54PM (#40006130)
Interesting about "Timeouts (only 30s???)" - most likely, this is a limitation configured explicitly for a user on your server. You can set it up with the `max_execution_time`, and by default, it is unlimited.

For example, I've set it up, along with many more limitations for my public playground https://play.clickhouse.com/, and it allows me to, at least, make it public and not worry much.

It could also be a configuration of a proxy if you connect through a proxy. ClickHouse has built-in HTTP API, so you can query it directly from the browser or put it behind Cloudflare, etc... Where do you host ClickHouse?

Re:Using ClickHouse to scale an events engine by joshstrange on Thursday April 11, 2024 @04:00PM (#40006204)
I can believe it's a config issue, I'll have to look into it. I didn't setup the cluster/dbs and when I asked about I was told "use the cli". I'll try to see if I can get that fixed.
Re:Using ClickHouse to scale an events engine by michaelbuckbee on Thursday April 11, 2024 @10:47PM (#40008947)
Any chance you CH is proxied through a Heroku app? Heroku has 30s timeouts.
Re:Using ClickHouse to scale an events engine by nsguy on Thursday April 11, 2024 @03:39PM (#40005983)
What is your use case? If you're deleting rows that already feels like maybe it's not the intended use case. I think about clickhouse as taking in a firehose of immutable data that you want to aggregate/analyze/report on. Let's say a million records per second. I'll make up an example, the orientation, speed and acceleration of every Tesla vehicle in the world in real time every second.
Re:Using ClickHouse to scale an events engine by joshstrange on Thursday April 11, 2024 @03:51PM (#40006107)
It's to power all our analytics. We ETL data into it and some data is write-once so we don't have updates/deletes but a number of our tables have summary data ETL'd into them which means cleaning up the old rows.

I'm sure CH shines for insert-only workloads but that doesn't cover all our needs.

Re:Using ClickHouse to scale an events engine by nsguy on Thursday April 11, 2024 @04:37PM (#40006561)
You can always use different databases for different use cases.

There are many applications that require extremely high insertion rates (millions of records per second), very large total number of rows (billions, trillions) and flexible/fast querying/aggregation with high read rates (100's of millions or higher rows/s) and that's sort of the sweet spot IMO for ClickHouse and where you'll be pressed to find alternatives. I'm sure it can be used in other situations but maybe there are more choices if you're in those.

Re:Using ClickHouse to scale an events engine by bigger_cheese on Thursday April 11, 2024 @07:21PM (#40007860)
>You can always use different databases for different use cases.

Unfortunately this is not always realistic, especially in large organizations, I know where I am there is a big push from top (i.e the IT budget people) to standardize everything they want to simplify licenses, support contracts etc.

I may not be doing cutting edge stuff (I work at an Industrial plant) but we do have mixed data use cases where it could be beneficial to use different dbs but realistically I don't see it happening.

Re:Using ClickHouse to scale an events engine by mosen on Thursday April 11, 2024 @03:58PM (#40006178)
Have you looked into the ReplacingMergeTree table engine? (Although we still needed to use FINAL with this one)
Re:Using ClickHouse to scale an events engine by hipadev23 on Thursday April 11, 2024 @04:07PM (#40006280)
CH works just fine for cleaning up rows: Delete with mutations sync=1, or use optimize with deduplicate by, or use aggregate trees and optimize final, or query aggregate tables with final=1.

Numerous ways to achieve removal of old/stale rows.

Re:Using ClickHouse to scale an events engine by darthShadow on Thursday April 11, 2024 @05:43PM (#40007127)
You have already gotten excellent options from the other comments, but here's another one that's not been mentioned yet.

You may want to consider adjusting your partition key (if feasible) as a function of datetime so you can just drop a complete partition when required, rather than needing separate delete queries.

In my experience, it has proven to be a very quick and clean way to clear out older data.

Re:Using ClickHouse to scale an events engine by unixhero on Thursday April 11, 2024 @06:19PM (#40007398)
Tableau
Re:Using ClickHouse to scale an events engine by myrloc on Thursday April 11, 2024 @07:04PM (#40007751)
Sounds like you need to use a ReplacingMergeTree + final keyword.
Re:Using ClickHouse to scale an events engine by alecfong on Thursday April 11, 2024 @04:18PM (#40006394)
What foot guns have you run into with FINAL?
Re:Using ClickHouse to scale an events engine by joshstrange on Thursday April 11, 2024 @04:34PM (#40006529)
Just forgetting to use it or PREWHERE. Since queries run just fine without those you can think you have something working when you actually have duplicate rules.
Re:Using ClickHouse to scale an events engine by ergonaught on Thursday April 11, 2024 @03:54PM (#40006131)
Most, though certainly not all, problems I see with ClickHouse usage come from pretending it is another database or that it is intended for other use cases.
Re:Using ClickHouse to scale an events engine by shin_lao on Thursday April 11, 2024 @03:50PM (#40006078)
It's meant to store immutable data, and isn't great if you need low-latency updates. Also it's quirky in some ways.
Re:Using ClickHouse to scale an events engine by joshstrange on Thursday April 11, 2024 @03:53PM (#40006126)
> It's meant to store immutable data

I don't disagree, I feel like we might be using it wrong. We were trying to replace ES with it but it just doesn't feel like it fits our needed usecase.

Re:Using ClickHouse to scale an events engine by shin_lao on Thursday April 11, 2024 @03:59PM (#40006192)
How many rows do you have on average per day?
Re:Using ClickHouse to scale an events engine by joshstrange on Thursday April 11, 2024 @04:10PM (#40006326)
A couple million (<10M), I don't have a better number available right now. Not all (or even most) of those need cancelling rows thankfully.
Re:Using ClickHouse to scale an events engine by hipadev23 on Thursday April 11, 2024 @04:18PM (#40006393)
You don’t need a cluster nor should you be having any issues you mentioned. I run 10x that volume daily on a single gcp box (8 core / 64GB). We migrated off BigQuery and went from $10k/mo to about $250/mo. And it’s faster for both low-latency and big slow queries.
Re:Using ClickHouse to scale an events engine by joshstrange on Thursday April 11, 2024 @04:35PM (#40006537)
The plan is to 10x that volume in the not too distant future but given what you've said I can believe we are horribly over-provisioned/over-scaled. Thank you!
Re:Using ClickHouse to scale an events engine by hipadev23 on Thursday April 11, 2024 @04:42PM (#40006599)
It sounds like you’re probably using Clickhouse Cloud? If so, I was not impressed. Overly pushy sales people, pricing isn’t competitive, and they’re trying to cater to the snowflake/databricks crowd without smoothing any rough edges (like the default timeout being enabled on a GUI).

Overall I’d say CH isn’t as tolerant or forgiving as BigQuery, Snowflake, or Databricks. You can write the worst SQL possible and BQ will happily charge you $5/TB for that cartesian self-join. CH meanwhile will error with memory limit or even crash.

Re:Using ClickHouse to scale an events engine by joshstrange on Thursday April 11, 2024 @04:45PM (#40006631)
We are using Altinity. I believe it's a 3-server cluster and we have 2 clusters (our prod one and another one we are trying to promote to production once our data integrity checks pass, at which point we will spin the other down).
Re:Using ClickHouse to scale an events engine by hipadev23 on Thursday April 11, 2024 @04:51PM (#40006685)
Robert Hodges of Altinity will likely be here shortly, they monitor HN for any mention of clickhouse, maybe they can get you fixed up without their standard $10k/mo support contract.
Re:Using ClickHouse to scale an events engine by hodgesrm on Friday April 12, 2024 @03:20AM (#40010166)
Hi Josh, sorry to hear about the issues. Sounds like things that should be solvable. ClickHouse does require thinking a bit differently from other stores like BigQuery. I sent you an email. Feel free to contact me at the email posted on my HN account. Looking forward to helping you bend ClickHouse to your will.
Re:Using ClickHouse to scale an events engine by citrin_ru on Thursday April 11, 2024 @06:37PM (#40007533)
> * Timeouts (only 30s???) unless I used the cli client

Almost all clients (client libraries) allow a configurable timeout. In server settings there is a max query time settings which can be adjusted if necessary: https://clickhouse.com/docs/en/operations/settings/query-com...

Re:Using ClickHouse to scale an events engine by orf on Thursday April 11, 2024 @08:42PM (#40008309)
From the docs on FINAL:

> However, using FINAL is sometimes necessary in order to produce accurate results

Welp.

Re:Using ClickHouse to scale an events engine by FridgeSeal on Thursday April 11, 2024 @10:03PM (#40008747)
If you use tables like “ReplacingMergeTree” which _explicitly_ states that merges happen in the background, and non-merged rows _will_ be visible.

It’s a table design optimised for specific workloads, and the docs and design detail those tradeoffs.

We use it at work for workloads that can tolerate “retreading” over stale data, because it means they can efficiently write to the db without round tripping, or locking and row updates, and without the table growing massive. It works fantastically in our use case.