Data Consistency Across Microservices

前端 未结 6 673
滥情空心
滥情空心 2021-01-30 02:41

While each microservice generally will have its own data - certain entities are required to be consistent across multiple services.

For such data consistency requiremen

6条回答
  •  忘了有多久
    2021-01-30 03:06

    "accordingly update the linked entities in their respective databases" -> data duplication -> FAIL.

    Using events to update other databases is identical to caching which brings cache consistency problem which is the problem you arise in your question.

    Keep your local databases as separated as possible and use pull semantics instead of push, i.e. make RPC calls when you need some data and be prepared to gracefully handle possible errors like timeouts, missing data or service unavailability. Akka or Finagle gives enough tools to do that right.

    This approach might hurt performance but at least you can choose what to trade and where. Possible ways to decrease latency and increase throughput are:

    • scale data provider services so they can handle more req/sec with lower latency
    • use local caches with short expiration time. That will introduce eventual consistency but really helps with performance.
    • use distributed cache and face cache consistency problem directly

提交回复
热议问题