Micro Services Why must choose spring cloud?

Now very popular micro-service architecture, building services and micro-systems will lead to more clear business division and scalability. At the same time, support for micro-services technology stack is varied, this series of articles describes these techniques leader --Spring Cloud. This is a series of posts, mainly about why we chose Spring Cloud and its technical summary.

1 Why micro-services architecture requires Spring Cloud

Briefly, the service of the core is applied according to the traditional stop a service split into a service, and on this basis of micro service to more fully decoupled (not share DB, KV, remove heavyweight ESB), and stressed the DevOps and fast evolution. This requires us to adopt and stop times, different technology stack pan-SOA era, and Spring Cloud is one of the best.

English Development and Operations DevOps is fit, he asked the development, testing, operation and maintenance of integrated cooperation, to make smaller, more frequent, more automated application release, application architecture and surrounding infrastructure to build infrastructure. This requires the full application of cohesion, but also facilitate operation and maintenance and management. This idea coincides with the micro-service concept.

Next we service architecture evolution from the perspective of Spring Cloud and see why more responsive to micro-services architecture.

1.1 Speaking from using nginx

The initial service solutions is to provide the same services to provide a unified domain name and service the caller sends an HTTP request, the request Nginx responsible for the distribution and jump to the domain name.

file

There are many problems with this architecture:

Nginx as an intermediate layer, is coupled in the configuration file of the service invocation logic, which impairs the integrity of the micro and services, but also makes Nginx into a heavyweight ESB some extent.

Information services scattered in various systems, can not be unified management and maintenance. Every service call is the first attempt, consumers do not know which service instances to provide them with services. This is not in line with the concept of DevOps.

We can not visually see the service providers and service consumers current health and communication frequencies. This is not in line with the concept of DevOps.

Consumers retransmission failure, load balancing and so there is no uniform policy, which increased the difficulty of development of each service, is not conducive to rapid evolution.

In order to solve the above problems, we need a central component ready for service integration, the summary information for each service, including the service component name, address and quantity. The caller services to provide this service to obtain information first instance (IP, port, etc.) when requested by a service center component, and then select a provider for the service via policy default or custom direct access. So, we introduced Dubbo.

1.2 Based on Dubbo achieve microService

Ali Dubbo is a open source SOA service management solutions, rich document, use of the country is very high.

Dubbo built using micro-services, it may have been a better solution to the problem mentioned above:

file

Call the middle layer becomes optional components, consumers can directly access the service provider.

Service information is concentrated in the Registry, formed a central component of service governance.

By Monitor monitoring system, you can visually display statistical information service call.

Consumer can perform load balancing, service degradation choice.

But for the micro-architecture in terms of service, Dubbo also not perfect:

Registry relies heavily on third-party components (zookeeper or redis), when these components there is a problem, a service call will soon be interrupted.

DUBBO main use RPC calls. Enables service providers and the caller had a strong reliance on the code, service providers need to continue to contain the common code out of the jar package packaged for consumer use. Once the packaging problem, it will result in a service call error.

1.3 the best choice --Spring Cloud

As a new generation of service framework, Spring Cloud slogan put forward is to develop "cloud-oriented applications environment", which provides a more comprehensive technical support service for the micro-architecture. Combined with the demands of micro services we mentioned at the beginning, we have Spring Cloud and DUBBO be some comparison:

file

Spring Cloud abandoned Dubbo RPC communication, using the REST HTTP-based manner. Strictly speaking, these two methods have advantages and disadvantages. Although to some extent, the performance of the latter at the expense of service calls, but also to avoid the problems mentioned above native RPC brings. RPC and REST compared to more flexible, service providers and rely solely dependent on the caller a paper contract, code-level strong dependence does not exist in this case emphasize the rapid evolution of micro-services environment, appear to be more appropriate.

Eureka compared to the zookeeper, more suited to the scene found the service, and this will be the next one will be out in detail.

Clearly, Spring Cloud is more powerful than DUBBO, wider coverage, but also as Spring fist project, it is also possible, Spring Boot, Spring Data, Spring Batch Spring and other items perfect integration with the Spring Framework, these services for micro It is crucial.

As mentioned earlier, an important micro-services behind the concept is continuous integration, fast delivery, and the use of a unified internal services in the technical framework, with clearly more efficient than the technology portfolio to disperse. More importantly, compared to Dubbo, it is an ongoing maintenance, more fiery community open source project, which uses the system to ensure that it is built, can continue to be supported by the power of open source.

2 Spring Cloud Technology Overview

The following figure shows the complete Spring Cloud technology consists of:

file

Service Governance: This is the core of Spring Cloud. Currently Spring Cloud mainly realized through the integration of Netflix related products function in this regard (Spring Cloud Netflix), including Eureka for service registration and discovery, calling breaker Hystrix, call end load balancing Ribbon, Rest client Feign, intelligence service Spectator routing Zuul, for monitoring and display of the data collection, Servo, Atlas, and for providing configuration read Archaius RxJava Controller Reactive encapsulation layer. In addition, for

Feign and RxJava not Netiflix products, but are integrated into the Spring Cloud Netflix in.

For registration and discovery services, in addition to Eureka, Spring Cloud also integrates Consul and Zookeeper as an alternative, but because these two programs in the CAP rather than theoretically follow CP AP (one will be detailed at this point), so The official was not recommended.

Distributed Link Monitoring: Spring Cloud Sleuth provides a fully automated, configurable embedded data points to collect performance data on the micro-service call link, and sent Zipkin storage, and display statistics.

Message component: Spring Cloud Stream demand for a variety of distributed messaging abstracts, including publication subscriptions, consumer groups, message fragmentation functions, to achieve asynchronous communication between the micro-services. Spring Cloud Stream also integrates third-party Apache Kafka as RabbitMQ and implement a message queue. The Spring Cloud Bus-based Spring Cloud Stream, the main provider of event communication between services (such as refresh configuration).

Configuration Center: Based on Spring Cloud Netflix and Spring Cloud Bus, Spring also provides a Spring Cloud Config, to achieve a centralized configuration management, dynamic refresh the concept of distribution center. Configured to store or simply by Git file, supports encryption and decryption.

Safety Control: Spring Cloud Security based on safety standards OAUTH2 this open network, providing a single sign-on service in the micro-environment, resource authorization, token management.

Command-line tool: Spring Cloud Cli provides a way to command line and scripting way to manage micro services and Spring Cloud components.

Cluster tools: Spring Cloud Cluster provides cluster selected from primary, distributed lock (not yet implemented), time token (Write implemented), etc. Distributed clustering technology required components.

This article from the blog article multiple platforms OpenWrite release!

Guess you like

Origin juejin.im/post/5de0de2c5188252edd0e27e2