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
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With