News for hackers. Stuff that matters.
Re:Publishing with Apache Kafka at The New York Times by cookiecaper on Wednesday September 06, 2017 @01:27PM (#15185450)
>We need the log to retain all events forever, otherwise it is not possible to recreate a data store from scratch.

SIGH. Cue the facepalm, head in hands, etc.

I'm not going to get into a big thing here. But if you find yourself saying "I need to keep this thing forever no matter what" and then you try to use something that even entertains the notion of automatic eviction/deletion semantics as the system of record, you're doing it wrong.

Not to burst the bubble of the techno-hipsters, but Kafka is "durable" relative to message brokers like RabbitMQ, not relative to a system actually designed to store decades of mission-critical data. Those systems are called "RDBMS".

Elsewhere in the article he says that they have less than 100GB of data and that it's mostly text. This is massive overarchitecture that isn't even covering the basic flanks that it thinks it is, such as data permanence.

I would really like to read the article that discusses why Postgres or MySQL couldn't have served this purpose equally well.

Re:Publishing with Apache Kafka at The New York Times by _lex on Wednesday September 06, 2017 @01:41PM (#15185581)
I think the POV he's taken is that the kafka stream is the one true datasource (for all time), with all other dbs being derivatives. This insane strategy seems to be over engineered to get around db migrations... though i'm sure the event stream will also change over time, and he'll have to write migration-like code anyways.
Re:Publishing with Apache Kafka at The New York Times by LgWoodenBadger on Wednesday September 06, 2017 @04:07PM (#15186699)
There's not just one reason for it.

Kafka lets dependent consumers transform that data into whatever model is appropriate for their use case. There's no one-size-fits-all E-R model for data for all use cases.

It's not just working around db migrations. It's also providing you with the ability to model the data as many ways as you require. How else would you do it, materialized views? How often are they materialized? Regular views? How performant are they?

There are many benefits to this approach, and a lot of them require a different way of thinking. It's a different paradigm.

Re:Publishing with Apache Kafka at The New York Times by dreamfactored on Wednesday September 06, 2017 @04:29PM (#15186885)
Isn't that just skinny model, fat client?
Re:Publishing with Apache Kafka at The New York Times by rhizome on Wednesday September 06, 2017 @03:58PM (#15186641)
If datasource engineers are for some reason implementing "ontogeny recapitulates phylogeny," they won't be creating migration-like code, they'll be writing ETL filters. Break out your Members Only jackets!
Re:Publishing with Apache Kafka at The New York Times by bognition on Wednesday September 06, 2017 @01:35PM (#15185528)
OOC what makes a RDBMS more durable that a Kafka? Both of them are systems for representing data on disk. I'd love to hear why one representation system is better at disaster recovery than another.
Re:Publishing with Apache Kafka at The New York Times by cookiecaper on Wednesday September 06, 2017 @01:49PM (#15185640)
In Postgres, I never have to worry that the server will be accidentally loaded with `retention.bytes` or `retention.days` set too low and, as a result, choose to delete everything in the database, generating a wholly artificial "disaster" that can result in long periods of disruption or downtime (at a minimum; worst case is permanent data loss).

It is true that someone could issue `DROP DATABASE`, `rm -rf` the filesystem on the database server, or so forth, so my point is not that other systems are invincible. It's just that a properly-configured RDBMS is designed to take data integrity extremely seriously and provides numerous failsafes and protective mechanisms to try to ensure that any data "loss" is absolutely intentional.

On a RDBMS, things like foreign key constraints prevent deletion of dependent records, mature and well-defined access control systems prevent accidental or malicious record alteration, concurrency models and transactions keep data in a good state, etc. Kafka, on the other hand, is designed to automatically and silently delete/purge data whenever a couple of flags are flipped.

That is not a flaw in Kafka itself; it's designed to do that so that you don't have to interrupt your day and purge expired/old/processed data all the time. It's a flaw in architectures that misinterpret Kafka's log paradigm as a replacement for a real data storage/retrieval/archive system.

I've had this argument countless times with people who've tried to use RabbitMQ as a system of record (if only for a few minutes while the messages sat in queue). There's just some fundamental disconnect for a lot of developers where they don't understand that something accepting the handoff doesn't mean that the data is inherently safe.

Re:Publishing with Apache Kafka at The New York Times by lima on Wednesday September 06, 2017 @03:25PM (#15186401)
Kafka is a fine replacement for a RDBMS if it fits your particular use case. It has very strong data consistency guarantees - stronger than most RDBMS - if you configure it properly (acks=1 et al). It won't even lose data if the leader of a partition crashes during a commit.

It has been explicitly designed for these use cases and even has features like compaction:

https://kafka.apache.org/documentation/#compaction

Now, I agree with you that in most cases, using Kafka as your primary data store instead of a RDBMS is madness - but that doesn't mean it's a bad idea in general.

Re:Publishing with Apache Kafka at The New York Times by dreamfactored on Wednesday September 06, 2017 @04:31PM (#15186902)
Isn't that what 'in general' means?
Re:Publishing with Apache Kafka at The New York Times by tlberglund on Wednesday September 06, 2017 @10:36PM (#15188770)
I don't mean to be cavalier about misconfiguration, but it's not like the retention period is the Sword of Damocles. It's a configuration setting, and Kafka honors it reliably. As other commenters have pointed out, there are other bad things you can do to cause data loss with any system no matter how hard you try. These stories will continue to grace post-mortem blog posts long after we are gone, but stories of Kafka accidentally not retaining data do not seem to be thick on the ground. Any non-trivial system has its rough edges, but this just doesn't seem to be one of them for Kafka.
Re:Publishing with Apache Kafka at The New York Times by skybrian on Wednesday September 06, 2017 @02:51PM (#15186141)
So, remove the flag that you'll never use and recompile?

I'm not sure this is worse than using a Unix box with a working "rm" command.

Re:Publishing with Apache Kafka at The New York Times by cookiecaper on Wednesday September 06, 2017 @03:07PM (#15186263)
For what it's worth, I've known sysadmins who strip their boxes to the bones and take pains to ensure that the "rm" command won't be able to be accidentally invoked, primarily by ensuring it doesn't exist on the box. They carry their utilities from box to box, and take them with them when they leave.

That said, any slightly-sane permission or access control scheme, including the defaults mandated by almost all RDBMS distributions (which want a system user dedicated to their use), would make it rather difficult to rm the database folder. Just opening a shell to a RDBMS's underlying server should be a rare event in itself, to say nothing of actually elevating to root, or running a sloppy/careless rm command that is uncaught by the numerous potential failsafes that sysadmins have been installing for decades now (constraining superuser access to a pre-defined set of commands, for example).

Again, the point is not that RDBMS systems are invincible. It's just that they're much sturdier, and actually designed to serve this purpose.

In what universe is "Well, hack out the dangerous parts" a reasonable answer? Talk about reckless disregard for data integrity! Do you really want to use Kafka that bad that you'd develop, maintain, and thoroughly test a custom patchset that circumvents its eviction routines, rather than just using the systems that already excel at not deleting stuff?

Secondly, eviction is a core part of a message queue's design, on purpose. It's actually a needed thing, and while I'm not a Kafka dev, I seriously doubt that it's so simple that a single flag can be disabled and we can move on.

Re:Publishing with Apache Kafka at The New York Times by skybrian on Wednesday September 06, 2017 @04:52PM (#15187047)
Disabling a flag is likely a one-line change, assuming a reasonable flag library. But yes, maintaining a custom fork at all is not something to take on lightly. It would make more sense to talk to the Kafka developers about how to make it safer to use in this scenario.
Re:Publishing with Apache Kafka at The New York Times by scaryclam on Wednesday September 06, 2017 @01:51PM (#15185652)
From what I can tell, Kafka isn't designed for long term data storage. RDBMS systems are designed for this.

Kafka is more for streaming data and events, so I'd probably be uncomfortable assuming that it won't do something and "tidy up" my very old data at some point in the future. Since it's supposed to do this from time to time out of the box, you'd have to be very careful not to let anyone tweak the custom config to revert back to this behaviour. RDBMS won't delete things unless you tell it to more explicitly.

While I think storing things in Kafka is fine generally, there's no way I'd not have a more perminant store of the data somewhere so that I can recreate the Kafka data store if I need to. I'm not sure why they're not just using a boring old DB for that purpose. Perhaps they have a reason, but it's not obvious to me.

Re:Publishing with Apache Kafka at The New York Times by miguno on Wednesday September 06, 2017 @03:34PM (#15186473)
Kafka can perfectly keep your data around forever. The only limitation is available disk space (and databases have the same limitation). I'm not implying that it is always the best idea to use Kafka as a long-term storage solution, but likewise a database isn't the silver bullet here either.

> so I'd probably be uncomfortable assuming that it won't do something and "tidy up" my very old data at some point in the future

Kafka doesn't "tidy up" your data unless it is configured to do so. What's true is that, by default, Kafka will keep your data around for a week "only" but that's a configuration. And most people change it to whatever fits their use case (some lower it to a few hours, some increase it to months or years; others configure it to keep data around forever, typically in combination with Kafka's so-called "log compaction" functionality).

> Since it's supposed to do this from time to time out of the box, you'd have to be very careful not to let anyone tweak the custom config to revert back to this behaviour. RDBMS won't delete things unless you tell it to more explicitly.

The DBAs I worked with would now say "Hold my beer..." ;-)

> While I think storing things in Kafka is fine generally, there's no way I'd not have a more perminant store of the data somewhere so that I can recreate the Kafka data store if I need to.

What's interesting is that more and more users (from my experience) are actually beginning to treat Kafka as the source of truth, and rather recreate other data stores -- like RDBMS, Elastic indexes, etc. -- from it. If you like RDBMS, you can think of Kafka as the DB's transaction log.

IMHO a lot of these discussion is about personal preferences, the situation that you are in (cough legacy cough), team skills, etc. There are often good reasons to use Kafka rather than RDBMS (in this context) but also vice versa, or completely different technologies of course (like blob stores, e.g. S3).

Re:Publishing with Apache Kafka at The New York Times by cookiecaper on Wednesday September 06, 2017 @09:09PM (#15188424)
>Kafka can perfectly keep your data around forever.

In the sense that you can fiddle with it to the point where it doesn't purge things automatically, sure. But RDBMS provides more than the promise that it won't delete your data after a set period of time. If that was all we needed, any filesystem from the last 3 decades would serve fine as a "permanent datastore".

MySQL has gone through a lot of grief to get to the point where it's safe out of the box. This is important. There are many conceivable situations where an unsafe default can accidentally get worked back into things. At least MySQL has never had a default that truncated databases (afaik)...

>The DBAs I worked with would now say "Hold my beer..." ;-)

No one's claiming that RDBMS are invincible, but they do provide numerous features specifically designed to minimize data loss and corruption. You can read more about these in the documentation of any major RDBMS. I've mentioned some specifically elsewhere in this thread, but don't want to keep repeating the same things.

>IMHO a lot of these discussion is about personal preferences, the situation that you are in (cough legacy cough), team skills, etc.

No offense, but this just shows your ignorance of the functionality that you're leaving on the table by considering SQL a cough-legacy-cough solution. We discussed above that "can be configured to not delete things despite defaults and assumptions" is much different from "safe long-term data storage is a major design concern".

A messaging queue does not and should not have the same semantics, because it's not intended to keep decades' worth of data, even though it may be possible to avoid the database's eviction routine. We don't have to abuse something just because the developers haven't gone to lengths to override inadvisable configurations.

Re:Publishing with Apache Kafka at The New York Times by tlberglund on Wednesday September 06, 2017 @10:18PM (#15188681)
It may be unfair to describe setting a documented configuration parameter as "fiddling." Retention is seven days by default. It is trivial to set it to arbitrarily long periods of time. To my knowledge, this functionality isn't really in question. Whether logs are a good unifying abstraction on which to build systems is in dispute among reasonable people, but whether Kafka randomly deletes stuff is not. :)
Re:Publishing with Apache Kafka at The New York Times by cookiecaper on Thursday September 07, 2017 @12:01AM (#15189061)
I don't claim that Kafka randomly deletes things. Just that it automatically does so.

The danger is not that Kafka will choose not to respect the configuration value. It is that the default setting will find a way to creep back in without the admin noticing it, and then a quick reboot, maybe even an unplanned one caused by a power trip or a kernel crash, will be sayonara to the system of record. Sure, there are backups, but who needs that aggravation? (p.s.: there probably aren't actually any workable backups)

In the RDBMS world, MySQL's automatic and silent truncation of VARCHARs down to the character limit of the column was seen as a sign of its badness. That demonstrates the difference in paradigm.

Anyway, the argument doesn't really hinge on whether or not there's an automatic eviction model in the software. It's just a clear, loud signal that the software is not really intended for long-term storage, and that you are, at best, entrusting decades of mission-critical data to a less-tested configuration on a young, maturing product. This should not be appealing by itself, and that's a very optimistic perspective on the choice to forgo the data integrity features provided by a traditional RDBMS.

Developers just cannot seem to grok that just because something appears to store data across server restarts does not mean it is necessarily a safe permanent parking spot. I'm not a DBA, and I've had my share of serious squabbles with them, but when this is what happens with unsupervised developers at the helm, it's hard not to be sympathetic to their aggressive, almost hostile, feelings around developer input into the data model.

Re:Publishing with Apache Kafka at The New York Times by tlberglund on Thursday September 07, 2017 @08:39AM (#15191266)
Agreed that this is a newer architectural paradigm and a younger product. Of that there is no doubt, and there is always risk there. Also return, of course; someone had to deploy an RDBMs for the first time too—and everyone is glad they did.

But I still don't follow the argument. If the eviction model is a loud, clear signal that this is the wrong solution, why isn't the mutability of RDBMS data the same sort of signal? Claiming that the presence of a DELETE statement in SQL rules out relational databases as durable data stores would not get me too far. And nor should it!

You are 100% right that this is a new approach. You are also right that it is possible to make configuration errors that will break the system. But this is true of all nontrivial systems. At the end of all of this, we still have a very interesting sequence of events (all NYT content ever) stored in an immutable log. This seems reasonable. Maybe the NYT team is blazing a trail, it's not prima facie a crazy one. :)

Re:Publishing with Apache Kafka at The New York Times by cookiecaper on Thursday September 07, 2017 @11:40AM (#15192851)
SQL provides users with a lot of facilities and mechanisms to limit, control, supervise, and if performed within a transaction, even undo overzealous DELETE statements. I discussed some of these at https://news.ycombinator.com/item?id=15188619.

AFAIK, with Postgres, there are no known circumstances where restarting your server will result in the purge of your database; that's really just icing on the cake, not the core of the argument. The core of the argument is that SQL provides not only a rational design paradigm for long-term storage and choices that reflect they take it seriously, but also an extremely strong feature set for data management and integrity.

As I've said numerous times now, SQL isn't invincible. But it's inarguably more resilient than Kafka, and it provides the controls necessary to keep some sanity over data in the long run.

Re:Publishing with Apache Kafka at The New York Times by miguno on Thursday September 07, 2017 @09:26AM (#15191595)
> No offense, but this just shows your ignorance of the functionality that you're leaving on the table by considering SQL a cough-legacy-cough solution.

No reason to get ad-hominem.

When I said cough-legacy-cough, I was referring to the situation you happen to be in when e.g. taking on a new project. If, for example, your company has been fully committed to Postgres since several years, your chances to change this and move to a different architecture (or even sticking to the same architecture but using a different RDBMS like MySQL) are pretty low.

Re:Publishing with Apache Kafka at The New York Times by LgWoodenBadger on Wednesday September 06, 2017 @11:00PM (#15188867)
Kafka is not a messaging queue. It's a log.

The same underlying structure used within our RDBMS to provide all the guarantees Kafka provides.

As for logs and databases, they are duals.

https://www.confluent.io/blog/turning-the-database-inside-ou...

Re:Publishing with Apache Kafka at The New York Times by cookiecaper on Thursday September 07, 2017 @02:33PM (#15194558)
>Kafka is not a messaging queue. It's a log.

Kafka bills itself as a "messaging system".

>The same underlying structure used within our RDBMS to provide all the guarantees Kafka provides.

Is there perhaps a reason that people use the RDBMS scaffold atop this "underlying structure"? The point I'm making is that Kafka is not safe for use cases that demand robust data storage and integrity, at least not in comparison to the standard of safety set by the traditional systems of record for important data (RDBMS).

Re:Publishing with Apache Kafka at The New York Times by miguno on Thursday September 14, 2017 @10:55AM (#15248617)
Small and friendly correction: Kafka bills itself as "a distributed streaming platform".

Also, a heads up: we'll soon publish a blog post on the subject of "is it ok to (permanently) store data in Apache Kafka".

Re:Publishing with Apache Kafka at The New York Times by mayank on Wednesday September 06, 2017 @04:53PM (#15187051)
You've really just laid out feelings rather than concrete technical reasons for why Kafka can't function as a permanent datastore.

Can you point to specific design elements in Kafka that would lead you to conclude that it isn't suitable for permanent data storage?

Also, Kafka doesn't "do" anything to your old data if you don't want it to. It's also open-source, so these behaviors can be verified.

Re:Publishing with Apache Kafka at The New York Times by pram on Wednesday September 06, 2017 @06:17PM (#15187583)
I'd say it isn't appropriate for permanent data storage because the individual brokers don't scale well with the amount of logs present. If you have hundreds of partitions, and millions of logs, then any operation dealing with the indexes (like an unclean startup) will take an extremely long amount of time. So your individual brokers are now down for an hour if they don't shut down cleanly. Which happens often (oom, weird zk errors, etc)

It scales linearly.

Re:Publishing with Apache Kafka at The New York Times by LgWoodenBadger on Wednesday September 06, 2017 @11:05PM (#15188889)
Most of the use-cases you describe wouldn't be resolved by re-reading the entirety of the topics from the beginning of time.

They'd resume from their last committed offset and continue where they left off.

If you do have to catastrophically recover from the beginning of time, then sure you'd have a rough time. But that's true for any system that would have to do that. It's not Kafka-specific.

Now if your consumer was entirely in-memory and made no use of persistent storage itself and it had to recover from the beginning of time, then I'd say that type of problem is your own architectural failure and I have yet to come across a tool, pattern, framework, or architecture that bullet-proofs your foot.

Re:Publishing with Apache Kafka at The New York Times by pram on Thursday September 07, 2017 @02:02AM (#15189453)
Reading the topic from the beginning is not what I'm talking about.
Re:Publishing with Apache Kafka at The New York Times by cachemiss on Wednesday September 06, 2017 @01:39PM (#15185562)
That's a bit of an oversimplification. Production grade RDBMS systems have far more guard rails, testing and work put in to them than Kafka. It's relatively straight forward to lose data in Kafka, I've done it (its usually control plane bugs, not data plane).
Re:Publishing with Apache Kafka at The New York Times by robohamburger on Wednesday September 06, 2017 @01:41PM (#15185576)
I skimmed the article but I imagined they were using it as a secondary data store. I think they want to it to be durable in the sense that even if the events are already consumed they can still play them back to reindex elastic search (which is a thing you need to do periodically).
Re:Publishing with Apache Kafka at The New York Times by Diederich on Wednesday September 06, 2017 @02:03PM (#15185758)
"With the log as the source of truth, there is no longer any need for a single database that all systems have to use. Instead, every system can create its own data store (database) – its own materialized view – representing only the data it needs, in the form that is the most useful for that system. This massively simplifies the role of databases in an architecture, and makes them more suited to the need of each application."
Re:Publishing with Apache Kafka at The New York Times by robohamburger on Wednesday September 06, 2017 @03:00PM (#15186213)
Fair enough. It seems like it still ought to be able to burn the kafka+elasticsearch world down and submit everything to kafka with such a setup (and thus elasticsearch). I would certainly not sleep very well at night if I could not.
Re:Publishing with Apache Kafka at The New York Times by sidlls on Wednesday September 06, 2017 @09:55PM (#15188608)
And then you end up with a different flavor of data store for every team, complete with its own idioms and (probably duplicative) business logic.

Unless their devops/SRE staff is up to the task this "architecture" is a nightmare waiting to happen.

Re:Publishing with Apache Kafka at The New York Times by miguno on Wednesday September 06, 2017 @03:24PM (#15186395)
> I think they want to it to be durable in the sense that even if the events are already consumed they can still play them back to reindex elastic search (which is a thing you need to do periodically).

That (replaying if needed) is exactly what Kafka allows you to do, unless I misunderstood what you wrote.

Re:Publishing with Apache Kafka at The New York Times by robohamburger on Thursday September 07, 2017 @12:36AM (#15189166)
No, you understand. Just not sure what failure mode would make kafka a bad store, especially if all its logs are created from other services.