Live data from Hacker News

The Reactive Monolith – How to Move from CRUD to Event Sourcing

wix.engineering

71–80 of 112 posts

Re: The Reactive Monolith – How to Move from CRUD to Event Sourcing

#71
post #58
post #34

Earlier quoted context omitted.

I work on a bog standard ERP that was originally CRUD, but a whole module was refactored to event sourcing so clients could have a log and rollback. A couple of months back, a QA review reported a bug - the log system didn’t work. Turns out it’s never worked. Nobody has ever done a rollback either.

I understand this thread is about dumping on ES... However, I must notice in your case it was an audit log. An ES system wouldn't work at all without access to events.

Yeah, the ES side of the system worked but was completely unnecessary. So loads of extra complexity, with no value for the business.

Re: The Reactive Monolith – How to Move from CRUD to Event Sourcing

#72
post #3

And then you realize that the CRUD db you moved away from operates on event sourcing (WAL) anyway. And thus you’re just doing inner platform effect.

Correct, and many applications are using WAL via CDC (Change Data Capture) to gain some of the benefits of the CQRS/ES.

The problem is that the CRUD is only recording "What" change/mutation was done, but not "Why" by "Whom", and "When" it was done. With tailing WAL / CDC you can also capture the "When".

This can be partially mitigated by adding audit fields like:

  Why (reason for change):

  created_bc ("because") / created_reason   (a person opened an a/c, a new baby born, or a record was migrated from another datastore)
  updated_bc ("because") / updated_reason   (fixed typo in the address, or moved to new address)
  deleted_bc ("because") / deleted_reason   (closed an a/c, an end-user died, GDPR request, soft-deleted, removed by moderator, etc.)

  By Whom (i.e. user_id, support person, decision maker, etc.):

  created_by
  updated_by
  deleted_by

  When (event time) - with CDC you can capture all the intermediate updated_at events:

  created_at
  updated_at
  deleted_at

This captures much more information that a typical CRUD, but it will only save last update_xxx fields, so it still loses a lot of information.

Re: The Reactive Monolith – How to Move from CRUD to Event Sourcing

#73
My first experience with event sourcing was having a new hire at a previous company try to shill it. It was a smaller company and he had previously built a career consulting on ES. Every problem we had he would come up with an argument for why ES would solve it. I soon learned he had zero technical ability, but was great at sounding credible to management. I liked to imagine him as a "seagull ES" practitioner. He flies in, sh*ts ES on everything, and flies out without having to deal with the mess.

Ironically I went on to use a lot of ES prinicpals in building a distributed deduplication engine for my previous startup after I left that company. We used a WAL which we were able to rebuild databases/projections from, ship to replica nodes for read replicas, push to S3 for resilient storage etc. it was an extremely powerful architecture for us. It was also complex and required a special skill set to work on and reason about.

I have to imagine anyone that advocates for "moving from CRUD to Event Sourcing" has recently been sucked into drinking the coolaid, and has no idea about the world of hurt they've signed up for, completely necessarily.

Re: The Reactive Monolith – How to Move from CRUD to Event Sourcing

#74

I would like to see answers to the question: why move from Crud to event sourcing. Because I have seen at least 5 moderate projects trying to integrate ES. They all failed in the sense that either people didn't understand the code anymore, huge integration times, performance issues and even complete project cancellation because of all people walking away

I have never implemented ES, although it seems to be useful to have the most simple version of it in place: just a queryable log of versioned events and the ability to replay it.

But if you have the luxury to do consistent CRUD with a relational/graph, ACID database, then a temporal data model might give you much more leverage.

Essentially you think of your records as bookkeeping entries and go from there. You retain the ability to do ad-hoc relational queries, while not having to build core database functionality yourself.

Re: The Reactive Monolith – How to Move from CRUD to Event Sourcing

#75
post #73

My first experience with event sourcing was having a new hire at a previous company try to shill it. It was a smaller company and he had previously built a career consulting on ES. Every problem we had he would come up with an argument for why ES would solve it. I soon learned he had zero technical ability, but was great at sounding credible to management. I liked to imagine him as a "seagull ES" practitioner. He fli…

Similar thing happened on a project I joined. Except this person not only forced ES onto the business but their own specific library for it https://github.com/johnbywater/eventsourcing

The business eventually failed to due to this, due to slow implementation of simple features and many other issues with it.

I will never use ES due to this project, it's pointless, anything you can do with it, you can do without it.

Re: The Reactive Monolith – How to Move from CRUD to Event Sourcing

#76
post #5

This article doesn’t really explain event sourcing and some of the trade offs with event driven architecture in general (additional complexity). I’ve heard Git is an example of event sourcing. It has all the info for you to be able to determine the current state from scratch if you needed to. I’m not sure why you’d see event sourcing as the next stage of evolution for a CRUD system.

I started my carrier before the industry consolidated around CRUD, and even before RDBMS/SQL became the go to tool. I only had SQL on large machines (VAX-11), not on PCs.

The industry is moving chaotically and sometimes getting stuck in a local minima for a decade. The innovation follows diffusion model, and it slowly builds momentum until the tipping point is reached.

So I do agree, that CQRS/ES might be the next informal industry standard, but we do need tooling, best practices, use cases and success stories.

Maybe we need a special programming language, a DSL, or a framework for it, or a special DBMS.

Another point: it's not that easy to build a correct, scalable and maintainable moderate-complexity CRUD app. Anything beyond a simple blog engine or TODO list tutorial can quickly become a mess. The tutorials are omitting error handling, and that where the juniors are learning from.

Last anecdotal datapoint: when building a moderate-complexity CRUD app, and trying to handle all edge cases/error handling/correctness, I realized that I'm building a poor man's CQRS, so I might do the real thing as well.

Re: The Reactive Monolith – How to Move from CRUD to Event Sourcing

#77
post #44
post #33

Earlier quoted context omitted.

It's not practical. That's why all the arguments for it involve overstating and hyperbole. The results speak for themselves. It's shit.

The question is whether it’s not practical because it hasn’t received the three decades of engineering that relational databases have, or because it’s broken in theory.

Modern relational databases are marvels of engineering. But I don't think they would have gotten off the ground if they had needed those three decades to be practical at all.

Re: The Reactive Monolith – How to Move from CRUD to Event Sourcing

#78
post #69

Earlier quoted context omitted.

Here's why I used event sourcing. We were modeling well dynamics. And to calculate interesting properties of the well we needed sensor data, the previous state of the well, and a model of the well built by a petroleum engineer. Unfortunately the model of the well wasn't always up to date (pump was replaced, etc..), so we needed to be able to replay all of the sensor data into the well when a model was retroactively c…

it sounds pretty straightforward to implement with basic crud too, though. you'd just need an inserted timestamp field so that you can rerun the analysis with where inserted >= the_date order by inserted

I think GP mixing up Stream Processing with Event Sourcing [1]. Event Sourcing is usually used in complex business domains, Stream Processing in simple domains, but with large amounts of data (i.e. IIoT).

if you use a timeseries databases like kdb+/q, TimescaleDB, InfluxDB, QuestDB, etc., you don't even need to order by the insertion timestamp.

Unlike RDBMS/SQL where rows/tuples are unordered, in timeseries databases they're usually ordered by the insertion time, more similar to dataframes than to SQL tables.

--

[1] Martin Kleppmann — Event Sourcing and Stream Processing at Scale

https://www.youtube.com/watch?v=avi-TZI9t2I

Re: The Reactive Monolith – How to Move from CRUD to Event Sourcing

#79
i have done few ES projects. it is amazing! massive overhead but for some projects it is well worth it. one thing i would note is that understand the difference between local events and public events. local events do not have to be complex and granular. simple diff of an entity is enough to trigger local reactors to perform local actions. now when you want to publish events outside of your domain, then you might have to implement high granularity(ie. from what to what, where, why and who). you can also produce only few specific public events that don't even have to be that granular just so that you can "notify" some other actor outside of your domain. i think figuring this out is why most projects fail. they go to granular, too specific when in reality they might have just needed "user x created a post titled foo at this time".

also, ALWAYS have aggregate's snapshot. never rebuild aggregate from ES unless you are rebuilding your entire system. i always use indices for my snapshots, that way i can work with them just like with any other entity with the difference being the serialized form of the entity itself. it saves a lot of time and makes working with them no different than crud style of sql storage.

Re: The Reactive Monolith – How to Move from CRUD to Event Sourcing

#80

I used to be really excited about event sourcing but yeah, its usually just over-engineering. It appeals to the nerd in me because its a powerful & clean model - events are immutable, your entire database can theoretically be reconstructed at any point in time by just replaying an event log up to time X. In the ideal form its sort of the highest fidelity version of data storage, throwing nothing away, supporting all…

Totally agree. The field of software engineering would be a lot better off if we stopped using weasel words like "clean" and "elegant", and discussed concrete things like performance or the ability to produce an audit log.
Post reply on HN