zoukankan      html  css  js  c++  java
  • Microservice Trade-Offs

    https://martinfowler.com/articles/microservice-trade-offs.html

    Many development teams have found the microservices architectural style to be a superior approach to a monolithic architecture. But other teams have found them to be a productivity-sapping burden. Like any architectural style, microservices bring costs and benefits. To make a sensible choice you have to understand these and apply them to your specific context.   

     

    Microservices provide benefits…

    • Strong Module Boundaries: Microservices reinforce modular structure, which is particularly important for larger teams.
    • Independent Deployment: Simple services are easier to deploy, and since they are autonomous, are less likely to cause system failures when they go wrong.
    • Technology Diversity: With microservices you can mix multiple languages, development frameworks and data-storage technologies.

    …but come with costs

    • Distribution: Distributed systems are harder to program, since remote calls are slow and are always at risk of failure.
    • Eventual Consistency: Maintaining strong consistency is extremely difficult for a distributed system, which means everyone has to manage eventual consistency.
    • Operational Complexity: You need a mature operations team to manage lots of services, which are being redeployed regularly.

    Eventual Consistency (Con)

    I'm sure you know websites that need a little patience. You make an update to something, it refreshes your screen and the update is missing. You wait a minute or two, hit refresh, and there it is.

    This is a very irritating usability problem, and is almost certainly due to the perils危险 of eventual consistency. Your update was received by the pink node, but your get request was handled by the green node. Until the green node gets its update from pink, you're stuck in an inconsistency window. Eventually it will be consistent, but until then you're wondering if something has gone wrong.

    Inconsistencies like this are irritating气人的 enough, but they can be much more serious. Business logic can end up making decisions on inconsistent information, when this happens it can be extremely hard to diagnose what went wrong because any investigation will occur long after the inconsistency window has closed.

    Microservices introduce eventual consistency issues because of their laudable值得赞赏的 insistence on decentralized data management. With a monolith庞然大物, you can update a bunch of things together in a single transaction. Microservices require multiple resources to update, and distributed transactions are frowned on (for good reason)不允许. So now, developers need to be aware of consistency issues, and figure out how to detect when things are out of sync before doing anything the code will regret.

    The monolithic world isn't free from these problems. As systems grow, there's more of a need to use caching to improve performance, and cache invalidation is the other Hard Problem. Most applications need offline locks to avoid long-lived database transactions. External systems need updates that cannot be coordinated with a transaction manager. Business processes are often more tolerant容忍的 of inconsistencies than you think, because businesses often prize availability more (business processes have long had an instinctive understanding of the CAP theorem).

    So like with other distributed issues, monoliths don't entirely avoid inconsistency problems, but they do suffer from them much less, particularly when they are smaller.

  • 相关阅读:
    【转】SQL时间函数
    C#操作Word完全方法
    出水芙蓉,风华绝代记民国才女林徽因
    梅超风:我就是那个多年以前的女子
    厉胜男
    南海恶神
    挪窝
    吴若权——洛可可动画电影馆
    美的慢箭
    机械公敌(I, Robot) 场景设定
  • 原文地址:https://www.cnblogs.com/chucklu/p/13050193.html
Copyright © 2011-2022 走看看