Live data from Hacker News

Show HN: Learn what DDD, CQRS, and event-sourcing are all about

docs.wolkenkit.io

31–40 of 86 posts

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#31
post #27

Can anyone explain why eventual consistency is so scary? The way I see it, eventual consistency is everywhere. Even in your non-distributed synchronous CRUD app. The minute you start two db transactions within one script you have eventual consistency. You have to deal with the fact that one transaction can fail and that your state can be inconsistent.

> The minute you start two db transactions within one script you have eventual consistency.

You may also have two independent items of information that have no consistency relationship or requirements.

That's why eventual consistency "works" so "well" with NoSQL: because there's an overlap between using NoSQL databases and not requiring actual consistency.

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#32
post #26

Reshaping data is the source of so many costly bugs and communications breakdowns in this world. CQRS is like descending to the 8th circle, pit 7 of reshaping hell. What fetish drives one to such tortures? If your schema is any more complicated than a plain stream of characters, and you pick CQRS for your app, then you are an overpaid, bored, architecture astronaut consultant looking to pad his resume. Nevermind the…

CQRS just simply means your queries, and commands have separate paths. This can be as simple or as complicated as someone wants to make it. It could be as simple as having commands operate on a domain object, but the queries returning a fully populated view object from some custom sql.

Are those objects in the queries and queues separate and distinct types then? And, what about the object store, what types go in there? How do we handle data migrations?

I like queues as much as the next developer. Queues let you scale performance Mt Everest and deal with concurrency.

CQRS as an architecture is like queue abuse.

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#33
post #27

Can anyone explain why eventual consistency is so scary? The way I see it, eventual consistency is everywhere. Even in your non-distributed synchronous CRUD app. The minute you start two db transactions within one script you have eventual consistency. You have to deal with the fact that one transaction can fail and that your state can be inconsistent.

Dealing with eventual consistency adds a lot of mental complexity to almost every feature. It turns a simple rule like "Do not allow registering an username if that username has already been registered" into an entire rulebook on what should happen if a username is registered twice. It even forces you to deal with the obvious "Once a gizmo is created, it should appear in the list of gizmos". Every part of your code becomes a potential race condition that you have to detect and handle appropriately.

You can't get rid of eventual consistency, obviously, but you can set up your system so that your code expresses rules and features in an "immediately" consistent abstraction, and the system then translates those rules and features into the eventually consistent world, by applying tactics and techniques that you would have otherwise applied manually. It's a really natural approach for programmers: automate the translation from immediate to eventual, instead of doing it yourself every time.

Of course, most of these tactics come at a cost, either of performance (we won't acknowledge the creation of a gizmo until we've propagated that creation to every server capable of rendering the list of gizmos) or of availability (the registration of your username can't be acknowledged unless the persistent consensus reflects that you're the only one who registered it). But that's fine: most of these things aren't critical enough to make it worth dealing with eventual consistency manually, and when they do become critical, it's time to go down a level of abstraction and apply immediate-to-eventual translation tactics that rely on additional assumptions about what you're doing in order to improve performance or availability.

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#34
post #26

Earlier quoted context omitted.

CQRS just simply means your queries, and commands have separate paths. This can be as simple or as complicated as someone wants to make it. It could be as simple as having commands operate on a domain object, but the queries returning a fully populated view object from some custom sql.

Are those objects in the queries and queues separate and distinct types then? And, what about the object store, what types go in there? How do we handle data migrations? I like queues as much as the next developer. Queues let you scale performance Mt Everest and deal with concurrency. CQRS as an architecture is like queue abuse.

You don't have to use queues, separate objects/NoSQL store or anything like that to use cqrs.

I mean you can use them, but all CQRS means is a separate code path for queries and commands.

In my system I have command objects, they operate on domain objects which contain some business logic.

I have query objects which just execute custom sql code which returns a populated view.

This is useful because views often display specific data from multiple domain objects.

This system allows you to bring back the entire view in a single query and nothing else, rather trying to retrieve multiple domain objects which are really designed for business rules rather than queries.

Often yes, people do starting adding queues, materialised views to CQRS which can make it complicated.

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#35
post #18

Earlier quoted context omitted.

I'm currently writing a book about CQRS/ES I'd be glad of your notes about it's downsides.

I think many people just dislike DDD and CQRS/ES because it's associated with over engineering. Either you are really good and get things right without much help, which isn't often the case, or you end up in two other directions. You over-engineer with DDD/CQRS/ES. You under-engineer without them. Most developers I met preferred the last solution, probably because they end up with their "own" mess and not the mess of…

> You over-engineer with DDD/CQRS/ES.

CQRS/ES definitely seems like a correct foundations for a distributed system, I just don't think we have the right abstractions to properly model this without wanting to stab yourself in the eye.

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#37
The DDD/CQRS/ES topic appears on Hacker News every so often, and never fails to stir a strong debate. In fact, I was going to "Show HN" an Event Sourcing library I open sourced yesterday, but I guess I'll wait until everything dies down a bit :-)

I believe that the core principles of DDD/CQRS/ES are flawed and are the cause of a lot of pain. If your team plows forward and ignores the pain, you will have a bad experience working there. If your team decides to fix the problems with the architecture (usually in a way that's rather specific to their situation), and still insists that they're doing DDD/CQRS/ES, then you will have a great experience. The same can be said of many approaches to SQL database design.

When I joined Lokad, most of the code had been written by a strong CQRS advocate, and there were significant pain points caused by this approach that would have been nonexistent with a plain old SQL architecture. The author himself did a retrospective that covers a few issues: https://abdullin.com/lokad-cqrs-retrospective/

Instead of dropping everything and moving back to a more conventional SQL architecture, we dropped everything and moved to a solution which, if I were to describe it as DDD/CQRS/ES, would have me branded as a heretic by the DDD/CQRS/ES community: it does fit the definition, but it does not follow the best practices. There is a single data model shared by both commands and queries. Commands can sometimes return data. Each (micro?)service has access to exactly one aggregate. There is no uncertainty on event ordering, and no eventual consistency at the aggregate level. Materialized views for each aggregate are kept in-memory at all times. All of these intentional weakenings of the CQRS architecture were driven by pragmatic needs, and made with knowledge of the consequences.

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#38

The DDD/CQRS/ES topic appears on Hacker News every so often, and never fails to stir a strong debate. In fact, I was going to "Show HN" an Event Sourcing library I open sourced yesterday, but I guess I'll wait until everything dies down a bit :-) I believe that the core principles of DDD/CQRS/ES are flawed and are the cause of a lot of pain. If your team plows forward and ignores the pain, you will have a bad experie…

I'm CQRS advocate. None of are weakening the CQRS. CQRS is in fact pretty damn lose.

"There is a single data model shared by both commands and queries." - Nothing wrong with that, especially in simple cases.

"Commands can sometimes return data" - Well commands can succeed or fail. Greg young himself admits commands are really synchronous, and you need to communicate that.

"and no eventual consistency at the aggregate level." - This is the recommended approach. Between aggregates and it becomes loser.

"Materialized views for each aggregate are kept in-memory at all times" - Thats some advanced CQRS usage there.

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#39
post #38

The DDD/CQRS/ES topic appears on Hacker News every so often, and never fails to stir a strong debate. In fact, I was going to "Show HN" an Event Sourcing library I open sourced yesterday, but I guess I'll wait until everything dies down a bit :-) I believe that the core principles of DDD/CQRS/ES are flawed and are the cause of a lot of pain. If your team plows forward and ignores the pain, you will have a bad experie…

I'm CQRS advocate. None of are weakening the CQRS. CQRS is in fact pretty damn lose. "There is a single data model shared by both commands and queries." - Nothing wrong with that, especially in simple cases. "Commands can sometimes return data" - Well commands can succeed or fail. Greg young himself admits commands are really synchronous, and you need to communicate that. "and no eventual consistency at the aggregate…

Maybe I'm not as much of a heretic as I thought I would be :-)

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#40
post #27

Can anyone explain why eventual consistency is so scary? The way I see it, eventual consistency is everywhere. Even in your non-distributed synchronous CRUD app. The minute you start two db transactions within one script you have eventual consistency. You have to deal with the fact that one transaction can fail and that your state can be inconsistent.

> The minute you start two db transactions within one script you have eventual consistency.

Well it's all about errors (and subsequently about control and correctness). Even if you have two transactions you are able to undo the other without anyone else (readers of the system) know that it was there because something else happened just before yours. A transaction usually happens in an atomic fashion, which makes it possible to back out on something which is no more correct so you have to fail it somehow to someone which does have the ability to recover, the one who initiated the call.

Without being too philosophical, most, if not everything depends on synchronous state (fex events themselves), computing just gives the illusion of that things happens immediately. Eventual consistency is cheating, and you can do it where the events are entirely independent. Otherwise you will have side effects when events are not ordered.

JavaScript have an "asynchronous" coding style, where (red/blue) methods are put on event-loop as "events". But the events needs to executed in order (synchronously by a thread) for the program to behave correctly so you give the methods attributes (red/blue) for them to execute in an linked order. So even the asynchronous behaviour in JS relies on synchronous features for it to be correct!

Post reply on HN