I'm working on a project developed with ASP.NET, using Blazor for the frontend and Web API for the backend.
In our backend architecture, we use heterogeneous databases for read and write operations:
- Write Database: Each service has its own private database.
- Read Database: A data warehouse that provides pre-aggregated cross-service data.
Here's the problem:
- When a user performs an action on the frontend, the backend updates the write database.
- The response is returned to the user immediately after the write operation.
- The data synchronization to the read database is done asynchronously.
Due to this async process, there is a time window where the frontend might display stale data from the read database, leading to user confusion, incorrect actions, or repeated operations.
- Directly reading from the write database to mitigate this issue is not feasible.
- Considering a mechanism like a
TraceIdto track the update status and notify the frontend when the read database is updated.
Question:
What strategies can we employ to handle this inconsistency period effectively? Is using a TraceId a viable solution, or are there other design patterns or best practices that can help resolve this problem?
Any advice or suggestions would be greatly appreciated.