Architect monologue, micro-services architecture is such that

2020, and many small children on the micro partner services is still relatively unknown, said many people may not believe it, in fact, the concept of micro-services as early as 2012, it brought up, after all these years of development, it has now become very business the mainstream of architectural options. Today, I come to take you to explore past lives under micro services, and how landing in .Net Core. (Long article under the full-text catalog, all handwritten, Pat! Want peace of mind can also scan code to see the video version of the commentary).

Article directory

VIP- lazy channel

I also prepared a intimate live video commentary! Read the article does not go too long? Figure receive video directly on the scan code, hear me tell you to listen ~

Past and Present micro services

And micro-services architecture relative, called monomers architecture. This is our most familiar way of development, is a business project to get the whole process, which is completed in the same process. With the development of business, the amount of data concurrency and up, each system typically will select the right split vertically split, the monomers still architecture.

After a vertical split, the subsystem can independently do cluster, greatly enhance the carrying capacity. But with the further development of business, subsystem increasingly bloated, and according to 28 principles, in fact, 80% of the requests are concentrated in 20% of the business, different subsystems also have a lot of duplicate functional blocks. Ever since distributed was born, the demolition of the high-frequency repetitive functions into separate service deployment, various systems are done by calling the service.

Distributed split out a separate service deployment and maintenance, both completed the multiplexing function, but also ensures high availability and scalability of high-frequency service, representing more productive. However, to be crowned shall inherit their weight, caused by problems in distributed with the value it provides as much, such as distributed locks, consistency, availability, complexity and other terrible problems.

Over time, the business Forced technological progress, in large data requirements of high concurrency, distributed technology slowly began to mature, for a variety of problems have formed an effective way, then it became a distributed system architecture design the conventional means. To complete a service based on the decoupling of the business, providing high availability and scalability features to meet the growing business needs. With the split of business, more and more fine grain size, a new appellation micro-services (Microservice) came into being!

What is a micro-service architecture? I understood as a style of architecture of the system, based on the small size of the service to complete decoupling of the business, business processes will be split into multiple service assembly. Like the previous three-tier architecture inside, a business will call multiple BLL method, and now replaced by a call to multiple services. This is micro-services, of course, small children seriously think partners will find, really want to micro-landing service, too many questions! Here, I will take under .Net Core technology stack, to the problems of micro Services Architecture landing and to explore all solutions!

Floor micro Services Architecture

First, the inter-process communication: this is the basis for building micro services, usually have the following three categories:

1

Third-party storage shared communications (database / Redis / queue, etc.) based on

2

Http protocol-based services (WebService / WCF / WebApi)

3

Remote call mode (under RPC and .Net Core at FX gRPC)

Second, the service registration and discovery:

Micro-service architecture is built on the basis of the underlying service instance, you must be to ensure highly available and dynamically scalable services through the cluster, so the service registration, service discovery, health checks, abnormal offline functions are required, may be in the .Net Core consider choosing Consul (preferred), etcd or ZooKeeper.

Third, the gateway Gateway

Micro-service architecture supports multi-client shared service, and a number of underlying number of services, not all are exposed to external clients (security risk / public IP), and multi-client service instance can not be maintained indefinitely address, so gateway gateway is a must! Like management mode facade Façade good underlying services, mapping the underlying service by routing instance, the client shall be to complete the service call through the gateway. Furthermore, since the requests are away from the gateway, you can also complete the authentication authorization gateway here, current limiting, fuse, demotion and other advanced features.

Fourth, Authentication Authorization

These are the system architecture, functional requirements are down

Fifth, transient Troubleshooting

When really to write code, you will always find the service call does not call the method so easy, because the network can cause all sorts of accidents, delays, etc., requiring an elegant way to perform a retry timeout processing, fault recovery strategy, currently under .Net Core recommended Polly, common application is integrated into the gateway or AOP mode is inserted into the client inside.

Sixth, the distributed track

A request would involve multiple services, but also depend on the service itself, the entire request path constitutes a net call chain, imagine actually very afraid! Once a node abnormalities occur throughout the call chain, the stability of the entire call chain will be affected, therefore have to have tracking requests, performance analysis tools to quickly locate and fix the problem. SkyWalking (recommended), Cat, Zipkin, Pinpoint are optional, not here suggest that you create the wheel of their own.

Seven, log collection and analysis

Log in micro system log service is not so simple stand-alone, multi-service node vast, complex dependencies calling relationships, will bring a flood of log, an excellent set of distributed log collection and analysis framework is necessary to start, here I we recommend that ExceptionLess, start with simple information is complete.

Eight, unified configuration center

Configuration management platform is essential, so much so multi-cluster service, a personal management of the meat will be mad. Apollo can centralize management applications in different environments, different cluster configuration, the configuration changes can be pushed to real-time application side, and have standardized permissions, process control and other characteristics, is developed by the frame departments Ctrip open source configuration management center, .Net community pride, thumbs up!

Nine, distributed lock

Under monomer architecture, multi-threaded operating the same object can be used to lock the lock to ensure that only one thread can enter the next micro-architecture multi-service process, how control? The core idea is based on third party shared data access plus exclusive logic to complete control, like database / Nosql / Consul and other media can be. In practice, Redis is preferred not to explain.

Ten, distributed transactions

CAP had a saying, in the case of a distributed, availability and consistency of the system is unable to satisfy both. Under the micro-service system, a service request requires collaboration node N services, availability is the highest priority, otherwise the system is not functioning. That's how the data consistency how to do? Current mainstream model has three kinds, 2PC / 3PC, TCC and local news table, before a sacrifice to safeguard the availability of consistency, with less data protection are behind eventual consistency. Select the current mainstream Internet companies is based on a distributed transaction message queue implementation in the figure below.

Further down is the release deployment

Eleven, Jenkins-CI / CD

Continued delivery of continuous integration (CI / CD) is the core of agile development in micro Services Architecture is also standing. Simply put, the code branches can continue to merge into the new features, can continue the delivery of outputs to the downstream, so that the progress of the project visible. But think about meditation thing you know there are a lot of trouble, so all this to the professional tools to complete, Jenkins worth having.

Twelve, Docker container deployment

Micro-service architecture, the need to quickly start the service instances, systems support different environments, different operating environments, all kinds of service instances in different languages, independent of the physical server is not realistic, cost virtualization technology is too high, fast sandbox environment + + efficient use of resources can be copied quickly start Docker container of choice, Build Once, Run AnyWhere! not docker programmer, not a good engineer a.

XIII container arrangement Kubernetes

With Docker, we can do anything relaxing expand service instance, Queer, container instance may swell to the point where you can not control, probably a month after the team no one can figure out the intricacies of the relationship between service and container. So you need a management tool that Kubernete, for the choreography of the container, is to manage the full life cycle of the application of the tool, it can be understood as docker housekeeper.

Study and practice of micro Services Architecture

Partners can see a small child here, can be said to languish, and so many frameworks / components / tools / methods, is not to make you terrified of. Indeed, it is the micro-enterprise services architecture to fall on the architect also put forward higher requirements and challenges (Who told you to take the most money). Here, let me share with you how to learn and practice micro service!

The first stage

Understanding monomer architecture, master OOP + programming of AOP design, analysis and design methods DDD familiar with the field-driven design, try to simply split system.

second stage

Micro service to the idea of ​​reconfigurable systems, high-frequency and independent service split, deploy a cluster, Consul service management, integration gateway, complete the basic micro-services architecture.

The third stage

Further improve the infrastructure, the reconstruction began authentication authorization, service tracking, distributed log analysis, distribution center and other components introduced to address the distributed lock and distributed transactions, so that function is available.

The fourth stage

The introduction of new tools to complete the project deployment operations management, Jenkins / Docker / K8S, step by step into use, the way most provincial thing here is the cloud, Ali cloud, Azure cloud are recommended.

The fifth stage

Full service of micro-projects, crossed the threshold of the front, the back will be more successful in landing the complete project to combat micro-service architecture, respond to the real situation.

Well, that is a gradual process of learning and practical, but also the whole process of learning inside micro-architecture class service infrastructure, need full three months, really difficult, but the harvest Leverage! Below is experiencing lesson for micro services a week to understand and practice the micro-services architecture components directly limit readers of this article to receive free, quickly scan code and share with everyone to learn it!

Guess you like

Origin www.cnblogs.com/IT-Evan/p/12666650.html