I have a service (S1) that is deployed on kubernetes having multiple replicas (pods).
S1 requires some data from database (Cosmos Cassandra Api) for calculation.
This data is constantly updated by another service (S2).
There is a scheduler(@Scheduled) written in S1 codebase to fetch data from DB and keep it in memory (Hashmap) for faster calculation. Each pod now has its own copy of data in a HashMap stored internally.
Looking for change in design that can tackle the following problems as our pod count is going to increase and db update frequency will be more.
Instead of each pod polling for update from Db , can we use any event based or pub/sub out of the box solution. Checked Messaging Queues but not sure if each pod will be able to read same data.
Currently the polling is after every X mins, so at any time T there are some pods with updated data and some pods which are yet to get the latest data. Event based solution will reduce the gap for stale data.