Features Benefits micro services shortcomings

1. Micro Services with SOA What is the difference

 

It can be removed as a micro-services of ESB SOA. ESB is the center of the bus, graphic design SOA architecture should be a star, and is the center of micro-services to distributed software architecture.

 

2. advantage

 

Each service cohesive enough, small enough, the code is easy to understand, improve development efficiency; can be independently deployed between services, micro-service architecture allows continuous deployment possible; each service can extend their load balancing and database extensions, and every a service can be deployed according to their needs to the appropriate hardware servers; easy to expand the development team, you can for each service (service) components of the development team; improved fault tolerance (fault isolation), a memory leak does not make the whole service system failures; the system will not be a long-term restrictions on technology stack.

 

3. drawback

 

Developers want to deal with the complexity of distributed systems; developers to design the communication mechanism between the services, the need for multiple back-end service user case, the code is very difficult to achieve in the absence of a distributed transaction situation; involve multiple services directly automated tests also have considerable challenge; the complexity of service management in a production environment to manage multiple instances of different services, which means that the development team requires global co-ordination (PS: now there docker suitable solution to this issues); application of micro services architecture how to grasp the opportunity? For business clearly not rational, business data and processing power have not started before the outbreak of the growth of start-up companies need to consider micro-services architecture model, this time the most important is the rapid development, rapid deployment, rapid trial and error.

 

4. The micro-services architecture of the key issues

 

(1) communication mechanisms micro Services Architecture

 

Communication between the client and the server

In the monolithic application architecture, the client application (web or app) by sending an HTTP request to the server; however, in the micro-service architecture, the original monolith is replaced by a set of micro server service client in this case how to initiate a request it?

The client may initiate a request to the micro service RESTful HTTP, but there is this situation: a client in order to complete the business logic, the plurality of HTTP requests needs to be initiated, resulting in decreased system throughput, high latency wireless network plus the , it will seriously affect the client user experience.

To solve this problem, usually coupled with a role in front of the server cluster: API gateway, which is responsible for interfacing with the customer degree, and the client's request into a series of calls paired internal services. This also has the advantage is that the upgrade will not affect the service to the client, you only need to modify the API gateway. System Architecture FIG added after the API gateway as shown in FIG.

 

Communication between the internal service

 

There communication between the two kinds of internal services: HTTP protocol based on the synchronization mechanism (REST, RPC); asynchronous message based on the message queue processing mechanism (AMQP-based message broker).

 

Dubbo Alibaba open source distributed service framework, is a synchronous call, when too much of a system service, you need a registry to deal with service discovery issues, such as the use of such ZooKeeper configuration server address management services: services Publishers ZooKeeper want to send a request to record their service address and function names and other information on file; the caller to know that services related to information services, specific machine address query to get in ZooKeeper. This call mechanism synchronized intuitive and simple enough, but there is no "Subscribe - push" mechanism.

AMQP-based system representative of Kafka, RabbitMQ like. Such a distributed message handling system to subscribers and consumers decoupling, producer of news consumers do not need to be online; producers just need to send a message message to the message broker, and therefore does not require service discovery mechanism.

 

Two communication mechanisms have their advantages and disadvantages, in the actual system often comprises two communication mechanisms. For example, in a distributed data management, it is necessary to use both synchronous and asynchronous message processing mechanism HTTP mechanism.

 

(2) Distributed Data Management

 

Processing read request

 

Online store customer accounts there is a limit, when a customer tries to order, the system must determine whether the total order amount exceeds his credit limit. Credit card limit, orders responsible for the operation CustomerService managed by OrderService, therefore Order Service to request data from the Customer Service by RPC call; this approach can guarantee that every Order Service will get to the exact amount, the disadvantage is more than a single RPC call and Customer Service must remain online.

 

Another approach is, in OrderService store a copy of the credit card limit here, so there is no need to initiate real-time RPC requests, but also to ensure that a mechanism is needed - when Customer Service has a credit limit changes, should be promptly update stored here a copy of the Order Service.

 

Processing the update request

 

When a data residing on multiple services, it must ensure data consistency.

Distributed Transactions (Distributed transactions) is very intuitive to use distributed transactions, that is, to update the credit card limit on Customer Service, you must update the copy on other services, these operations are either full or do not do the whole. Use distributed transactions to ensure data consistency and strong, but will reduce the availability of the system - all related services must always online; moreover, many modern technology stack does not support transactions, such as REST, NoSQL databases.

 

When the credit card limit asynchronous update event (Event-driven asynchronous updates) Customer Service is based on change, it released one event to the "message broker (message Attorney)"; other services subscribed to this event after being prompted to update the data .

 

5. Nine characteristics of micro Services Architecture

 

Service components of:

 

In the micro-service architecture, we need to service component decomposition, outside service is a component of a process in which collaborate through communication protocols such as HTTP, rather than the traditional assembly that inserts into the type of way to work together, each service independently developed, deployed, can effectively avoid modifying a service due to the redeployment of the entire system.

 

By business organization team:

 

In the implementation of micro-services architecture requires a different team segmentation. Since each service is implemented for a specific business wide stack or full stack, the minutes of persistent storage for data, but also responsible for various functional areas of the user interface definitions across disciplines. So when faced with large-scale projects for micro-services team split split according to the method recommended more lines of business, on the one hand can effectively reduce internal friction modification services produced, on the other hand, teams can become more border It is clear.

 

Do attitude product:

 

In the micro-service architecture team, each team should be small ,, responsible for its entire life cycle in order to make the product, rather than the traditional project development as delivered to the testing, operation and maintenance for the target

 

Intelligent endpoint and dumb pipes:

 

Because each service is not a process, the mode of communication between components is changed, the method calls within the process had become a way of RPC calls will result in cumbersome communication between micro-services, making the system performance worse, so we need a more coarse-grained communication protocols:

 

In the micro-service architecture typically used at two services call the method:

 

(1) using HTTP RESTful API or lightweight messaging protocol, message passing with the service call at the trigger.

 

(2) by passing the message on the message bus a lightweight, reliable and some similar RabbitMQ asynchronous switching intermediates.

 

In the case of extreme emphasis on performance, there might use binary messaging protocols, such as protobuf

 

Decentralized governance:

 

Throughout the micro-service architecture, defined by the contract interface using lightweight, making our team specific technology platform service itself is no longer so sensitive, so that the entire micro-service architecture of the various components of the system will be able to choose different for different operational characteristics technology platform.

 

Decentralized management data:

 

In implementing micro-service architecture, want each service to manage its own database, which is decentralized data management, although decentralized data management makes data management more careful, let the data storage and optimal performance, but different database instance, data consistency has become one of the micro-service architecture problems to be solved, realized the difficulty of distributed transaction itself is very large, so the micro-service architecture, we were among more emphasis on service "None Rights "calls, and data consistency, only requires data in the final state is the same process can be.

 

Infrastructure Automation:

 

In the micro-services architecture, it is important from the outset developed a "continuous delivery" platform to support the entire implementation process;

 

Fault-tolerant design:

 

In the micro-service architecture, rapid detection of fault sources and possible automatic recovery service is designed to be taken into account, usually we all want to achieve Component Monitoring and logging in to each service. For example: service status dashboard, circuit breaker status, throughput, delay critical data network.

 

Evolutionary Design

 

In the early days, in the manner of a monomer system design and implementation, on the one hand the amount of the initial body system and will not be great, building and maintenance costs are not high. On the other hand, the initial core business is usually not changing dramatically at a later stage.

 

With the development of the system or business, a number of architects will often change the content of a certain time or have the effect of micro processing service, and gradually changing the original module in the monomer system gradually spun off, and stable unlikely to change modules to form a core service exists in the entire micro-architecture.

 

6. The micro-services design principles are as follows:

 

● Single Responsibility Principle

Each refers to a micro-service module, only care about their own business rules. Such as order module concerned only with orders related businesses, does not involve the logic of other services.

● principle of self-service

Development of each micro-service module, the need for their own development, testing, operation and maintenance, deployment, which will be a separate stack, and all have their own database, put it as a completely separate project do not involve other unrelated business.

● lightweight communication principles

Micro communication protocol services need cross-platform, cross-language communication protocol, because the service is not bound to micro technology stack, whether using Java, PHP or .net to develop Web systems, communication between them must go distinctive language .

● Interface Specification Principle

The aforementioned micro-service "interface to adjust the high cost," then how do to avoid it? We should begin planning a good micro-service module is what kind of model, try to avoid changes to the A interface will lead to changes in this situation B interface.

Guess you like

Origin www.cnblogs.com/ITnoteforlsy/p/11756360.html