Update central cache with different system data change in microservices scale architecture









up vote
0
down vote

favorite












We're building a microservice system which new data can come from three(or more) different sources and which eventually effects the end user.

It doesn't matter what the purpose of the system for the question so I'll really try to make it simple. Please see the attached diagram.



Data can come from the following sources:




  1. Back-office site: define the system and user configurations.


  2. Main site: where user interact with the site and make actions.


  3. External sources data: such as partners which can gives additional data(supplementary information) about users.

The services are:




  1. Site-back-office service: serve the back-office site.


  2. User-service: serve the main site.


  3. Import service: imports additional data(supplementary information) from external sources.


  4. User cache service: sync with all the above system data and combine them to pre-prepared cache responses. The reason for that is because the main site should serve hundreds of millions of user and should work with very low latency.

The main idea is:



  1. Each microservice has its own db.

  2. Each microservice can scale.

  3. Each data change on one of the three parts effects the user and should be sent to the cache service so it eventually be reflect on the main site.

  4. The cache (Redis) holds all data combined to pre-prepared responses for the main-site.

  5. Each service data change will be published to pubsub topic for the cache-service to update the Redis db.

  6. The system should serve around 200 million of users.

So... the questions are: .



  1. since the User-cache service can(and must) be scale, what happen if, for example, there are two update data messages waiting on pubsub, one is old and one is new. how to process only the new message and prevent the case when one cache-service instance update the new message data to Redis and only after another cache-service instance override it with the old message.

  2. There is also a case when the Cache-service instance need to first read the current cache user data, make the change on it and only then update the cache with the new data. How to prevent the case when two instances for example read the current cache data while a third instance update it with new data and they override it with their data.


  3. Is it at all possible to pre-prepare responses based on several sources which can periodically change?? what is the right approach to this problem?



    System architecture diagram











share|improve this question

























    up vote
    0
    down vote

    favorite












    We're building a microservice system which new data can come from three(or more) different sources and which eventually effects the end user.

    It doesn't matter what the purpose of the system for the question so I'll really try to make it simple. Please see the attached diagram.



    Data can come from the following sources:




    1. Back-office site: define the system and user configurations.


    2. Main site: where user interact with the site and make actions.


    3. External sources data: such as partners which can gives additional data(supplementary information) about users.

    The services are:




    1. Site-back-office service: serve the back-office site.


    2. User-service: serve the main site.


    3. Import service: imports additional data(supplementary information) from external sources.


    4. User cache service: sync with all the above system data and combine them to pre-prepared cache responses. The reason for that is because the main site should serve hundreds of millions of user and should work with very low latency.

    The main idea is:



    1. Each microservice has its own db.

    2. Each microservice can scale.

    3. Each data change on one of the three parts effects the user and should be sent to the cache service so it eventually be reflect on the main site.

    4. The cache (Redis) holds all data combined to pre-prepared responses for the main-site.

    5. Each service data change will be published to pubsub topic for the cache-service to update the Redis db.

    6. The system should serve around 200 million of users.

    So... the questions are: .



    1. since the User-cache service can(and must) be scale, what happen if, for example, there are two update data messages waiting on pubsub, one is old and one is new. how to process only the new message and prevent the case when one cache-service instance update the new message data to Redis and only after another cache-service instance override it with the old message.

    2. There is also a case when the Cache-service instance need to first read the current cache user data, make the change on it and only then update the cache with the new data. How to prevent the case when two instances for example read the current cache data while a third instance update it with new data and they override it with their data.


    3. Is it at all possible to pre-prepare responses based on several sources which can periodically change?? what is the right approach to this problem?



      System architecture diagram











    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      We're building a microservice system which new data can come from three(or more) different sources and which eventually effects the end user.

      It doesn't matter what the purpose of the system for the question so I'll really try to make it simple. Please see the attached diagram.



      Data can come from the following sources:




      1. Back-office site: define the system and user configurations.


      2. Main site: where user interact with the site and make actions.


      3. External sources data: such as partners which can gives additional data(supplementary information) about users.

      The services are:




      1. Site-back-office service: serve the back-office site.


      2. User-service: serve the main site.


      3. Import service: imports additional data(supplementary information) from external sources.


      4. User cache service: sync with all the above system data and combine them to pre-prepared cache responses. The reason for that is because the main site should serve hundreds of millions of user and should work with very low latency.

      The main idea is:



      1. Each microservice has its own db.

      2. Each microservice can scale.

      3. Each data change on one of the three parts effects the user and should be sent to the cache service so it eventually be reflect on the main site.

      4. The cache (Redis) holds all data combined to pre-prepared responses for the main-site.

      5. Each service data change will be published to pubsub topic for the cache-service to update the Redis db.

      6. The system should serve around 200 million of users.

      So... the questions are: .



      1. since the User-cache service can(and must) be scale, what happen if, for example, there are two update data messages waiting on pubsub, one is old and one is new. how to process only the new message and prevent the case when one cache-service instance update the new message data to Redis and only after another cache-service instance override it with the old message.

      2. There is also a case when the Cache-service instance need to first read the current cache user data, make the change on it and only then update the cache with the new data. How to prevent the case when two instances for example read the current cache data while a third instance update it with new data and they override it with their data.


      3. Is it at all possible to pre-prepare responses based on several sources which can periodically change?? what is the right approach to this problem?



        System architecture diagram











      share|improve this question













      We're building a microservice system which new data can come from three(or more) different sources and which eventually effects the end user.

      It doesn't matter what the purpose of the system for the question so I'll really try to make it simple. Please see the attached diagram.



      Data can come from the following sources:




      1. Back-office site: define the system and user configurations.


      2. Main site: where user interact with the site and make actions.


      3. External sources data: such as partners which can gives additional data(supplementary information) about users.

      The services are:




      1. Site-back-office service: serve the back-office site.


      2. User-service: serve the main site.


      3. Import service: imports additional data(supplementary information) from external sources.


      4. User cache service: sync with all the above system data and combine them to pre-prepared cache responses. The reason for that is because the main site should serve hundreds of millions of user and should work with very low latency.

      The main idea is:



      1. Each microservice has its own db.

      2. Each microservice can scale.

      3. Each data change on one of the three parts effects the user and should be sent to the cache service so it eventually be reflect on the main site.

      4. The cache (Redis) holds all data combined to pre-prepared responses for the main-site.

      5. Each service data change will be published to pubsub topic for the cache-service to update the Redis db.

      6. The system should serve around 200 million of users.

      So... the questions are: .



      1. since the User-cache service can(and must) be scale, what happen if, for example, there are two update data messages waiting on pubsub, one is old and one is new. how to process only the new message and prevent the case when one cache-service instance update the new message data to Redis and only after another cache-service instance override it with the old message.

      2. There is also a case when the Cache-service instance need to first read the current cache user data, make the change on it and only then update the cache with the new data. How to prevent the case when two instances for example read the current cache data while a third instance update it with new data and they override it with their data.


      3. Is it at all possible to pre-prepare responses based on several sources which can periodically change?? what is the right approach to this problem?



        System architecture diagram








      caching scale microservices enterprise-architect google-cloud-pubsub






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 17 hours ago









      tomn

      654




      654



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237306%2fupdate-central-cache-with-different-system-data-change-in-microservices-scale-ar%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237306%2fupdate-central-cache-with-different-system-data-change-in-microservices-scale-ar%23new-answer', 'question_page');

          );

          Post as a guest














































































          Popular posts from this blog

          27

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          Category:Rhetoric