There are multiple microservice that consume common data. So if i microservice is accessing data then it should be cache at 1 place and other microservice can refer to that cache data . Please help me with architecture design. Is there any other way we can keep common data. ( data will be decided at runtime it is not static data ) Thanks
There is an option for a centralized cache but I am not sure how that will be the architecture and which cache will be suitable
All you need is a centralized storage engine. There are multiple options you can choose from:
A distributed cache system, such as Redis or Memcache, is used for high-performance scenarios with a simple key-value data structure. I would recommend Redis as a cache system since it supports more complex data structures like hash, list, and sorted set, and it also provides data persistence.
A centralized database, like MySQL, is used for structured data and durable data storage, utilizing disk-based data persistence. MySQL also supports ACID and transactions, which ensure data consistency and integrity. Generally, MySQL's performance is not as good as Redis under similar conditions.
For your microservices architecture, you can implement a data access service in front of your data storage to avoid direct connections from multiple services, protecting your data by not exposing the data source to all services. All other services will then request data from the data access service to access the shared data.
Alternatively, if simplicity is not a concern, you can directly connect to the data source with all microservices in need