News for hackers. Stuff that matters.
Re:Mistakes we made adopting event sourcing and how we recov... by nullwasamistake on Monday July 01, 2019 @08:16PM (#20330980)
In my experience CQRS is useless these days when I can use something like MongoDb that has great read speeds. The idea of splitting reads and writes is fine conceptually but doesn't make sense to me when databases are so fast.

I worked on multiple Event Sourcing CQRS based systems and I see no advantages vs traditional databases.

The event stream is exactly the same as a commit log in a regular DB. Building "projections" is the same as making views or calculated columns. In my experience storing the whole event history is not useful and consumes huge amounts of space. Just like everyone compacts their commit logs, you don't have to, and if you don't, isn't ES the same thing with extra steps? It stores all the changes to tables and views, which are exactly the same as projections. With ES + CQRS combined you're basically replicating a database, badly.

Sorry to be so negative about this topic but I've worked on several of these projects at a decent scale and it's been the biggest disaster of my professional life. The idea may be viable but tooling is so bad that you're almost surely making a huge mistake implementing these patterns in production code.

Re:Mistakes we made adopting event sourcing and how we recov... by mycall on Monday July 01, 2019 @10:08PM (#20331530)
> The event stream is exactly the same as a commit log in a regular DB

This assumes the content in the commit log are client events, not CRUD on table data actions (events are higher order).

> the whole event history is not useful and consumes huge amounts of space

When a greenfield project is starting up, data is gold. 8TB drives are $242. Create a data lake from the start.

Re:Mistakes we made adopting event sourcing and how we recov... by nullwasamistake on Wednesday July 03, 2019 @02:17AM (#20342051)
I disagree. The events tend to relate directly to what would be regular database tables in my experience.

And data is the new oil is definitely a businessweek cargo cult. None of the event data was of any use on the projects I worked on. We were under mandate to find something to do with it and still couldn't. The closest useful thing was allowing undo and replaying past events but we already had that on Postgres with hibernate auditing on interesting tables (money related stuff)

Re:Mistakes we made adopting event sourcing and how we recov... by codebeaker on Tuesday July 02, 2019 @02:59AM (#20332819)
> Sorry to be so negative about this topic but I've worked on several of these projects at a decent scale and it's been the biggest disaster of my professional life. The idea may be viable but tooling is so bad that you're almost surely making a huge mistake implementing these patterns in production code.

Quite, which is why I'm both writing a book, and developing tooling to help with this problem. ES/CQRS is a nice pattern that you can explain to someone on the back of an envelope in 5 minutes, but the devil really is in the details.

Re:Mistakes we made adopting event sourcing and how we recov... by nullwasamistake on Wednesday July 03, 2019 @02:24AM (#20342080)
I agree it's a nice pattern. What you really need though is a "database in code". A library that handles all the projections, event stream, and especially replays and upgrading event versions automatically.

I'm hopeful that one day it will be a common and useful pattern but it desperately needs language integration to help with the details. That's why right now I can just say stay the hell away. Looking forward to advances in the space to make it viable in production

Re:Mistakes we made adopting event sourcing and how we recov... by pyrale on Wednesday July 03, 2019 @03:36AM (#20342379)
It seems like you have problems with the language here. Using pg and a language with ADTs, we have no trouble doing everything ourselves.
Re:Mistakes we made adopting event sourcing and how we recov... by equasar on Tuesday July 02, 2019 @04:03AM (#20333122)
Any preview?
Re:Mistakes we made adopting event sourcing and how we recov... by edvinbesic on Monday July 01, 2019 @10:10PM (#20331538)
One thing you do get "for free" pretty much is an audit log though. Each event can easily have an ID associated with it in case you need to be able to trace such a thing. Of course you can model this outside of a CQRS system but then you basically have created a CQRS system.
Re:Mistakes we made adopting event sourcing and how we recov... by stevesimmons on Tuesday July 02, 2019 @01:24AM (#20332370)
And if you store events with both an event_timestamp and effective_timestamp, you get bi-temporal state for free too.

Invaluable when handing a time series of financial events subject to adjustments and corrections. For instance, backdate interest adjustments due to misbooked payments, recalculate a derivatives trade if reported market data was initially incorrect, calculate adjustments to your business end of month P&L after correcting errors from two months ago.

Re:Mistakes we made adopting event sourcing and how we recov... by nullwasamistake on Wednesday July 03, 2019 @02:20AM (#20342065)
You get audit logs for free on a regular database with an ORM like Hibernate or even support on database snapshot level with Postgres or MSSQL. You get the logging capabilities of CQRS without any of the complexity.

After working on several such systems, I strongly believe you should keep data storage concerns in the database. Moving it to code implementation is a massive amount of overhead for no benefit.