Through the previous chapter, "Springcloud Development Learning Summary (iii)--service governance Eureka", we have built the core components of the MicroServices architecture-service registries (including single-point mode and high-availability mode). A service is also registered, named Hello-service. Now that we have a service registry and a service provider, here's an attempt to build a service consumer that is focused on two goals, Discovery services, and consumer services. Where the service discovery task is done by the Eureka client, and the service consumption task is done by the Ribbon . The Ribbon is a client-side load balancer based on HTTP and TCP that can poll access to achieve a balanced load by ribbonserverlist the list of server configurations configured in the client. When the ribbon and Eureja are used together, the Ribbon's service instance manifest ribbonserverlist is discoveryenableniwsserverlist rewritten to get a list of services from the Eureka Registry. It also replaces iping with niwsdiscoveryping, which delegates responsibilities to Eureka to determine whether the server has been started. In this chapter, we do not make a detailed introduction to the ribbon, readers only need to understand it in the Eureka Service discovery based on the implementation of a set of service instance selection strategy, so as to achieve the consumption of services. A detailed introduction and analysis of the Ribbon will follow.
Let's build a simple example to see how service discovery and consumption can be realized under Eureka's service governance system.
- First, we started the service registry Eureka-server and Hello-service services that were implemented before, in order to experiment with the Ribbon's client load balancing function, we java-jar the command line ①
Springcloud Development Learning Summary (iv)--Client load Balancing Ribbon