The source code of this article: GitHub·click here|| GitEE·click here
1. Summary of basic components
1. Article reading list
1) Basic components
Eureka components, service registration and discovery
Ribbon and Feign components to achieve load balancing
Hystrix components to achieve service fusing
Turbine component, realize microservice cluster monitoring
Zuul component, realize routing gateway control
Config component, realize unified configuration management
Zipkin component, Realize request link tracking
2), application cases
Based on Shard-Jdbc sub-database and table, database expansion plan
Shard-Jdbc based on SpringCloud Sub-database and sub-table expansion
3), subsequent updates
This case is mainly based on the SpringCloud2 version to demonstrate the application of microservices in actual development.
storey-client-web
storey-middle-soft < br />
storey-data-center
storey-cloud-ware
Use version
- Spring5+
- SpringBoot2+
- SpringCloud2+
2, the concept of common components
- Eureka components
Eureka is a kind of REST-based services are mainly used in the AWS cloud to locate services to achieve load balancing and failover of middle-tier servers. This service is called EurekaServer. The client component EurekaClient, which makes the interaction with the service easier.
- Ribbon and Feign components
Ribbon is a client-side Load Balancer (LB) device, which provides Access control to a large number of HTTP and TCP clients.
Feign is a declarative Web Service client. Its appearance makes it very simple to develop Web Service clients. To use Feign, you only need to create an interface and add corresponding annotations, for example: @FeignClient interface class annotations.
- Hystrix component
When a microservice in the microservice architecture fails, it is necessary to quickly cut off the service and prompt the user, Subsequent requests do not call the service, return directly, and release the resources, which is the service fuse.
- Turbine component
In the microservice architecture, in order to ensure the availability of the program and prevent program errors from causing network congestion, there is a circuit break器model. The condition of the circuit breaker reflects the availability and robustness of the program, which is an important indicator. HystrixDashboard is a component of the circuit breaker status, providing data monitoring and intuitive graphical interface.
- Zuul component
Zuul gateway mainly provides dynamic routing, monitoring, flexibility, security control and other functions. In a distributed microservice system, the system is disassembled into multiple microservice modules, and the user’s request is routed through the zuul gateway and forwarded to the specific post microservice module.
- Config component
In a microservice system, there are many services and the same configuration: such as database information, cache, Parameters, etc., will appear on different services. If a configuration changes, many service configurations need to be modified. Spring cloud provides a configuration center to solve this scenario problem.
- Zipkin component
Zipkin is a component in the SpringCloud microservice system, which implements a link tracking solution. You can locate which specific services are requested by a request. In a complex microservice system, if an exception occurs in the request, the service where the problem lies can be quickly captured.
Second, Boot vs. Cloud
SpringBoot focuses on the rapid development of a single microservice. SpringCloud is a global microservice coordination framework. It integrates and manages individual microservices developed by SpringBoot, and provides integrated services between microservices, such as configuration management, service discovery, circuit breakers, and routing gateways. SpringCloud relies on SpringBoot.
3. Dubbo vs. Cloud
1. Invocation method comparison
The service invocation method is an important difference between Dubbo and Spring Cloud. Familiar with the concepts of RPC/HTTP/REST will help to compare Dubbo and SpringCloud. RPC is a remote procedure call, and its calling protocol usually includes a transmission protocol and an encoding protocol. RPC call is a service-oriented package, optimized for service availability and efficiency. http is a hypertext transfer protocol, RPC can also use http as a transfer protocol, but generally tcp is used as a transfer protocol.
2. Execution performance comparison
Dubbo uses a single long connection and NIO asynchronous communication (keep connection/polling processing), uses the TCP protocol of a custom message, and Serialization uses the customized Hessian2 framework, which is suitable for small data volume and large concurrent service calls, and the number of service consumer machines is much greater than the number of service provider machines, but it is not suitable for service calls that transmit big data. Spring Cloud directly uses the HTTP protocol, which is weaker than Dubbo in performance.
3. Registry comparison
This usually refers to the comparison between ZooKeeper (Dubbo registry) and Eureka (Cloud registry). The well-known CAP theory in the distributed field (C: data consistency, A: service availability, P: fault tolerance of partition failure), Zookeeper guarantees CP, but for service discovery, availability is more important than data consistency. AP Better than CP, and the Eureka design follows the AP principle.
4. Framework ecological comparison
Dubbo focuses on RPC and service governance, while Spring Cloud is a microservice architecture ecosystem.
Four. Source code address
GitHub·Address
https://github.com/cicadasmile/spring-cloud-base
GitEE ·Address
https://gitee.com/cicadasmile/spring-cloud-base