Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling UI in Event-driven Microservices

I have concern when handling communication between Frontend and Backend in Event-Driven Microservices architecture:

Use case: User creates new product then he go to product list to check. The flow will be as below enter image description here

My question is how the UI handle product list in this case? The new product may not be present because the read side haven't processed new product event.

like image 738
Barcelona Avatar asked Jul 17 '19 10:07

Barcelona


People also ask

Can microservices have UI?

Microservices architecture often starts with the server-side handling data and logic, but, in many cases, the UI is still handled as a monolith. However, a more advanced approach, called micro frontends, is to design your application UI based on microservices as well.

What interaction styles are available using an event-driven architecture?

There are three general styles of event processing: simple, stream, and complex. The three styles are often used together in a mature event-driven architecture.

What is event-driven in microservices?

An event-driven architecture uses events to trigger and communicate between decoupled services and is common in modern applications built with microservices. An event is a change in state, or an update, like an item being placed in a shopping cart on an e-commerce website.


1 Answers

That's possible since you are using CQRS Pattern. Generally in distributed system we prefer eventual consistency over strong consistency to make it scale-able. So there's a trade-off.

In your scenario really depends how long it would take to reflect change from Write to read database but i assume it shouldn't be long. If it is then you have to manage it accordingly on UI end e.g. As soon as your enter the product in your system you may need to return ID, that your UI would poll in read database and meanwhile user has wait screen. Or better you may have to use Websockets to avoid polling and update UI as soon as product is available on read side

like image 160
Imran Arshad Avatar answered Oct 06 '22 02:10

Imran Arshad