0

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.

  1. 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.

  2. 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.

3
  • What's the limitation that you'll run into by increasing the pod count? Have you looked into expanding the size of the Cassandra cluster to handle the additional updates? Commented Jul 18, 2023 at 8:05
  • The limitation is clearly mentioned in 2nd point, some pods have updated data while for other pods the scheduler is still to run thus having stale data. If stale data pods serve traffic then the results will be inconsistent with pods having udpated data.
    – Lord Nick
    Commented Dec 17, 2023 at 8:26
  • Perhaps I'm misunderstanding something - from the description it sounds like the service is already using multiple pods, so why isn't this happening under the existing solution? What existing mechanism is preventing the pods from having inconsistent data, and at what specific point will that existing mechanism cease to work? Commented Dec 17, 2023 at 10:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.