Introduction to MicroServices Framework-springcloud

Source: Internet
Author: User

The previous article talked about the microservices infrastructure, and Netflix's many open source components together provide the complete distributed microservices infrastructure environment, while Spring Cloud is a further encapsulation of Netflix's many open source components, and it also achieves a good integration with the cloud platform and the spring Boot development framework.

Spring Cloud is a relatively new micro-service framework, and this year (2016) released the release version of 1.0. Although Spring cloud is the shortest time, Spring Cloud offers a full range of distributed system solutions compared to RPC frameworks such as Dubbo.

Spring Cloud provides developers with a quickly build tools in distributed systems (configuration management, service discovery, fuse, routing, Micro Agent, Control bus, one-time token, all-in-one, leader election, distributed session, cluster status), developers using spring Cloud can quickly start a service or build an application, while being able to connect quickly and with cloud platform resources.

Let's start with a brief description of the four basic key components of the spring Cloud Chinese community:

Community Address: http://springcloud.cn/

Spring Cloud Config configuration center



Spring Cloud config is the configuration center in our usual sense. Spring Cloud config-The configuration of the application that was originally placed on the local file to be placed on the central server, The essence is that the configuration information is migrated from the local to the cloud。 To provide better management and release capabilities.

Spring Cloud Config sub-server and client, The server is responsible for publishing the configuration files stored in git (SVN) as a rest interface, the client can obtain the configuration from the server-side rest interface. However, the client is not actively aware of the changes to the configuration, thereby proactively acquiring a new configuration, which requires each client to trigger its own/refresh through the Post method.

Spring Cloud Netflix Service discovery


Spring Cloud Eureka provides service discovery, service registration capabilities in a distributed environment.

Spring Cloud Netflix, one of Spring Cloud's sub-projects, focuses on the packaging of Netflix's range of open source products, which provides a self-configuring Netflix OSS integration for spring boot applications.

With some simple annotations, developers can quickly configure common modules in the application and build large, distributed systems. The main modules it provides include: Service Discovery (Eureka), Circuit breakers (Hystrix), intelligent routing (Zuul), Client load Balancing (Ribbon), etc.

Spring Cloud Hystrix fuses



A circuit breaker (Cricuit breaker) is a facility that automatically fuses (turns on the switch) when the remote service is unavailable, and automatically recovers (closes the switch) when the remote service resumes.

A circuit breaker (Cricuit breaker) is a facility that automatically fuses (turns on the switch) when the remote service is not available and automatically recovers (closes the switch) when the remote service resumes, and Spring Cloud provides a circuit breaker via Netflix's hystrix components, Resource isolation and self-healing capabilities.

Spring Cloud Zuul Service Gateway



Spring Cloud Eureka provides service discovery, service registration capabilities in a distributed environment.

Spring Cloud Netflix, one of Spring Cloud's sub-projects, focuses on the packaging of Netflix's range of open source products, which provides a self-configuring Netflix OSS integration for spring boot applications. with some simple annotations, developers can quickly configure common modules in the application and build large, distributed systems. It mainly provides modules including: Service Discovery (Eureka), Circuit breaker (hystrix), intelligent Path (Zuul), Client load Balancing (Ribbon), etc.

Of course Spring Cloud also has many additional components to extend, including service link monitoring and tracking (a key feature), message bus, Data flow processing, batch task processing, and more. For the whole spring cloud microservices framework simply, that is:

as long as you divide your microservices components and modules and define the API interfaces that need to be exposed, the rest of the development is not much different from the traditional approach, and the components you develop are integrated into a distributed, extensible microservices environment. The interface is designed to publish, service registration, service invocation and routing, service monitoring, health detection and flow control will be done by the micro-service framework to help you.

It is with the mature micro-service framework that we should shift the focus of the microservices architecture design from the technical bottom to the component partition and interface design.


the difference between Springcloud and Dubbo

The differences between the two are described in the following articles, which can be consulted in detail:

http://blog.didispace.com/microservice-framework/

You can see that Springcloud can provide more basic capabilities than Dubbo,dubbo can be seen as a simple implementation of Springcloud.

Dubbo is the RPC service governance framework, with the capabilities of service registration, discovery, routing, load balancing, and so on with spring cloud. But there is no configuration center, complete and easy to use full-link monitoring, need to adopt open source solutions customized or self-research. Spring Cloud's configuration center, full-link monitoring and other components. For now, Spring cloud domestic small and medium-sized enterprises use more, large enterprises may need to customize the components they need to handle.

But also need to see Spring cloud Annotation-based service discovery, service governance and other features have code intrusion, Dubbo No code intrusion, business developers do not need to use annotations to focus on the framework level of processing. From the perspective of middleware or infrastructure, service governance and other functions are transparent to ordinary business programmers, and business programmers do not need to focus on the use of service governance frameworks, but focus on the business code.

practice of Springcloud based on micro-service framework

For specific practices based on the Springcloud framework, it is recommended to refer to the Suphing Blog's series of articles, as follows:

    • Service Registration and Discovery: http://blog.didispace.com/springcloud1/
    • Service consumption: http://blog.didispace.com/springcloud2/
    • Service Fusing mechanism: http://blog.didispace.com/springcloud3/
    • Service Configuration Center: http://blog.didispace.com/springcloud4/
    • Service Gateway: http://blog.didispace.com/springcloud5/
    • High-Availability Service registry: http://blog.didispace.com/springcloud6/
    • Message bus: http://blog.didispace.com/springcloud7/

Service registration and Discovery

Note that the Springboot framework is still in use and is integrated with the Springboot framework, adding a dependency on Springcloud related packages and components in the Pom.xml configuration file. On the basis of the original interface API definition, we add @enablediscoveryclient annotations, which makes it easy for the service registry to discover the service provider and the services it provides.

Service consumption


Mode 1-ribbon is a load balancer based on HTTP and TCP clients. The ribbon can poll for access in a ribbonserverlist server-side list configured through the client to achieve a balanced load. When the ribbon is used in conjunction with Eureka, Ribbonserverlist is discoveryenabledniwsserverlist rewritten to get a list of the server from the Eureka Registry.

Mode 2-feign is a declarative Web service client that makes it easier to write Web Serivce clients. We only need to use feign to create an interface and configure it with annotations to be done. It features pluggable annotation support, including feign annotations and jax-rs annotations. The feign also supports pluggable encoders and decoders. Spring Cloud adds support for feign to spring MVC annotations, and integrates the Ribbon and Eureka to provide an HTTP client implementation that provides a balanced load.

Circuit Breaker

First, add the Hystrix dependency to the Pom.xml file, and add @enablecircuitbreaker annotations on the consumer application main class to turn on the circuit breaker function. Note that the original service consumption mode also involves the modification, adding the service callback callback function.

Service Gateway

A service gateway is an integral part of the microservices architecture. In addition to the service Routing and load balancing function, the service gateway provides the rest API to the external system, and it also has the functions of privilege control. The Zuul in Spring Cloud Netflix is a role that provides front-door protection for microservices architectures, while migrating permissions control of these heavier non-business logic content to the service routing plane, enabling service cluster principals to be more reusable and testability-oriented.

Introduction to MicroServices Framework-springcloud

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.