Abstract
What is? What is SpringCloud? What's it for? Why is that? Why SpringCloud? What are his strengths? How to do? How do I use SpringCloud? And the role of SpringCloud's various components?Copy the code
What is?
1. Brief introduction to Spring Cloud
2. Official introduction
Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service discovery, circuit breakers, intelligent routing, micro-proxy, control bus, one-time tokens, global locks, leadership election, distributed sessions, cluster state). Coordination of distributed systems leads to boiler plate patterns, and using Spring Cloud developers can quickly stand up services and applications that implement those patterns. They will work well in any distributed environment, including the developer’s own laptop, bare metal data centres, and managed platforms such as Cloud Foundry.
3. Overview of core members
Service Registry
|
Spring Cloud Netflix Eureka
|
Service invocation mode
|
REST API
|
Service monitoring
|
Spring Boot Admin
|
The circuit breaker
|
Spring Cloud Netflix Hystrix
|
The service gateway
|
Spring Cloud Netflix Zuul
|
Distributed configuration
|
Spring Cloud Config
|
Service tracking
|
Spring Cloud Sleuth
|
The message bus
|
Spring Cloud Bus
|
The data flow
|
Spring Cloud Stream
|
The batch task
|
Spring Cloud Task
|
4. What is the relationship with Spring Boot
Spring -> Spring Boot > Spring Cloud.Copy the code
Why is that?
1. Advantages of Spring Cloud?
2. Why SpringCloud?
- Produced by the Spring family, Spring is unrivaled in the enterprise development framework, with a big head, which can guarantee the subsequent update and improvement. Dubbo, for example, is almost dead right now
- Have Spring Boot this independent dry will be able to save a lot of things, large and small live Spring Boot are engaged in pretty good.
- As a big guy of micro service governance, consider very comprehensive, almost all aspects of service governance are considered, convenient development out of the box.
- Spring Cloud is highly active, tutorials are plentiful, and it’s easy to find solutions to problems
- In a few lines of code, the platform functions of fusing, load balancing and service center are accomplished
How does it work?
1. Introduction to core modules
- Define common abstractions for common modules. This is a perfect application of Spring’s decoupling philosophy. Each pattern is not tightly tied to implementation. The following uses server configuration as an example. You are free to change backend storage without affecting other services.
- Modular components. Spring Cloud is not an all-or-nothing solution; all modules are optional.
- Support for multiple environments, such as Dev, Test, and PROd. We can then build a package for all environments.
- Transparent configuration extraction. These centralized configurations should be captured automatically without any user encoding.
- Properties are automatically refreshed when they change. The service should be notified of such changes and the new properties reloaded.
- Maintain a change history and easily revert to older versions. This is a very useful feature to recover from bad changes in production.
- Service Registration – the process by which a service registers its location in a central registry. It typically registers its host and port, and sometimes authentication credentials, protocols, versions, and environment details.
- Service discovery – The process by which a client application queries the central registry to learn the location of a service.
- Fault tolerance – What happens when the registration service fails? Sometimes it will cancel registration immediately upon normal shutdown, but for the most part we need a timeout mechanism. The service sends a heartbeat constantly to ensure vitality. In addition, customers need to be able to handle failed services by automatically retrying another service.
- Load Balancing – If multiple hosts are registered under the service, how do we balance the load between hosts? Is load balancing performed on the registry side or client side? Can we provide custom load balancing policies?
- Integration work – How complex is the integration process? Does it just involve some new dependencies and/or configuration changes? Or is it intrusive discovery code? When your language is not supported, sometimes a separate Sidekick procedure is a good choice.
- Availability Issues – Is the registry itself highly available? Can I upgrade without downtime? The registry should not be a single point of failure.
- Provides a simple model for implementing complex enterprise integration solutions.
- Promotes asynchronous, message-driven behavior in Spring-based applications.
- Facilitate intuitive, incremental adoption by existing Spring users.
- Components should be loosely coupled for modularity and testability.
- The framework should enforce separation of concerns between business logic and integration logic.
- Extension points should be abstract in nature, but within well-defined boundaries to promote reuse and portability.
- Consumer Group. This was first introduced and popularized by Apache Kafka. It can support publish-subscribe and compete queues in a programming model.
- The partition. Messages with the same partitioning key are guaranteed to be generated in a physical segment based on the user-supplied partitioning key. This is critical in stateful processing, where related data needs to be processed together for performance or consistency reasons.
- Automatic content negotiation. Message type conversion is automatically performed based on the message type received by the user.
- We discussed requests for Spring Cloud Stream Binder earlier
- The HTTP header received by the Spring MVC controller
- Request RestTemplate
- . And most other types of requests and replies in Spring-Ecology
2. Netflix is introduced
Netflix is an OTT service that provides on-demand video in many countries [7] and operates a single-fee, mail-in DVD rental service in the United States. The service uses a return envelope to send DVDS and blu-Ray rental discs to the consumer’s designated pick-up address. Founded by Reed Hastings and Marc Randolph on August 29, 1997, the company is headquartered in Los Gatto, California and began offering subscription-based services in 1999. By 2009, Netflix was offering more than 100,000 movies on DVD, with more than 10 million subscribers [8]. On February 25, 2007, Netflix announced that it had shipped the 1 billionth DVD. [9] As of April 2011, Netflix had more than 23 million subscribers in the United States and more than 26 million in the rest of the world. [10] In 2011, Netflix’s total digital revenue exceeded $15 billion. [11] However, on October 23, 2012, Netflix announced that its revenue in the third quarter of the year decreased by 88%[12]. In January 2013, Netflix announced that it had added 2 million subscribers in the United States during the fourth quarter of 2012, bringing the total number of streaming subscribers to 27.1 million in the United States and 29.4 million celebrity subscribers in the rest of the world. In the same period, Netflix’s revenue rose 8 percent to $945 million. [13] In mid-March 2013, Netflix had 33 million subscribers [14]. The number of subscribers reached 36.3 million in April 2013 (29.2 million in the United States) [15]. Since then Netflix’s subscriber numbers and revenue have continued to grow. As of October 2015, Netflix had 69.17 million subscribers worldwide, including more than 43 million in the United States. [16]
Netflix is a DVD rental and video subscription service, with 60 million video subscribers in 13 years, which has contributed to its success in distributed applications.
3. Core components
- Spring Cloud Netflix Eureka
- Spring Cloud Netflix Hystrix
- Spring Cloud Netflix Zuul
- Spring Cloud Netflix Archaius
Configuration management API, a set of configuration management apis that provide dynamic typed properties, thread-safe configuration operations, polling framework, callback mechanism, and more.
- Spring Cloud Netflix Ribbon Load balancing.
- Spring Cloud Netflix Fegin REST client.
- Spring Cloud Bus
Message bus, which uses distributed messaging to connect services and service instances together and is used to propagate changes in state across a cluster.
- Spring Cloud Cluster
Cluster tool, based on Zookeeper, Redis, Hazelcast, Consul implementation of leadership election and civilian state pattern abstraction and implementation.
- Spring Cloud Consul
Service discovery and configuration management based on Hashicorp Consul implementation.
- Spring Cloud Cluster
Will replace Spring Integration. Provide basic support for clustering in distributed systems, such as: elections, cluster state consistency, global locking, tokens, and other common state patterns abstraction and implementation.
- Spring Cloud Consul
- Spring Cloud for Cloud Foundry
- Spring Cloud Security
Security controls that provide load balancing for OAuth2 REST clients and authentication header forwarding in Zuul proxy.
- Spring Cloud Sleuth
Distributed link monitoring, distributed tracking system for SpringCloud applications, compatible with Zipkin, HTrace, and ELK.
- Spring Cloud Task
Short life cycle microservices that add functional and non-functional features to Spring Booot application simple declarations.
- Spring Cloud Zookeeper
Service discovery and configuration management are based on Apache Zookeeper.
- Spring Cloud for Amazon Web Services
Fast and Amazon Web Services integration.
- Spring Cloud Starters
- Spring Cloud CLI
- Spring Cloud Connectors
Simplify the process of connecting to services and getting operations from the Cloud platform. It is highly scalable and can be used to build your own Cloud platform using Spring Cloud Connectors.
- Spring Cloud Stream
A framework for creating message-driven microservices applications, based on Spring Boot, to build individual/industrial Spring applications using Spring Integration to provide connectivity to message brokers. Data flow operation development kit, package with Redis,Rabbit, Kafka and more send and receive messages.
- Spring Cloud Data Flow
Used for big data processing
Data Flow is a unified programming model and managed service for developing and performing a wide range of Data processing patterns including ETL, batch and continuous operations.
Spring Cloud Data Flow is a native cloud-configurable service for composable microservices running in modern environments. Spring Cloud Data Flow enables developers to create and orchestrate data pipelines for common use cases like data extraction, real-time analytics, and data import/export.
Spring Cloud Data Flow is a redesign of Spring XD based on the native Cloud. The project aims to simplify the development of big data applications. Spring XD’s stream processing and batch module refactoring are Spring Boot-based stream and Task/Batch microservices, respectively. These applications are now automated deployment units and they have native support for modern operating environments like Cloud Foundry, Apache YARN, Apache Mesos, and Kubernetes.
Spring Cloud Data Flow provides a set of models and best practices for distributed streaming and batch data channels based on microservices.
conclusion
1. What is SpringCloud?
2. Why SpringCloud?
- Based on HTTP protocol, RESTful style, simple and convenient interface, efficient and transparent (Dubbo uses RPC protocol, performance is slightly better than HTTP protocol, but strong coupling degree is higher)
- Relying on the Spring platform, using Spring Boot to build services, comprehensive and out of the box
- Community active and well-documented
3. How to use SpringCloud?
- Requests are unified through the API Gateway (Zuul) to access internal services.
- Upon receiving the request, the gateway retrieves the available services from the registry center (Eureka).
- The Ribbon balances the load and distributes it to back-end instances.
- Microservices communicate with each other through Feign.
- Hystrix handles service time-out circuit breakers.
- Turbine monitors indicators related to calls and fuses between services.