Introduction to MicroServices and micro-services in ASP. NET Core Combat Project series

Source: Internet
Author: User
Tags continuous integration tools

0. Catalogue

Overall architecture directory: ASP. NET core distributed project-Directory

One, micro-service selection

In the technical selection of micro-service architecture, it is the least expensive to take "no intrusion" and "community active" as the main points of view, in the future, when upgrading to atomic service architecture, Quantum service architecture, or even back to monolithic architecture.

Software development only needs to be assembled and no longer needs to be developed from scratch.

Selection can refer to Captain Zhang's article: Https://mp.weixin.qq.com/s/UIFjm7W6bDfdmjpeMVJtqA

second, what is the micro-service architecture?

Each micro-service is a part and uses these parts to assemble different shapes. MicroServices architecture is to break down a large system into multiple small systems with a single function, and use simple methods to make multiple small systems work together into a large system.
Services are coordinated and co-ordinated to provide users with the ultimate value, each of which runs in its own independent process, serving as a lightweight communication mechanism between services, often based on the HTTP protocol's RESTful API or RPC.
Core idea: divide large system into small system.

third, micro-service Components

Service registration: The service provider registers its own calling address with the service registry, making it easy for service callers to find themselves.

Service discovery: The service caller finds the address of the service it needs to invoke from the service registry.
Load Balancing:
Service Gateway: The Service gateway is the only entry for a service invocation.
Configuration Center:
API Management:
Integration Framework: MicroServices components are serviced externally by a single, integrated framework that integrates all microservices components (especially management-side components) into a unified interface framework in a configuration that enables users to use the system in a unified interface.
Distributed transactions: ensuring consistency of data
Call chain: Records the microservices that are invoked when a business logic is completed and displays such a serial or parallel call relationship. In case of system error, it is convenient to find the error point. Monitoring
Support platform: Because of the micro-service, the system becomes more fragmented, the deployment of the system, operations, monitoring, etc. are more complex than the monolithic architecture, you need to use automation.

Four, micro-service architecture advantages? Why use a microservices architecture?

The comparison between micro-service and monomer can be seen:

When do you choose a microservices service?

From a personal point of view, there are three scenarios to consider using microservices
1, large-scale, team of more than 10 people
2. High complexity of business, more than 5 sub-modules of the system
3, need long-term evolution, project development and maintenance cycle more than six months

v. Rapid experience of micro-service architecture

Four steps to develop with microservices Simple mode:
1, the use of the existing technology system in the organization to develop a single role of micro-services
2. The service provider registers the address information with the registry, and the caller pulls down the service address from the registration center.
3. Expose the service APIs to portals and mobile apps through the portal backend (service gateway).
4. Integrate the management side module into the unified operation interface.

vi. operation and Maintenance

Infrastructure: auto-build, automatic deployment, log center, health check, performance monitoring, and more
GITLAB-CI/CD, JENKINS+GITLAB-CI/CD: Automating Deployment
K8S&DOCKER+JENKINS&PIPELINE+GITLAB--CI/CD: Automating Deployment
ELK: Log
Zipkin/skywalking: micro-service Monitoring

Vii. Summary

We only need to understand the registry, service discovery, load balancing, service gateways and management-side integration frameworks at the development level, prepare continuous integration tools, configuration centers, and monitoring alarms at the operational level, so you can easily land a micro-service architecture and enjoy the benefits of a microservices architecture. I wish you all a pleasant stay.

Viii. Development and governance of micro-service architecture API

1, open to the Internet users call API needs in the API Gateway plus authorization, authentication, current limit, concurrency, statistics, billing and other functions

2, Intranet Environment: provide to the intranet of other micro-service calls API.

1, intranet environment API Development

1, need to consider whether to use the HTTP API or RPC?

HTTP API:
Refers to the simple HTTP protocol-based API, the specific example is the MVC controller,
Http://127.0.0.1/helloworld

Rpc:
Remote procedure calls, most of which are remote calls to Socker communication methods, can also use the HTTP protocol to implement RPC calls, such as GRPC.

HTTP simple, RPC socket-based RPC performance is better. But I finally chose the HTTP API to use.

2, HTTP API performance is sufficient to support most projects

The protocol throughput of RPC is several times the HTTP performance, such as Protobuf, Thrift, Kyro, Dubbo
etc, the performance difference between HTT and RPC is not the main problem considering the factors such as technology stack, cost, stability, ease of use, maintainability, and business scenario.

Ix. How to ensure the consistency of data in the micro-service architecture

Take the e-commerce platform as an example, when the user orders and payment, the system needs to modify the status of the Order and
and increase user loyalty. Since the system is based on a microservices architecture, the payment service, order service and Integration services are separated, and each service has a separate database for data storage. When the user pays successfully, whether to modify the order status failure or increase the points failed, will result in inconsistent data.

However, under the MicroServices architecture, each microservices has its own database, and the system of MicroServices architecture cannot simply satisfy the ACID, we need to look for a data consistency solution under the MicroServices architecture:

The CAP refers to a distributed system that contains three elements: consistency (consistency), availability (availability), Partition tolerance (partition fault tolerance), and none of the three can be combined.
C: All data changes are synchronized
A: Correct corresponding user request within an acceptable time frame
P: Partition fault tolerance, that is, a node or network partition failure, the system can still provide services to meet the consistency and availability.
In the distributed system, in order to guarantee the partition fault tolerance of the module, we can only balance the data strong consistency and usability. In a certain period of time, the data may be inconsistent between the modules, but by automatic or manual compensation can achieve the final agreement.

Share how we ensure the data consistency of our microservices architecture:

1, Reliable Message final consistency (for scenarios where cross-platform technology stacks are not uniform)

Two-phase commit with MQ components, involving three modules:
A, upstream application, execute business and send MQ messages
B, reliable messaging services and MQ messaging components that coordinate the delivery of upstream and downstream messages and ensure consistency of upstream and downstream data.
C, downstream applications, monitoring MQ messages and performing their own business.

2. TCC Scheme

Three modules involved: main business, from business, activity Manager
1. The primary business service calls all the try operations from the business service, and logs all from the business service in the Activity manager, respectively. When all practitioner service try succeeds or one practitioner service try fails, it enters the second stage.
2. The Activity Manager performs a confirm or cancel operation based on the try result of the first stage of the practitioner service. If the first phase of all the try succeeds from the business service, then the collaborator invokes all the confirm operations of the practitioner service, otherwise, calls all cancel operations from the business service.
Confirm failure: Rolls back all Confirm operations and executes the cancel operation.
Cancel failed: The automatic cancel mechanism is provided from the business service to ensure that the cancel succeeds.

Reference Address:

Captain Zhang article: Https://mp.weixin.qq.com/s/UIFjm7W6bDfdmjpeMVJtqA

Document reference Address: "MicroServices architecture starting from 0"

Document: "MicroServices architecture from 0"

asp:787464275 Welcome Dabigatran AC
If you think this article is good or something, you can click on the "recommend" button in the bottom right corner to support the spirit, because this support is the biggest motivation for me to continue to write and share!

Louieguo
Disclaimer: Original Blog Please keep the original link in the reprint or at the beginning of the article with my blog address, such as found errors, welcome criticism. Generally reproduced in my article, can not set up a reward function, if there are special needs please contact me!

Introduction to MicroServices and micro-services in ASP. NET Core Combat Project series

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.