Shared State Module for Microservice Data Conflict Resolution
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
In single-spa applications constructed from microservice components, each microservice must independently access data, leading to increased computational load and potential conflicts from multiple sources, necessitating a mechanism for shared data access among microservices.
Innovation Solution
A shared state module acts as a common interface, configured to facilitate data sharing among microservice front-end modules, with a method involving processor-based receipt and transmission of data access instructions, using JavaScript computer-readable instructions and libraries like RxJS for update notifications, and Axios for HTTP request handling.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If each microservice independently accesses data, then microservices maintain independence and flexibility, but computational load increases and data conflicts occur
Solution Approach 1:
A shared state module is introduced as an intermediary component that manages data access for multiple microservices. This module maintains a centralized data store and provides controlled access to all microservices, eliminating the need for each service to independently query multiple data sources. The intermediary handles data retrieval, caching, and distribution, thereby reducing overall computational load while preserving microservice independence.
2Adaptability or versatility
If each microservice independently accesses data, then microservices maintain autonomy, but data consistency and conflicts arise
Solution Approach 1:
The shared state module serves as a mediator that ensures data consistency by providing a single source of truth for all microservices. It implements centralized data management with controlled access patterns, ensuring that all services retrieve consistent data versions. The module handles data synchronization and conflict resolution, maintaining reliability while allowing microservices to operate autonomously.
Solution Approach 2:
Multiple independent data access operations from different microservices are merged into a single centralized data management system. The shared state module combines data storage, retrieval, and synchronization functions into one unified component, ensuring that all microservices access the same consistent data state without direct peer-to-peer interactions that could lead to conflicts.
3Productivity
If a shared state module is introduced, then computational load is reduced and data consistency is improved, but system complexity increases
Solution Approach 1:
The shared state module is designed as a universal component that handles multiple functions including data storage, retrieval, caching, synchronization, and access control for all microservices. By consolidating these diverse functions into a single multi-functional module, the system reduces overall complexity compared to having separate data management mechanisms for each microservice.
Solution Approach 2:
The shared state module implements a copy mechanism where data is cached and replicated for efficient access by multiple microservices. Instead of requiring complex real-time synchronization protocols, the module creates and distributes data copies to subscribed services, simplifying the architecture while maintaining data consistency and improving access efficiency.
Data Source
AI summary
A method and a system for providing a shared state module that acts as a common interface for facilitating data sharing among microservice front-end modules that are being used in conjunction with one another within a single application are provided. The method includes: receiving an input that includes information that relates to a set of microservice modules to be utilized for constructing an application; uploading each of the set of microservice modules and a shared state module that is configured to facilitate data sharing; transmitting, to each of the set of microservice modules, an instruction that provides access to the shared state module; and when a particular microservice module requests a subset of data that is accessible via the shared state module, causing the requested subset of data to be received by the particular microservice module.


