Developing microservices with aggregates - Chris Richardson

  Переглядів 274,475

SpringDeveloper

SpringDeveloper

День тому

Recorded at SpringOne Platform 2016.
Slides: www.slideshare.net/SpringCentr...
The Domain Model pattern is a great way to develop complex business logic.
Unfortunately, a typical domain model is a tangled, birds nest of classes.
It can’t be decomposed into microservices.
Moreover, business logic often relies on ACID transactions to maintain consistency.
Fortunately, there is a solution to this problem: aggregates.
An aggregate is an often overlooked modeling concept from the must read book Domain Driven Design.
In this talk you will learn how aggregates enable you to develop business logic for the modern world of microservices and NoSQL.
We will describe how to use aggregates to design modular business logic that can be partitioned into microservices. You will learn how aggregates enable you to use eventual consistency instead of ACID.
We will describe the design of a microservice that is built using aggregates, and Spring Cloud.

КОМЕНТАРІ: 146
@losrobbosful
@losrobbosful 2 роки тому
Those people who complain about "not fast enough talk" are exactly the problem of our time. People rushing through concepts, just understanding it partially and applying it right away, again rushed, without much thinking. That perfectly explains why more than 90% of Microservice architectures are such a gigantic mess and also most of the talks about it. Thanks to Chris we - the "slow thinkers" - still have a chance to turn things around for the better, cleaning up all the BS the "rushing people" left behind
@tommygentile5618
@tommygentile5618 11 місяців тому
I'm not a rush individual.. but my company made me become one
@alex_chugaev
@alex_chugaev 5 років тому
I am not native speaker. For me speed is perfect, I understood each word. Thank you. Great material!
@colloredbrothers
@colloredbrothers 4 роки тому
Speed is perfect imo, he talks about many complex concepts and to absorb all of that it helps to have the words flow more slowly.
@kimadams-semanticrevolution
@kimadams-semanticrevolution 5 років тому
Great overview, really enjoyed your presentation! Totally agree that listening is better at >=1.5x speed.
@defenseman84
@defenseman84 4 роки тому
I thought this was great and not sure how people are watching this at a higher speed... I needed to pause this periodically and take in its glory. This was finally proved the event sourcing model for me.
@NilsElHimoud
@NilsElHimoud 5 років тому
Great talk to refresh my theoretical DDD know how. I like the speed.
Рік тому
Thank you Chris for this excellent presentation!
@frankadu23
@frankadu23 4 роки тому
Great talk!
@Funkbassfushion
@Funkbassfushion Рік тому
Best presentation I've seen so far on microservices and eventsourcing.
@fadidib8516
@fadidib8516 Рік тому
i agree
@losrobbosful
@losrobbosful 2 роки тому
I love Chris. Thanks to guys like him there is still hope that simplicity and clean thinking prevails over all that overcomplication and endless confusion of other microservice talks.
@gregorifernandesdelima9618
@gregorifernandesdelima9618 3 роки тому
Great explanation, thank you!
@sandyss2392
@sandyss2392 3 роки тому
Great explanation 👏🏼👏🏼
@chitthiaayeehai
@chitthiaayeehai 3 роки тому
I just love this guys man.
@milesajaygupta
@milesajaygupta 4 роки тому
Very Nice description
@KevinGenus
@KevinGenus 4 роки тому
So glad I found this talk. I watched at 1x speed. Hearing someone speak at their pace allows you to hear words being emphasized in ways you will never heard at faster speeds. This was an awesome talk.
@Minefortress21
@Minefortress21 2 роки тому
I have been on 2x soo much that 1x sounds slo-mo to me now
@googlr214
@googlr214 6 років тому
I started a small open source project which became CloudFoundry - CR
@ajabbi-tv
@ajabbi-tv 3 роки тому
Excellent talk
@jimmcconville
@jimmcconville 2 роки тому
This is fantastic. Wish I'd found this video much earlier.
@henguemelkis1464
@henguemelkis1464 Рік тому
Set playback speed to 1.25 and enjoy! Complex concepts explained with simple examples, great talk
@maheshmb9171
@maheshmb9171 2 роки тому
Awesome video, Realy it is helpful. I am expecting the multitenant based microservice architecture for distributed databases.
@LadislavJech
@LadislavJech 6 років тому
brilliant
@kavithareddy586
@kavithareddy586 Рік тому
Very well explained, Thank you
@anniyananniyan1068
@anniyananniyan1068 7 років тому
in the name of technology everyone is creating their own version of truth and market it the best. each day a new cook with new cutlery
@abkyabacha
@abkyabacha 7 років тому
This guy is founder of Cloud Foundry and API Gateway architecture
@anniyananniyan1068
@anniyananniyan1068 7 років тому
so the sales pitch eh ?
@trozzonick77
@trozzonick77 2 місяці тому
Great talk , stil very actual , thanks.
@vivekarora5705
@vivekarora5705 2 роки тому
Well explained!!
@RamiSalner
@RamiSalner 7 років тому
Watching at x2 speed is recommended for this great video
@Papa91echo
@Papa91echo 3 роки тому
And then try watch it in normal speed.
@chefgabe
@chefgabe 3 роки тому
Lk
@conorq377
@conorq377 Місяць тому
crazy good presentation!
@juhairahamed5342
@juhairahamed5342 Рік тому
Good explanation
@gabrielferrer3868
@gabrielferrer3868 3 роки тому
Thank you for the talk. Now I understand better how microservices can persist data without transactions. I like the Event Store approach the most.
@8bittimes
@8bittimes 5 років тому
Around minute 54, it is mentioned that events are published on kafka as well as the event store. How is consistency achieved between those two "distributed resources"?
@cantwaittowatch
@cantwaittowatch 4 роки тому
Excellent talk but I'm sure there is an easy way to do this. Complex way to wrap one's head!! :)
@vanivari359
@vanivari359 4 роки тому
19:16 ... now allow the customer to search for an order which contained "headphones" and the microservice journey begins...
@PavelIvanovskii
@PavelIvanovskii 4 роки тому
best comment ever for this vid...
@Greenthum6
@Greenthum6 2 роки тому
There rarely is a need to search for your orders by a keyword. And if that is needed for business add a read model for customer orders with text query support.
@_panand_
@_panand_ 2 роки тому
Another service serving this just this view could save a lot of architecture change trouble.
@lucilvioalves
@lucilvioalves 3 роки тому
Perfect example of how you can add accidental complexity in your software solution. For those who are looking for DDD and how it can helps you to split your solution in services, you're in the wrong place.
@mohyeid1857
@mohyeid1857 2 роки тому
Totally agree. Full of waste time trying to solve fundamental issues of micro services by introducing bunch of other new sever issues.
@einfacherkerl3279
@einfacherkerl3279 Рік тому
@@mohyeid1857 how would you solve the transaction issues in micro service ? could you point to some resources ?
@SatyaTX
@SatyaTX 7 років тому
Completely different architecture style seems very useful but It would have been more beneficial if video also involves a live project. The concept explanation was very good, it just will take some time to accustom with all concepts explained.
@PrashantThakre
@PrashantThakre 5 років тому
First of all this not a different architecture, its old architecture and discussed before many times. For more, you can refer to the SAGA.
@tush7986
@tush7986 6 років тому
Excellent talk. This has clarified how DDD is important for designing and developing micro services.
@gaatutube
@gaatutube 5 років тому
The simplest programming paradigms usually win in the long run. Not sure if this event source method will ever become popular when you shift more programming efforts & complexity to the business logic developer. However, this video is worth watching for some of the ideas (such as aggregates and how it relates to transactional semantics) in it.
@kennethcarvalho3684
@kennethcarvalho3684 5 років тому
Totally enjoyed this talk...lots of valuable information in a short duration...by the way is the Order service going to be in blocked state until it gets an event telling it that Customer credit limit is ok???
@JTGaut17
@JTGaut17 4 роки тому
No it would send an async message to the message bus, get an OK response back and return control back to the user. Later a new message of credit approval or rejection would be oublished.on the message bus and picked up by the order service. It would the update the order information and inform the user in some way like an email.
@educostadev
@educostadev 4 роки тому
Repository: github.com/cer/event-sourcing-examples
@HarshGundecha75
@HarshGundecha75 2 роки тому
You, dear sir, are a god sent person 🙌
@emdadulsadik861
@emdadulsadik861 2 роки тому
26:01 between two context boundaries (where no shared distributed DB is used) 2PC cannot be used.
@Rene-tu3fc
@Rene-tu3fc 2 роки тому
the customer workflow seems tightly coupled to the customer service, since it uses its code to apply events. Why wouldn't we decouple that workflow into a different processor that sends commands to the user service?
@oiraqih
@oiraqih 3 роки тому
A generous talk from a generous person. Thank you! Yet, if I have to turn software and data design practices upsidedown, and if this were the only way, then I will say: thank you! I don't want microservices, at least for now. Once ideas become more mature and once these side effects are either avoided or at least addressed in a transparent way, we can talk. Are you serious!? Would you add all this complexity! Would you start doing journal maintenance as if you were writing the DBMS itself!? And after all, you'll still have to write here (DB) and there (message broker). The 2PC problem still persists, or maybe I missed it. So, again, a generous talk, but a counterproductive, unrealistic solution.
@LusidDreaming
@LusidDreaming 2 роки тому
You're not writing to two places within the transaction. You're writing in one place (DB) with the transaction. Then you're sending the message to the broker (at least) once within a transaction. So the idea is that you can commit the message to the outbox so that the entire operation leading up to and including sending that message is atomic. Then you rely on your ability to only delete the message once it's sent (again using a transaction) to ensure at least once message delivery. So you will only modify your state if the resulting message/event was sent at least once. You cannot guarantee this if you try to send the message/event directly to the broker.
@coldestlin
@coldestlin 2 роки тому
impressive
@ChristianAltamiranoAyala
@ChristianAltamiranoAyala 4 роки тому
My lecture of DDD Chris Evans' book worth
@igoralex007
@igoralex007 2 роки тому
Where are those code samples, mentioned in presentation?
@binualexander9746
@binualexander9746 2 роки тому
I am confused at 42:18 , isnt in event sourcing there are only inserts and no updates
@prateekashtikar8631
@prateekashtikar8631 3 роки тому
Can we've some code to explain this concepts?
@thatpaulschofield
@thatpaulschofield 3 роки тому
I haven't watched the whole video yet, but looking at the thumbnail, it appears that he's building a monilithic UI rather than a composite UI? Doesn't that just result in a distributed monolith?
@updownftw_
@updownftw_ 2 роки тому
Axon framework is to make Event driven Microservices and Axon server is the Event store, am I correct ?
@vamp9225
@vamp9225 5 років тому
21:50 lmao this guy
@MikaelUmaN
@MikaelUmaN 5 років тому
Real talk starts at about 5 minutes in.
@joelmamedov404
@joelmamedov404 3 роки тому
It is confusing. Firstly, the terms aggregate is misused here. Actually, you are not aggregating anything. You just locally referencing to the same information that moved out to its own service. You can do that without local referencing as well. (like service call) Therefore, it is just an optimization technic in my view. Another way to implement it via the workflow process. In this case, you do not need any local referencing (AKA: "aggregate")
@kapilshekhar
@kapilshekhar 5 років тому
Something about event sourcing being a solution for strong consistency for DB Write and Message publish doesnt seem right here. It is perfectly fine to be strongly consistent within one microservice or one DDD Aggregate.
@genericperson8238
@genericperson8238 3 роки тому
He says so in his book too
@8bittimes
@8bittimes 5 років тому
Isn't there a race condition between checking the credit limit and applying a new event as it is shown (by first checking that applying the new reservation)? Would it not make more sense to add a reservation, only then check if the limit is exceeded and if so, revoke the reservation? (Edit: in the example code around minute 57)
@Bstbln
@Bstbln 4 роки тому
No. Applying the reservation and checking happens in the same service, they can e.g. lock the customer row within one transaction, insert the reservation and commit.
@Bstbln
@Bstbln 4 роки тому
Also there is probably no race condition as they might end up reading the events for a certain customer within one consumer and process them in order (see Kafka partitions).
@gulamahsan5902
@gulamahsan5902 3 роки тому
Where is the code link?
@kocesat
@kocesat 3 місяці тому
Eventsource is like how our body works. Brain is an event store, every other cells are like seperate services that do not know each other and react to the signal(event) that brain sends. And if something happens in a cell, that cell sends a signal to the brain. Thats why our body is sourrounded by millions of neurons. One caveat though. If brain (event store) fails to function, the whole system stops functioning.
@3LektroN1ck
@3LektroN1ck 7 років тому
watch at x1.25 speed or you'll be sleeping before the 5th minute
@catamarancn
@catamarancn 6 років тому
x1 is good for non-English people:)
@jpphoton
@jpphoton 6 років тому
but these concepts are the important ones to consider when building out.
@cerberuspandora
@cerberuspandora 6 років тому
thats like the first thing i did when i opened the video..
@raulmeloferreira
@raulmeloferreira 6 років тому
2x
@2mozz
@2mozz 5 років тому
No joke.
@TheDibyendusarkar
@TheDibyendusarkar 3 роки тому
Whats the problem if we make some sort of call to customer service at 28:47. It will reserve the credit same way.
@Buffalo5
@Buffalo5 2 роки тому
Temporal coupling. The availability of Order Service would depend on the availability of Customer Service.
@pavankumararyasomayajulu6365
@pavankumararyasomayajulu6365 3 роки тому
Event Sourcing looks something similar to Store in ReactJs
@shenth27
@shenth27 3 роки тому
Exactly, ReactJS adapted it
@mishacalifornia5670
@mishacalifornia5670 7 років тому
Is there a github for this project?
@marmalist
@marmalist 7 років тому
Look on eventuate.io ! There are eventuate itself and all example projects including this one from video.
@octavr2008
@octavr2008 7 років тому
The source code from the presentation, can be found here: github.com/cer/event-sourcing-examples
@bharathmuniganti2821
@bharathmuniganti2821 3 роки тому
@@octavr2008 Tq
@criosray
@criosray 6 років тому
Good speech, but "transaction that needed to be atomic" is kind of tautology. Transaction is atomic by definition.
@sparun1607
@sparun1607 5 років тому
I have only one question if we hit the service directly will it redirect to api gateway automatically? if we need to make it to work what should be done?
@BryanChance
@BryanChance Рік тому
It seems alternate solutions and design patterns just opens up a different can of worms LOL
@rameshgupta5864
@rameshgupta5864 3 роки тому
Aggregates starts at 15:15
@harishbayyavarapu
@harishbayyavarapu 7 років тому
How'z authentication & Authorization implemented in this model ?
@jriggatx
@jriggatx 6 років тому
I haven't found many talks/examples of DDD-based microservices, if you will, that detail auth. If anybody has any, I'd appreciate some references to them.
@JamesSmith-cm7sg
@JamesSmith-cm7sg 5 років тому
If you mean api auth then the api gateway handles it either by itself or via service
@kisan-majdoorkalyansamiti7390
@kisan-majdoorkalyansamiti7390 5 років тому
Security should externalized if you are architect then you should know this basic thing
@TimBee100
@TimBee100 5 років тому
So microservices call other microservices which are even micro-er?
@kisan-majdoorkalyansamiti7390
@kisan-majdoorkalyansamiti7390 5 років тому
Code/ Functionality first approach is best approach in Software industry and in manufacturing industry Model first as their manufacturing process is based on model ( finished or semi finished product). Aggregation is more towards Model first approach , in case you have already defined BC( bounded context ) then no sense of model granularity as It is already handled during identification of BC. By example in case you have develop is software for school you have to focus admission process exam process then accordingly you have to think required model . in most of case process is important . Siddharth Singh (www.linkedin.com/in/singhsiddh/)
@immmlate5164
@immmlate5164 4 роки тому
1.25 speed, finally normal speed
@amirhossein7984
@amirhossein7984 2 роки тому
try 1.5
@partyY2Hard
@partyY2Hard 2 роки тому
lol such a funny guy
@muralishclinton902
@muralishclinton902 Рік тому
Watched in 1.25x. Best explanation on DDD that I've come across.
@sakcee
@sakcee 4 роки тому
I now know to not implement event-source
@TampaCEO
@TampaCEO 5 років тому
While I agree with the idea of "atomic data", I completely disagree with the suggestion that each service has it's "own database". Here's just a few reasons why: For starters, most companies have legacy databases filled with many years worth of data, stored procedures, etc. Secondly, SQL servers have perfected the concepts of transactions and referential integrity. Why give that up simply to achieve the concept of "autonomy"? Might I suggest a better / simpler solution? Why don't you utilize database SECURITY instead? You can limit each service to their own list of objects. Let's say you have 20 services. Simply create 20 users named after each service. Then, grant specific rights to each of those users. This gives you the benefits of autonomous data management while preserving referential integrity. It also allows you to continue to utilize stored procedures. In other words, the "Orders Process" can call a procedure that updates the customer's credit limit, but the "Orders Service" has no idea that there is a customers table. I find this to be far better than creating a bunch of databases - then replacing the decades long proven transaction capabilities and foreign key constraints of a SQL server with a proprietary blend of "pub / sub" code written by literally anyone. I'd much rather find a "security solution" to ensure "atomic access" to specific objects. It's far better than reinventing the wheel.
@JamesSmith-cm7sg
@JamesSmith-cm7sg 5 років тому
This sounds good in theory, if its a very small company and everyone follows the idea it will work. However with most dev team thats not living in reality (at least in big companies). What happens is you won't find out about a schema change until things go down. Even if you make it clear the schema isn't to be touched, 6 months down the line people forget, new teams are given db access by someone who shouldnt give it, and list 100 other possibilities...
@xnoreq
@xnoreq 5 років тому
@@JamesSmith-cm7sg That's why there's this thing called testing. You don't just roll out a schema change. You run (automated) tests for all your services including processes that span many services and if the schema change breaks something you'll see it. This whole "pure micro services" way of thinking is so ridiculous... What happens if some dev team breaks a micro service that is required for common use cases? Right...
@JamesSmith-cm7sg
@JamesSmith-cm7sg 5 років тому
@@xnoreq If only...
@snowy0110
@snowy0110 4 роки тому
I would say you haven't tried to dive deeper than just complaining... Just saying, if you have such questions and attitude, you clearly seem like you didn't spend enough time on fundamentals about a different approach. Try with this talk first ukposts.info/have/v-deo/e4pkq3-sraN5xoE.html, rather than giving salty comments like "whole industry is wrong, just I clearly see how to do it the right way". Btw, stored procedures and the single database won't last long in a big company. That's a path to a failure that was proven by dozens of big companies. Small companies don't usually care much of it. You can do whatever you want without having big issues.
@meamzcs
@meamzcs 4 роки тому
@@xnoreq It's so ridiculous that it works great at amazon for example xD..
@sijifalore8252
@sijifalore8252 5 років тому
Code Smell? Can simple concepts not be explained with convoluted cosmetic English that sound dead boring.
@habibm19
@habibm19 3 роки тому
"is that a question? do you have a burning question?".....lawl...dude must of had his hand up for long time interrupting the presentation
@ifireblade09
@ifireblade09 4 роки тому
He is right that aggregates are key, but my issue is he incorrectly sliced up the aggregates because his business logic is filtered across the entire system for say placing an order. This DDD anti-pattern is known as the distributed monolith.
@thatpaulschofield
@thatpaulschofield 3 роки тому
He's actually placing the business logic behavior closest to the data the business logic depends on. This follows the OOP principle of cohesion, which is a widely-accepted practice in OOP: en.m.wikipedia.org/wiki/Cohesion_(computer_science)#:~:text=In%20object%2Doriented%20programming%2C%20if,while%20complexity%20is%20kept%20manageable.
@Greenthum6
@Greenthum6 2 роки тому
It is about using microservices to enable scaling beyond a monolith. You can of course implement microservices with transactional databases and APIs. However, there are a lot of pitfalls that this event driven model avoids, but unfortunately adds some new ones.
@fatiamor3220
@fatiamor3220 5 років тому
second half of the video is all about event sourcing: github.com/cer/event-sourcing-examples
@jasper5016
@jasper5016 Рік тому
This event storing to database looks unnecessarily complex.
@criosray
@criosray 6 років тому
Optimistic locking have nothing to do with transaction. Also it's not a bad situation, it's a good situation. Normally order processing systems work in a first come-first served manner, so you HAVE to have optimistic locking, but again optimistic locking is only about timestamp comparison prior to updating the data in the db. It doesn't have anything to do with transactions.
@moman3r33
@moman3r33 Рік тому
nope
@nickpearce2968
@nickpearce2968 3 роки тому
Aggregation is coupling by definition. Congratulations, you just made an even more brittle solution.
@thatpaulschofield
@thatpaulschofield 3 роки тому
Aggregates are modeling the inherent coupling in the business domain.
@thatpaulschofield
@thatpaulschofield 3 роки тому
But that may not have been explained very well in the presentation.
@dungam9402
@dungam9402 3 місяці тому
change speed to 1.25 thanks me later
@PrashantThakre
@PrashantThakre 5 років тому
Isn't it just SAGA ? Why people are creating their own version ? BTW two time I fell to sleep during this video.
@yahveyeye
@yahveyeye 5 років тому
It's TCC
@mohyeid1857
@mohyeid1857 2 роки тому
Full of waste time trying to solve fundamental issues of micro services by introducing bunch of other new sever issues. You counted how many drawbacks you have and called them simple? Did you try to cover how to solve each or some at least? When you were going with aggregate description as a unit, and then moved to modularized aggregate and granularity level, you lost me again going from aggregate to entity again.
@pdn9609
@pdn9609 3 роки тому
What a load of trash on so many levels. It is unfortunate that this atrocity has gotten traction on a lot of places.
@jasper5016
@jasper5016 Рік тому
Very useful video but his voice is so monotonous that puts me to sleep.
@vimalk78
@vimalk78 5 років тому
very boring talk
@CarloL525
@CarloL525 3 роки тому
Great talk!
Building microservices with event sourcing and CQRS
1:24:33
SpringDeveloper
Переглядів 111 тис.
Domain-Driven Design with Relational Databases Using Spring Data JDBC
1:10:30
SpringDeveloper
Переглядів 58 тис.
когда одна дома // EVA mash
00:51
EVA mash
Переглядів 10 млн
skibidi toilet 73 (part 2)
04:15
DaFuq!?Boom!
Переглядів 30 млн
DDD & REST - Domain Driven APIs for the web - Oliver Gierke
1:15:16
SpringDeveloper
Переглядів 164 тис.
Securing Microservices with Spring Cloud Security
1:29:52
SpringDeveloper
Переглядів 100 тис.
Protect Your Microservices with Spring Cloud Gateway
28:10
SpringDeveloper
Переглядів 25 тис.
Spring Tips: Vector Databases with Spring AI
23:55
SpringDeveloper
Переглядів 2,5 тис.
Spring Tips: Beans, Beans: What's in a Spring bean?
40:05
SpringDeveloper
Переглядів 6 тис.
Spring Tips: Spring Cloud Gateway for Spring MVC
26:19
SpringDeveloper
Переглядів 4,7 тис.
Spring Office Hours: S3E17 - Spring Security Architecture Principals
1:01:09
SpringDeveloper
Переглядів 1,9 тис.
Spring Tips: Distributed Job Scheduling with Jobrunr
19:03
SpringDeveloper
Переглядів 8 тис.
Spring Tips: Hello, Java 22!
38:49
SpringDeveloper
Переглядів 13 тис.
Вы поможете украсть ваш iPhone
0:56
Romancev768
Переглядів 189 тис.
APPLE УБИЛА ЕГО - iMac 27 5K
19:34
ЗЕ МАККЕРС
Переглядів 52 тис.
Игровой ноутбук за 100тр в МВИДЕО
0:58
KOLBIN REVIEW
Переглядів 461 тис.
APPLE УБИЛА ЕГО - iMac 27 5K
19:34
ЗЕ МАККЕРС
Переглядів 52 тис.