Live data from Hacker News

Kafka at the low end: how bad can it get?

broot.ca

81–90 of 144 posts

Re: Kafka at the low end: how bad can it get?

#81
post #19

Earlier quoted context omitted.

Why is that an anti-pattern? Databases have added `SKIP LOCKED` and `SELECT FOR UPDATE` to handle these use cases. What are the downsides?

as with everything, it depends on how you're processing the queue. eg we built a system at my last company to process 150 million objects / hour, and we modeled this using a postgres-backed queue with multiple processes pulling from the queue. we observed that, whenever there were a lot of locked rows (ie lots of work being done), Postgres would correctly SKIP these rows, but having to iterate over and skip that many…

How did you get from original post of "low level of load" to overengineering for "150 million objects/hr".

Is the concept of having different solutions for different scales not familiar to you?

Re: Kafka at the low end: how bad can it get?

#82

Earlier quoted context omitted.

I don’t know why but I could wear you are German (and old)

I like working with folks that know a good pint, and value workmanship. If you are inferring someone writing software for several decades might share, than one might want to at least reconsider civility over ones ego. Best of luck =3

Neither being German or old are bad values from my point of view. But you tried a bit hard to flex with your past experiences tbh...

Re: Kafka at the low end: how bad can it get?

#83

What do people recommend? Especially for low levels of load, that doesn't require that the dispatcher and consumer are written in the same language.

Kafka with a different partitioner would have worked fine. The problem was that the web workers loaded up the same partition. Randomising the chosen partition would have removed, or at least alleviated, the stated problem.

Re: Kafka at the low end: how bad can it get?

#84
What that post describes (all work going to one/few workers) in practice doesn't really happen if you properly randomize (e.g. just use random UUID) ID of the item/task when inserting it into Kafka.

With that (and sharding based on that ID/value) - all your consumers/workers will get equal amount of messages/tasks.

Both post and seemingly general theme of comments here is trashing choice of Kafka for low volume.

Interestingly both are ignoring other valid reasons/requirements making Kafka perfectly good choice despite low volume - e.g.:

- multiple different consumers/workers consuming same messages at their own pace

- needing to rewind/replay messages

- guarantee that all messages related to specific user (think bank transactions in book example of CQRS) will be handled by one pod/consumer, and in consistent order

- needing to chain async processing

And I'm probably forgetting bunch of other use cases.

And yes, even with good sharding - if you have some tasks/work being small/quick while others being big/long can still lead to non-optimal situations where small/quick is waiting for bigger one to be done.

However - if you have other valid reasons to use Kafka, and it's just this mix of small and big tasks that's making you hesitant... IMHO it's still worth trying Kafka.

Between using bigger buckets (so instead of 1 fetch more items/messages and handle work async/threads/etc), and Kafka automatically redistributing shards/partitions if some workers are slow ... You might be surprised it just works.

And sure - you might need to create more than one topic (e.g. light, medium, heavy) so your light work doesn't need to wait for heavier one.

Finally - I still didn't see anyone mention actual real deal breakers for Kafka.

From the top of my head I recall a big one is no guarantee of item/message being processed only once - even without you manually rewinding/reprocessing it.

It's possible/common to have situations where worker picks up a message from Kafka, processes (wrote/materialized/updated) it and when it's about to commit the kafka offset (effectively mark it as really done) it realizes Kafka already re-partitioned shards and now another pod owns particular partition.

So if you can't model items/messages or the rest of system in a way that can handle such things ... Say with versioning you might be able to just ignore/skip work if you know underlying materialized data/storage already incorporates it, or maybe whole thing is fine with INSERT ON DUPLICATE KEY UPDATE) - then Kafka is probably not the right solution.

Re: Kafka at the low end: how bad can it get?

#85

Kafka for small message volumes is one of those distinct resume-padding architectural vibes.

Don't disagree on the resume-padding but only taking into account message volume and not the other features is also not the best way to look at it.

Have I used (not necessarily decided on) Kafka in every single company/project for the last 8-9 years? Yes.

Was it the optimal choice for all of those? No.

Was it downright wrong or just added for weird reasons? Also no, not even a single time - it's just kinda ubiquitous.

Re: Kafka at the low end: how bad can it get?

#86

What that post describes (all work going to one/few workers) in practice doesn't really happen if you properly randomize (e.g. just use random UUID) ID of the item/task when inserting it into Kafka. With that (and sharding based on that ID/value) - all your consumers/workers will get equal amount of messages/tasks. Both post and seemingly general theme of comments here is trashing choice of Kafka for low volume. Inte…

The other thing that's PITA with Kafka is fail/retry.

If you want to continue processing other/newer items/messages (and usually you do), you need to commit Kafka topic offset - leaving you to figure out what to do with failed item/message.

One simple thing is just re-inserting it again into the same topic (at the end). If it was temps transient error that could be enough

Instead of same topic, you can also insert it into another failedX Kafka topic (and have topic processed by cron like scheduled task).

And if you need things like progressive backing off before attempting reprocessing - you liekly want to push failed items into something else.

While it could be another tasks system/setup where you can specify how many reprocessing attempts to make, how much time to wait before next attempt ...etc. Often it's enough to have a simple DB/table.

Re: Kafka at the low end: how bad can it get?

#87
post #69

The kafka protocol is a distributed write ahead log. If you want a job queue you need to build something on top of that, it’s a pretty low level primative.

Why does everybody keep missing this point? I don’t know.

There's a wonderful Kafka Children's book that I always suggest every team I work with read: https://www.gentlydownthe.stream/

The way I describe Kafka is, "an event has transpired... sometimes you care, and choose to take an action based on that event"

The way I describe RabbitMQ is, "there's a new ticket in the lineup... it needs to be grabbed for action or left in the lineup... or discarded"

Definitely not perfect analogies. But they get the point across that Kafka is designed to be reactive and message queues/job queues are meant to be more imperative.

Re: Kafka at the low end: how bad can it get?

#88
post #2

thankfully early access for KIP-932 is coming in 1-3 weeks as the 4.0.0 release gets published

TFA mentions it in the third paragraph:

> Note: when Queues for Kafka (KIP-932) becomes a thing, a lot of these concerns go away. I look forward to it!

Re: Kafka at the low end: how bad can it get?

#89

What that post describes (all work going to one/few workers) in practice doesn't really happen if you properly randomize (e.g. just use random UUID) ID of the item/task when inserting it into Kafka. With that (and sharding based on that ID/value) - all your consumers/workers will get equal amount of messages/tasks. Both post and seemingly general theme of comments here is trashing choice of Kafka for low volume. Inte…

(Author here)

You say: > What that post describes (all work going to one/few workers) in practice doesn't really happen if you properly randomize (e.g. just use random UUID) ID of the item/task when inserting it into Kafka.

I would love to be wrong about this, but I don't _think_ this changes things. When you have few enough messages, you can still get unlucky and randomly choose the "wrong" partitions. To me, it's a fundamental probability thing - if you roll the dice enough times, it all evens out (high enough message volume), but this article is about what happens when you _don't_ roll the dice enough times.

Re: Kafka at the low end: how bad can it get?

#90

What do people recommend? Especially for low levels of load, that doesn't require that the dispatcher and consumer are written in the same language.

Until you hit scale, the database you're already using is fine. If that's Postgres, look up SELECT FOR UPDATE SKIP LOCKED. The major convenience here - aside from operational simplicity - is transactional task enqueueing. For hosted, SQS or Google Cloud Tasks. Google's approach is push-based (as opposed to pull-based) and is far and above easier to use than any other queueing system.

I'm probably biased, but in the number of cases where I had to work with Kafka, I'd really prefer to simply have an SQL database. In all of those cases I struggled to understand why developers wanted Kafka, what problem was it solving better than the database they already had, and for the life of me, there just wasn't one.

I'm not saying that configuring and deploying databases is easy, but it's probably going to happen anyway. Deploying and configuring Kafka is a huge headache: bad documentation, no testing tools, no way to really understand performance in the light of durability guarantees (which are also obscured by the poor quality documentation). It's just an honestly bad product (from the infra perspective): poor UX, poor design... and worst of all, it's kind of useless from the developer standpoint. Not 100% useless, but whatever it offers can be replaced by other existing tools with a tiny bit of work.

Post reply on HN