No video

How Microservices Communicate? Sync vs Async. Direct vs Brokers And Event Busses

  Рет қаралды 29,125

DevOps Toolkit

DevOps Toolkit

Күн бұрын

How should we design communication between microservices? Should it be synchronous or asynchronous? Should it be direct or through message brokers, event bussed, and gateways?
#Microservices
Consider joining the channel: / devopstoolkit
▬▬▬▬▬▬ 🔗 Additional Info 🔗 ▬▬▬▬▬▬
🎬 What is microservices architecture?: • What is microservices ...
▬▬▬▬▬▬ 💰 Sponsoships 💰 ▬▬▬▬▬▬
If you are interested in sponsoring this channel, please use calendly.com/v... to book a timeslot that suits you, and we'll go over the details. Or feel free to contact me over Twitter or LinkedIn (see below).
▬▬▬▬▬▬ 👋 Contact me 👋 ▬▬▬▬▬▬
➡ Twitter: / vfarcic
➡ LinkedIn: / viktorfarcic
▬▬▬▬▬▬ 🚀 Courses, books, and podcasts 🚀 ▬▬▬▬▬▬
📚 Books and courses: www.devopstool...
🎤 Podcast: www.devopspara...
💬 Live streams: / devopsparadox
▬▬▬▬▬▬ ⏱ Timecodes ⏱ ▬▬▬▬▬▬
00:00 Introduction To Microservices
01:50 Monoliths vs. Microservices
04:23 Communication Protocols
07:32 Receivers
10:54 Sync vs Async
16:42 Kubernetes As An Example Of Async Communication And Events

Пікірлер: 97
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
How did you organize communication between your applications? IMPORTANT: For reasons I do not comprehend (and Google support could not figure out), KZfaq tends to delete comments that contain links. Please do not use them in your comments.
@n4870s
@n4870s 2 жыл бұрын
What about cross service transactions?
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
@@n4870s Wait until next Monday. I'll publish a video that will go through one possible technical implementation on that subject.
@emonymph6911
@emonymph6911 Жыл бұрын
Love the overview. Where is your followup video called for how to create Async driven events with a broker? I recommend adding it to the description of this one and maybe a link at the end of this video, thank you.
@DevOpsToolkit
@DevOpsToolkit Жыл бұрын
That video has not yet been done. It's still ok n my to-do list.
@SunilKumar-ow6vx
@SunilKumar-ow6vx Ай бұрын
Hey Viktor .. Thanks a lot for explaining this topic in a simple and easy to understand way. Really loved the video .. I am basically a java Backend Developer and just subscribed your channel Hopefully will leran a lot from you and your Videos Once again Thanks
@RishiRajxtrim
@RishiRajxtrim 3 ай бұрын
I have been watching this video every year to under microservices and the communication among applications even better... every single time. Very powerful words delivered. Thanks a lot!
Жыл бұрын
Event-driven architecture should not be the default choice because depending on your requirements, you might need to prioritise messaging over events. For instance, if replay-ability is not a concern, you do not have to opt for an event-driven architecture. Instead, you might value transient data more than historical data. Furthermore, persistency may not be a critical factor, as messaging allows consumers to acquire a message from the channel/queue, which subsequently gets deleted. However, in Kafka-like services, a retention period exists, enabling consumers to change the offset and re-read the events even after consumption. In such cases, there might not be a necessity to choose event-based communication.
@fenarRH
@fenarRH 2 жыл бұрын
This is a good topic which I end up having conversations on, the way I open the conversation is to marking the direction of communication (North-South vs East-West) in to app-farm (ie microservices colony). Most of the time N-S comm is connection oriented (Direct/Sync) and E-W is async however what I see in legacy to app-modernization projects E-W also kept as Direct/Sync which is a perf killer also roadblock for scaling up the bottlenecked pods but endup scaling whole app-farm.
@jimbrown6422
@jimbrown6422 2 жыл бұрын
Viktor, Really great video. You explained it in easy to understand language. Keep up the great work. Thanks for this. Jim
@bjoernbung
@bjoernbung 2 жыл бұрын
Thanks Viktor! Very good introduction. Looking forward for the next video.
@iham1313
@iham1313 8 ай бұрын
very helpful differentiation of a/sync and de/coupling - thank you very much on that
@kevinyu9934
@kevinyu9934 2 жыл бұрын
Very inspiring!!! I like this topics. Super pumped for the next one,
@geowalrus
@geowalrus 2 жыл бұрын
That communication choreography is sometimes called 'saga' in event driven architecture.
@ayazahamed8254
@ayazahamed8254 Жыл бұрын
Very well explained. It help me to understand how we can communicate the microservices.👌
@davoodgoojposht
@davoodgoojposht 7 ай бұрын
Thanks a lot, It was a very helpful video. Only one thing on the topic of "Sync calls not being resilient", I think async calls have the same behavior too and even worst. With the Sync call if a service is down at least we get some feedback and error, with Async if one service is down we get no notion of a problem. so neither are resilient, we just don't get any errors in async
@DevOpsToolkit
@DevOpsToolkit 7 ай бұрын
If a service is down and if it starts processing messages in a queue, it will eventually catch up.
@davoodgoojposht
@davoodgoojposht 7 ай бұрын
@@DevOpsToolkit you are right, but also in many occasions the cathing up is more than a problem than an advantage, users keep resending the same request because they are not getting any response, and we should clear the messages before bringing up the service. I personally believe the fast feedback of sync communication is actually a great advantage.
@arielguzman2875
@arielguzman2875 5 ай бұрын
Great video thanks
@akitmentorconsultant4696
@akitmentorconsultant4696 2 жыл бұрын
Great video 👍 the same thoughts in my head too. Actually, synchronous communication is not a natural / ecological way to communicate. Because, real world works asynchronously. Synchronous approach is only problem of HTTP1 from my point of view. HTTP2 a little bit better see Server-Sent Events. But how many time/money we spent with HTTP1.1? A lot of years)
@SV-tc8cu
@SV-tc8cu 2 жыл бұрын
Excellent video, short but full of useful concepts
@jaturontepjuk3046
@jaturontepjuk3046 Жыл бұрын
Nice background color, mate
@DevOpsToolkit
@DevOpsToolkit Жыл бұрын
Thanks
@dmitriinadein4733
@dmitriinadein4733 6 ай бұрын
That is awesome! Please post a link for next video, if possible. Many thanks, we are watching your channel with collegues.
@erikslorenz
@erikslorenz 2 жыл бұрын
Viktor I love your channel. Thanks for the content!
@iaroslavdavydiak6439
@iaroslavdavydiak6439 2 жыл бұрын
Awesome 🚀👍, as always🙂. I like your visualizations, it helps me to understand what you mean.
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
Thanks a lot for the feedback. Visualizations are new and, so far, we used them in only a couple of videos. I'll double down on them and use them more if they're helpful.
@amitsahuit
@amitsahuit 2 жыл бұрын
Wonderfully Explained.. You are awesome.
@SoftwareDevelopment-zy1wh
@SoftwareDevelopment-zy1wh 5 ай бұрын
Nice Explanation. Thanks
@denisstortidasilva3832
@denisstortidasilva3832 2 жыл бұрын
Great video! Excited to see more videos around architecture and integration. I like the technical videos too, but I've seen top edge tech adopted with poor architecture principles and it doesn't end well :) thanks!
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
In this video, I'm experimenting with a new format. Typically, I'd explain architecture/process/etc. first, and then go through the technical parts and a demo. This time, I thought to split those so the next one will be one possible implementation of the ideas presented in this video. I'm still not sure whether having it together or split makes more sense so I'll do both approaches and see the reactions before I choose to stick with one or the other.
@denisstortidasilva3832
@denisstortidasilva3832 2 жыл бұрын
@@DevOpsToolkit splitting is a great idea, as you can explore different approaches/technologies to solve the same pattern (eg. Async integration by using threads/workers at application level, versus async event driven messages + choreography/orchestration) . I thought this one could be even longer, as the concepts are not easy to explain. Looking forward to it! 😍
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
@@denisstortidasilva3832 Such feedback is very helpful in deciding how to organize future material. Thanks. As for length... It's very hard to decide long long videos should be. When I make 30+ min videos, some people say they're too long. When I make them shorter, some say that they'd like them to be longer. That's also one of the things I want to experiment with. I'll try creating videos with more varied length (from a few minutes up to 45 min.) and see what has better reception.
@erikslorenz
@erikslorenz 2 жыл бұрын
@@DevOpsToolkit I like the new content. I work in a smaller company and I think that a lot of people in a smaller company may not think this is valuable. But I spend a ton of time integrating services and having good architecture between services is incredibly helpful. I use a lot of Google pub sub. As soon as you find yourself with 6 or 7 or 12 applications you need to take a step back and evaluate.
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
@@erikslorenz It's normal for smaller companies not to think about practices that are designed for bigger operations. The problems typically occur when something small becomes bigger and teams do not take time to "step back and evaluate" the new situation but just keep going.
@narendra-u5t
@narendra-u5t 2 жыл бұрын
Great !! Keep up the good work Viktor.
@user-vx6zk5jj4e
@user-vx6zk5jj4e Жыл бұрын
Good quality of content, thanks!
@MrTouqeerhameed
@MrTouqeerhameed Жыл бұрын
Great video -This is a thing that i am looking for
@devopscraftsmanship9302
@devopscraftsmanship9302 2 жыл бұрын
Great content! I came across this channel this year. I wish I did earlier ❤
@user-js4ub3ef6n
@user-js4ub3ef6n 5 ай бұрын
Thanks a lot
@opelfahrer91
@opelfahrer91 Жыл бұрын
Really liked that video, thank you :)
@Fayaz-Rehman
@Fayaz-Rehman 2 жыл бұрын
Better than ever. Thank you for sharing.
@dmytroshchotkin2939
@dmytroshchotkin2939 2 жыл бұрын
This was a brilliant video!
@chikosan99
@chikosan99 2 жыл бұрын
Thanks a lot!💥 You have great content
@yassinemessaoud8619
@yassinemessaoud8619 2 жыл бұрын
Can't wait for the next video !
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
It's coming next Monday :)
@DaljeetSingh1
@DaljeetSingh1 Жыл бұрын
you are awesome !
@javisartdesign
@javisartdesign 2 жыл бұрын
thanks! great explanation this is a big such topic
@soubinan
@soubinan 2 жыл бұрын
Yeaaahhhhhh!!! Waiting for the next :)
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
It's already recorded and is currently going through the editing and animations phase. It'll be published next Monday :)
@AnkiteshSrivastava
@AnkiteshSrivastava Жыл бұрын
I don't understand, why you still haven't reached 100k mark
@DevOpsToolkit
@DevOpsToolkit Жыл бұрын
I guess that not doing any marketing and not focusing on newbies leads to much smaller number of subs. I'm working on this channel mostly because I enjoy it and certainly not as a business so I'm not doing what needs to be done to increase subs.
@mohamedaittaleb
@mohamedaittaleb 2 жыл бұрын
Great and easy explaination, Thank you, waiting for your video on Kafka ;) ---- am I the only one who use the Playback speed 1.5 xD ?
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
You're not the only one that watches with increased playback speed. I do not think Darin ever watched anything at 1x :)
@geraaksenov4688
@geraaksenov4688 2 жыл бұрын
Thank you for the great video! I have a question: in asynchronous communication, how can we prevent broadcasted event/message to be processed multiple times by different independent listeners? Because if we don't, events may be multiplied (e.g. event of putting a product in the basket will be picked by multiple processors and each of them will order this product from the storage).
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
Typically, events should be idempotent so that multiple handlings of the same event do not result in multiple records. Otherwise, it's hard to guarantee that events will be processed in the first place. That's why we normally adopt the at-least-once approach. That being said, you can set up the backend of the event to guarantee that an event will be picked up by a listener only once.
@geraaksenov4688
@geraaksenov4688 2 жыл бұрын
@@DevOpsToolkit By "backend of the event" do you mean the message broker?
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
You're right. I meant message broker. I should stop writing messages over my phone while crossing a street :(
@geraaksenov4688
@geraaksenov4688 2 жыл бұрын
@@DevOpsToolkit I appreciate your effort :) Thank you for the answers
@MrR3set
@MrR3set 5 күн бұрын
i want to do an admin service that will manage all admin actions across my apps. ADM will manage role authorization and admin logging (audit log). I was planning on using direct communication between services. Each service will have their own admin endpoints exposed just to the adm service. Do you still think eventd are better here?
@DevOpsToolkit
@DevOpsToolkit 5 күн бұрын
I can't answer that question without more info. What i can say is that direct communication is easier while events are more reliable abd scale better.
@ptdev6776
@ptdev6776 10 ай бұрын
So basically service mesh tools like Istio that are based on synch communication...are bad tools? Which should be the sense of these tools if synch communication is a bad thing?
@DevOpsToolkit
@DevOpsToolkit 10 ай бұрын
Sync communication is unavoidable. For example, a backend app needs to talk directly to the db.
@willnguyendev
@willnguyendev 2 жыл бұрын
How about a sync rest request need the result of second service? first service needs to send message directly to second service and wait for response, doesn't it?
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
It does, but not in the mode I used it. I used pub/sub while you want direct messaging.
@muratasarslan2359
@muratasarslan2359 Жыл бұрын
Very well explained, thanks 😃 What would you think using gateway when we need sync communication?
@DevOpsToolkit
@DevOpsToolkit Жыл бұрын
If you need sync communication, any service mesh should do.
@muratasarslan2359
@muratasarslan2359 Жыл бұрын
@@DevOpsToolkit what if the microservices are subgraphs in an Apollo Graphql Federation 2 ?
@DevOpsToolkit
@DevOpsToolkit Жыл бұрын
unfortunately, I haven't used Apollo 😔
@WilkoWenzel
@WilkoWenzel 2 жыл бұрын
Danke!
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
Thanks a ton!
@camaycama7479
@camaycama7479 9 ай бұрын
What can act as a broker in kubernetes? Say I have a dozen cluster in k3s, what service I can use as a broker?
@DevOpsToolkit
@DevOpsToolkit 9 ай бұрын
Try NATS.
@YourTechBudCodes
@YourTechBudCodes 2 жыл бұрын
Amazing video! Loved your take on how microservices communicate. I've made a playlist on this topic which I would love for you to checkout. I'd like to add one thing. You mentioned that HTTP is a synchronous protocol. While that's completely true, you can still use it for triggering async events. Similarly you can use AMQP to implement synchronous RPC calls. So the nature of protocols doesn't directly affect how your microservices communicate.
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
I think I said that a couple of times. The fact that one protocol is synchronous does not mean that it cannot be used asynchronously, and vice versa. Now, it's quite possible that even though I said that, I did not explain it well. I'll do my best to improve the way I explain in the upcoming videos.
@spottedmahn
@spottedmahn Жыл бұрын
What about, I want to GET ____? Post an event? That doesn’t seem right. What am I missing? 🤔
@DevOpsToolkit
@DevOpsToolkit Жыл бұрын
If you want to get something, that's a simple get from the service or, more often ,a database that has the info. Events are more about "i just posted this, whomever needs it, come and get it." Imagine it's Amazon that consists of many services and someone just added an item to the shopping cart. That specific service does not need to worry who else needs that info. It does not need to do anything but post an event knowing that whomever needs to do something with it will get it. It's about decoupling. Another example would be kubernetes itself. When you send a manifest to Kube API, an event is created. The API has no idea which controller is responsible to do something with it. Instead, controllers are listening to events and performing actions when it's one they are subscribed to. Otherwise, the API would have to have the logic of forwarding requests to a massive number of controllers or you, the user, would need to know which specific controller to talk to.
@puneetsaneja3007
@puneetsaneja3007 Жыл бұрын
How Synchronous microservices talk to each other on cloud i.e on AWS without using QUEUE. Suppose there are 2 microservices A& B which are deployed on AWS ec2 instance. I cant hardcode B endpoint inside A microservice. Bcz everytime Ec2 instance started , the IP gets changed.
@DevOpsToolkit
@DevOpsToolkit Жыл бұрын
In that case you would probably talk to those services through a fixed endpoint like ELB or ALB.
@puneetsaneja3007
@puneetsaneja3007 Жыл бұрын
@@DevOpsToolkit so u mean, instead of calling B microservice directly , we call load balancer which redirect our request to B. Right ?
@DevOpsToolkit
@DevOpsToolkit Жыл бұрын
Yes.
@emonymph6911
@emonymph6911 Жыл бұрын
I'm confused what a broker actually is, is it a database or a deployment service like Kubernetes or service like Dapr? Please make an independent video on brokers, and how to connect to them and make them communicate with other third party applications or APIs.
@zohaibsaeed4063
@zohaibsaeed4063 Жыл бұрын
Example Hive mq for mqtt.
@BPTScalpel
@BPTScalpel 2 жыл бұрын
I'm really confused about why you think sync is not performant and how exatcly it helps in your example at ~8 min. App1 is waiting for a response. How do you improve the latency of this response with async? If you truly care about performance in this example you actually make everything sync with long lived connection, don't you?
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
If you look at the performance of that request, you are right. But, if you look at the performance of the application as a whole or the whole system (especially at scale), waiting for responses is costly, especially if that means requests to multiple applications.
@saynay302
@saynay302 2 жыл бұрын
You can think of it like the difference between response time and throughput, especially under load. Sync calls are great, until they hit some threshold where all their threads are blocked waiting for an operation to complete, then they tend to explode. Synchronous operations are fine if you have a high certainty that they will be completed quickly. The issues can come if you have a chain of sync calls, as any point along that chain could get stuck / crash / etc. and force your sync calls to block until they time out. They also don't handle changing scale gracefully; if you have a number of requests in-flight and the system decides to scale-up the service you are talking to, those in-flight requests will not be able to take advantage of the new capacity. If those requests were instead sitting in a message queue, when new processing power came online they can be handled right away. Async has some tradeoffs though. It is generally more difficult to reason about. You often need to handle scenarios you do not in sync (like retransmits, or duplicate messages), and will generally not have the same guarantees around ordering.
@BPTScalpel
@BPTScalpel 2 жыл бұрын
@@DevOpsToolkit Yes, but you would still have to wait for the response even in an async architecture; it would just not be the responsibility of App1 but of a different consumer somewhere down the line. The fact that you need the response to continue does not disappear because you change protocols. Don't get me wrong: I love async for fire and forget scenarios, but saying sync is not performant by taking a RPC call as an example (what it is especially good at) is a bit weird. Now, if what you are saying is that you need more tools to make sync work for RPC at scale, I agree. You would need both clients and servers to be able to handle requests asynchronously, you would need to add a load balancer, retry mechanisms etc... all of which come out of the box with async but nothing can be more performant (i.e. provide a faster response) than sync for RPC in my opinion.
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
@@BPTScalpel You're right. I made a mistake by not explaining it well. A direct sync reqest/response is performant.
@susanasher6939
@susanasher6939 Жыл бұрын
Does the broker send the message out only to the applications that are supposed to hear the message, and one of the ones that hear the message responds and the one that responds first gets to do the task? Or, does the broker send out the message only to the applications that can do that certain thing that is being requested?
@DevOpsToolkit
@DevOpsToolkit Жыл бұрын
It all depends on how you configure the broker. Also, more often than not, they don't send messages but allow other processes to subscribe to messages of certain type/subject.
@susanasher6939
@susanasher6939 Жыл бұрын
@@DevOpsToolkit Thank you so much for answering and making it easy to understand this!
@bileldridi324
@bileldridi324 2 жыл бұрын
Really interesting topic ! if we use such a communication system, we can reach easily an important complexity in big projects. So how can we get the big picture of microservices communication ? Do you know some documentations tips or tools that can solve tis kind of problem ?
@DevOpsToolkit
@DevOpsToolkit 2 жыл бұрын
Tracing tools like Jaeger can help with that.
@razbuchnik6007
@razbuchnik6007 Жыл бұрын
Didn't answer the most important question: how to handle ETLs of duplicate data.
@DevOpsToolkit
@DevOpsToolkit Жыл бұрын
You mean that you are trying to store data that is not uniquely identifiable so you might end up storing more than one copy?
Microservices explained - the What, Why and How?
18:30
TechWorld with Nana
Рет қаралды 841 М.
IQ Level: 10000
00:10
Younes Zarou
Рет қаралды 13 МЛН
Challenge matching picture with Alfredo Larin family! 😁
00:21
BigSchool
Рет қаралды 24 МЛН
哈莉奎因以为小丑不爱她了#joker #cosplay #Harriet Quinn
00:22
佐助与鸣人
Рет қаралды 10 МЛН
Synchronous and Asynchronous Communication between Microservices
40:10
How to make Microservices Communicate?
10:24
YourTechBud Codes
Рет қаралды 39 М.
What is AsyncAPI?
7:22
IBM Technology
Рет қаралды 16 М.
What is microservices architecture?
16:21
DevOps Toolkit
Рет қаралды 9 М.
A Beginner's Guide to Event-Driven Architecture
37:28
Software Developer Diaries
Рет қаралды 9 М.
The Problem With Microservices
17:47
Continuous Delivery
Рет қаралды 431 М.
Running Event-Driven Pub/Sub Microservices In Kubernetes With Dapr
24:25
IQ Level: 10000
00:10
Younes Zarou
Рет қаралды 13 МЛН