In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to implement CAP in distributed architecture SpringCloud. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Research SpringCloud
SpringCloud is the most popular micro-service governance framework at this stage, so how does SpringCloud implement the CAP of service governance? here I just want to talk about my understanding of SpringCloud architecture.
Personal understanding of the nature of SpringCloud:
1) encapsulate the hottest basic components in the industry (also known as middleware), pea pod Netflix basket components, and injected SpringBoot features, seamless docking SpringBoot projects, business out of the box.
2) SpringCloud is essentially an advanced middleware, more advanced than both spring and springBoot, but simpler and more flexible than both of them.
So here comes the question: what problems can SpringCloud solve for us? what are the features, points and shortcomings? Baidu online, a lot of messy articles, are superficial, follow others, this may give many architects a lot of problems, why choose SpringCloud.
In fact, the technology for the architect is not difficult, the main difficulty is how to select and sort out the technology, SpringCloud official website http://projects.spring.io/spring-cloud/, SpringCloud Chinese translation site https://springcloud.cc/, in fact, make good use of these two sites, for you to better master this framework is very helpful.
SpringCloud overall function module
Distributed configuration module
SpringCloudConfig, distributed configuration, Ali also has its own self-developed config server, so what are the characteristics of SpringCloud's distributed configuration system, here is a simple summary. SpringCloudConfig is the solution of distributed configuration center provided by SpringCloud, relying on Netflix service governance module and Consul service governance module, decoupling server and client,server is the distributed configuration center, deploy independently, expose some restful interfaces, and obtain configuration information. The client integrates into the business system through starter and starts with the business system. By specifying the corresponding server configuration center, the client hot loads the configuration information related to the application and caches locally. SpringCloud supports distributed configuration centers in both git and file modes, so how to ensure CAP requires careful reading of the source code. Of course, you can access server directly through client to get configuration information, but there will be a single point of problem. Once server is dead, it will be very difficult to finish. In fact, the concept of SpringCloud framework design is service-oriented cluster management. How can there be a single point of failure? client and server can register with eureka or consul registry as a separate micro-service, thus realizing the service governance of client and server. You can make full use of the CP of consul and the AP feature of eureka to achieve the high availability of services.
Netflix Service Governance Module (Eureka)
SpringCloudNetflix, considering the situation of failure, the failure of the service registry will inevitably cause the paralysis of the whole system, so it is necessary to ensure the high availability of the service registry. Eureka Server is designed with high availability design in mind. In Eureka service governance design, all nodes are both providers and consumers of services, and service registries are no exception.
The high availability of Eureka Server actually registers itself as a service with other service registries, so that a group of service registries can be formed to synchronize the service list with each other and achieve the effect of high availability.
The synchronization of Eureka Server follows a very simple principle: as long as there is an edge to connect the nodes, the information can be spread and synchronized. Pairwise registration can be used to achieve the effect of complete peer-to-peer nodes in the cluster and achieve the highest availability cluster. Any registry failure will not affect the registration and discovery of services. Eureka emphasizes high availability, that is, ensuring AP at the expense of strong consistency.
Eureka is a Servlet program, which needs to be embedded in the Servlet container, which will affect the performance of service governance. That is, when choosing gateway technology, many people abandon eureka-zuul and choose more aggressive Nginx and lua as basic gateways. As long as the service is embedded in the servlet container, the performance will be limited by the setvlet container.
Eureka1.0 High availability Architecture defects:
Eureka does not use strong consistency election protocols, such as ZAB protocol as a data consistency algorithm (zookeeper election algorithm). For example, Consul's data consistency algorithm Raft,Eureka cluster multi-copy consistency protocol uses the AP protocol similar to "asynchronous overwriting". Each server sends locally received write requests (register/heartbeat/unregister/update) to all other machines that make up the cluster (Eureka calls it peer, peer service). In particular, hearbeat messages are transmitted periodically between client- > server- > all peers.
Disadvantages of eureka data consistency protocol:
Every Server needs to store a full amount of service data, and the memory of Server will obviously become a bottleneck. When more and more subscribers come, you need to expand the Eureka cluster to improve the read capacity, but the expansion will result in more write requests for each server, and the effect of capacity expansion is not obvious. All server that make up the Eureka cluster need to have the same physical configuration and can only accommodate more service data by constantly improving the configuration.
Eureka2.0 architecture upgrade:
Data push moves from pull to push mode, and realizes the function of service address on-demand subscription with smaller granularity.
With the separation of read and write, the write cluster is relatively stable, and there is no need to expand the capacity frequently; the read cluster can be expanded as needed to improve the data push capability.
Added audit log features and richer Dashboard.
The overall upgrade of eureka2.0 architecture is similar to the architecture evolution of ConfigServer, a distributed registry developed by Alibaba.
Distributed message bus module (Bus)
What kind of functional component is SpringCloudBus? as the name implies, it must be message bus. If you are not familiar with the concept of message bus, you can own Baidu. Here is a brief description of the SpringCloudbus micro-service framework, which mainly solves the problems.
SpringCloudBus message bus supports Rabbitmq and Kafka, and the project directory structure: Spring-cloud-bus, Spring-cloud-bus-dependencies, Spring-cloud-starter-bus-amqp, Spring-cloud-starter-bus-kafka. In fact, all the project directory structures of Springcloud are sorted out according to the springboot format. At the bottom of the message bus, SpringCloudStream is used to complete the communication between services.
Single sign-on web module: SpringCloudForCloudFoundry
Cluster management module: SpringCloudCluster
Consul service governance module: SpringCloudConsul
Security authentication module: SpringCloudSecurity
Full link tracking system: SpringCloudSleuth
Data flow service module: SpringCloudDataFlow
Message queuing module
SpringCloudStream is a framework used to build message-driven capabilities for micro-service applications, isolating business and message middleware, shielding the differences of message middleware, such as Rabbitmq, Kafka, etc., of course, SpringCloud currently only supports Rabbitmq and Kafka. Middleware teams can encapsulate Rocketmq binders and invade the business in the form of plug-ins, so that the business can seamlessly cut to Rocketmq without changing the upper business code. Complete the upgrade of message middleware.
Gateway module
SpringCloudGateway is another distributed micro-service architecture gateway encapsulated by SpringCloud.
The latest gateway features are as follows: based on Spring Framework 5PowerProject Reactor and Spring Boot 2.0; ability to match routes on any request attribute; Hystrix circuit breaker integration; Spring Cloud DiscoveryClient integration; request rate limit; path rewriting; easy to write assertions and filters; support for assertions and filters to the routing side.
Spring Cloud Gateway is the gateway officially developed by Spring based on Spring 5.0 Spring Boot 2.0 and Project Reactor technologies. Spring Cloud Gateway aims to provide a simple and effective unified API route management method for micro-service architecture. As a gateway in Spring Cloud ecosystem, Spring Cloud Gateway aims to replace Netflix ZUUL. It not only provides unified routing, but also provides basic functions of gateway based on Filter chain, such as security, monitoring / burying point, and current restriction.
The core concept of the gateway module: routing, assertion and filter. Routing function is the basic module of the gateway, which consists of a series of ID,URI, as well as assertions and filters. Assertions are functional assertions of java8, and the input type is ServerWebExchange of SpringFramework, allowing developers to match all HTTP requests, including HTTP headers and parameters. The filter is an instantiation of SpringFramework GatewayFilter, and the request and response change before or after the HTTP downlink request.
On the distributed architecture SpringCloud how to achieve CAP to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.