133 points · by pul · 5y ago · 72 comments
I wonder if Kafka represents an existential angst in these Kubernetized Microservice times. Or is it more simply I am just too dumb to learn and use this shit correctly.
But there are times when you have a problem, and amongst the possible solutions is Kafka.
I've come across Kafkaesque problems only three times in the last seven years: a hosting platform that had to parse logs of over 700 WordPress sites for security and other businesslogic. Putting all events of a financial app backend into datalakes and filtering and parsing all openstreetmap changesets live.
No more daily SQL dumps from offshore to onshore and big batch procedures to genereate outdated events.
For me, Kafka sits in the same area of solutions as Kubernetes, Hadoop clusters, or anything "webscale": you don't need it. Untill you do, but by then you'll (i) have Serious Problems which such systems solve and (ii) the manpower and budgets to fix them.
With which I don't mean to avoid Kafka at all costs. By all means, play around with it: if anything, the event-driven will teach you things that make your a better Rails/Flask/WordPress developer if that is what you do.
Maybe a few use cases could be switched out for direct API calls, but I think Kafka hits the sweet spot in many situations.
What alternatives would you be looking at?
* Just keep your architecture a monolith. You'll do fine the majority of the cases.
* Event-sourcing doesn't require Kafka clusters. Nor do event-driven setups. You don't need complex tooling to pass around strings/json-blurps. An S3 bucket or a Postgresql database storing "Events-as-json" is often fine.
* Postgres can do most of what you need (except for the "webscale" clustering etc)[0] in practice already.
* Redis[1]
My main point is that while Kafka is a fantastic tool, you don't need that tool to achieve what you want in many cases.
> It seems as good a way as any to decouple systems
IMO relying on a tool to achieve a good software design, rather than design-patterns, is a recipe for trouble. If anything, because it locks you in (do you suddenly get a tightly coupled system if you remove Kafka?) or because its details force you into directions that don't naturally fit your domain or problem.
--
[0] https://spin.atomicobject.com/2021/02/04/redis-postgresql/ [1] https://redis.com/redis-best-practices/communication-pattern... etc.
Kafka is one of those systems that needs to be justified by out-scaling other solutions that don't come wedded with all its baggage.
MY problems are so special that my use of Kafka was perfect, but YOURS are trivial and you shouldn’t even consider Kafka.
Want to store data, query it in arbitrary and hard to foresee ways and also want to easily tune performance for these queries? Relational datastore it is.
Want to have ACID? Well, relational datastore it is.
Kafka is not the right solution for these problems.
I mean, whoever in their right mind would want to:
- have a snapshot of data
- query data, including ad-hoc querying
- query related data
- have trasactional updates to data
When all you need is an unbounded stream of data that you need to traverse in order to do all these things.
Being able to see a snapshot is good, and I would hope to see a higher-level abstraction that can offer that on top of something Kafka-like. But making the current state the primary thing is a huge step backwards, especially when you don't get a history at all by default.
> - query data, including ad-hoc querying
OK, fair, ad-hoc queries are one thing that relational databases are legitimately good at. Something that can maintain secondary indicies and do query planning based on them is definitely useful. But you're asking for trouble if you use them in your live dataflow or allow ad-hoc queries to write to your datastore.
> - have trasactional updates to data
I do think this one is genuinely a mistake. What do you do when a transaction fails? All of the answers I've heard imply that you didn't actually need transactions in the first place.
One of those things being “store it in a relational model” or “write a sum to a key value store” or something else.
This ability comes for free with Kafka, but is very not-free when using a relational model.
But it's interesting to compare his factorio style to mine. Or my factorio style to my regular programming style. They're very different.
It also only reflects one of the many tasks a developer usually does as an employee, that is creating algorithms. For a senior developer, that's probably not an apt task for differentiation, because it's quite bounded.
[1] https://github.com/edenhill/librdkafka [2] https://github.com/Shopify/sarama
Related HN discussion of this [1]
But yeah, parallel programming is easy to explain with Factorio.
Who in their right mind would conflate the two