Architecture topics for "three"

Architecture topics for "three"

Consistency

  In front of "topics for a framework" and "architecture topics for two" topics for the evolution of the service from the service to the micro-architecture, and affirmed the service and micro-services architecture is the same strain. Micro services based on service oriented architecture, service-oriented details and programs have been optimized and refined, highlights the non-centralized micro-management services architecture, to achieve agile development and automation of service by effectively splitting deploy, and under massive user's request, to improve the services at the micro-architecture finer-grained level of scalability.

  However, micro Services Architecture is not a panacea that can be said is a double edged sword, we enjoy the convenience it brings, it would also encounter problems inconsistencies between data and services, multi-service architecture for the next a service through non-reliable network communications, how to make efficient communication and collaboration between services, how to resolve inconsistencies between system status and other issues, it can be said that the problems we in the use of micro-services architecture have to face.

1. What is the consistency

  Consistency is an abstract concept, has different meanings in different scenarios, in the traditional IT era, usually refers to the consistency of strong consistency, consistency before the age of the Internet digression, let's look at the characteristics of the Internet age:

  • Large amount of information the Internet age, require very powerful computing capabilities
  • Age of the Internet user requires quick response speed, but also requires a certain outward expansion index (horizontal scaling)

  After the adoption of the characteristics of these two Internet era, we find that single-node server can not meet people's needs, began pooling service node. But not better pooling of (saying goes, many people may not be able to solve all the problems), we have an orderly, rational allocation of tasks and effectively manage, so the most discussed topic is the split in the Internet age . Split and is generally divided into horizontal and vertical resolution which not only refers to the database or cache, main idea and a logic of the divide and conquer

 Split level: Since a single node can not meet the performance requirements, the need to expand into multiple nodes, with consistent functionality across multiple nodes to form a pool service, a service request node part of the amount, all the nodes of large-scale co-processing high amount of concurrent requests.

 Vertical resolution: in accordance with the function split to split a single complex function into a plurality of simple features, since each single functional responsibilities, simple, and maintenance such change becomes easier, simple and safe, it is more Ease of product iterations, is also capable of quick release and on-line quickly.

  In such an age of the Internet, consistency refers to the weak consistency between distributed services technology, including data consistency and consistency of application systems.

  Either horizontally or vertically split, specific issues have been resolved under certain scenarios, however, the biggest problem of the system or service system after the split is consistency.

2, to solve the problem of consistency ideas

  1、ACID

    How to ensure the consistency of the problem? When we learn relational database to learn the principles of ACID, ACID be here for a simple introduction.

    A: Atomicity

    C: Consistency

     I: Isolation

    D: Persistence

    ACID properties of database with support strong consistency, strong consistency on behalf of the database itself does not appear inconsistent, each transaction is atomic (either success or failure), your transactions are isolated from each other is not affected. The final state is persistent. Therefore, the database will be the transition from a clear state to another state clearly, in the middle of the temporary state is not the case. If the automatic repair will occur in a timely manner, and therefore is strongly consistent. However, mentioned earlier, most of the projects have the Internet on a massive scale, characteristic of high concurrency, you must use split. Even the use of a relational database, a single difficult to meet performance requirements of storage and throughput. Due to limitations of business rules, we can not be assigned to the same database data fragmentation, then we need to achieve eventual consistency.

  2、CAP 

  Because of the systems or data were split, our system is no longer a stand-alone system, but a distributed system. There are three elements for CAP principle of distributed systems.

  C: consistency. All backup data in distributed systems in a unified time has the same value, the data at the same time to read all of the nodes are the latest copy of the data. (Consistency)

  A: availability, good response performance. Full availability refers Any fault model, and the service will be processed within a limited response time. (Availability)

  P: partition tolerance. Despite missing part of the message on the network, but the system continues to work. (Partition tolerance)

  CAP Rationale, any distributed system can only meet the above two points, three can not be taken into account. Since the relational database is a single node without replication, and therefore does not have a partition tolerance, but with consistency and availability. The distributed services system needs to meet the partition tolerance, which requires us to choose between a trade-off in usability and consistency.

  3、BASE

  eBay architect Dan Pritchett from practice summary of large-scale distributed systems, published an article on the theory put forward BASE ACM, BASE theory is an extension of the theory of the CAP, the core idea is that even if unable to do so strong consistency (Strong Consistency, CAP consistency is strong consistency), but the application can use the appropriate way to achieve eventual consistency (Eventual consitency). (BASE idea to solve the problem of distributed systems proposed CAP can not have both consistency and availability)

  ACID BASE ideas and principles very different, it satisfies the principle of CAP, obtained by sacrificing the availability of strong consistency, generally applied to the service application layer of the system or a large data processing system, by reaching the final consistency to try to meet the vast majority of business demand.

  Three elements BASE thought.

  BA: Basic available (Basically Available).

  S: soft state, the state may not be synchronized (Soft State) over a period of time.

  E: final consistency within a certain period of time, to reach the final data consistency can be. (Eventually Consistent)

  BASE is a way to achieve a soft state ideology, basic available and consistency is the ultimate goal. Thought to achieve due to the BASE system does not guarantee strong consistency, the system transient inconsistency may be present during the processing of the request, the inconsistency in a short period of time, request a temporary state, the system performing the processing in each step, by recording each temporary state, in case of system failure may continue to process requests from the intermediate unfinished state or return to the original state, and ultimately achieve a consistent state.

  With BASE idea as a basis, we are dismantling of complex distributed transaction, for each of these steps record the state, the problem may continue to perform tasks according to state records, reaching the final consistency.

Description:

  1, reference books: "Distributed Services Architecture: Principles, Design and combat"

  2, if wrong place, please feedback. After a comprehensive change.

 

Guess you like

Origin www.cnblogs.com/haoxiaozhang/p/11184276.html