当前位置:网站首页>Nacos - service discovery

Nacos - service discovery

2022-07-01 08:40:00 SXHENIGA

Translation source of notes : Dark horse Nacos


One 、 Monomer architecture and microservices

1、 Monomer architecture

Use the same database for all functional modules , meanwhile , It also provides API perhaps UI Access to the Web Module etc. , Eventually, it will be packaged and deployed as a single application , This method deploys all functions in one Web The system running in the container is called monomer architecture

advantage
1 High development efficiency
2 Easy to test
3 Easy to deploy
shortcoming
1 The complexity is getting higher , The maintainability of the giant sword is getting worse
2 The falling speed of the version gradually slows down
3 Hinder technological innovation
4 Can't scale on demand

2、 Microservices

         Each business module uses independent services to complete , This microservice architecture pattern also affects the relationship between applications and databases , Unlike traditional methods, multiple business modules share a database , Microservice architecture each service has its own database .

benefits
1 Divide and rule , Single responsibility ; Easy to develop 、 Understanding and maintenance 、 Facilitate the splitting and management of the team ;
2 Telescopic ; It can scale the specified service separately ;
3 Local modification , Easy to replace , Easy to deploy , Conducive to continuous integration and rapid iteration
4 Not limited to any technology stack

Two 、 Service discovery

         In microservices , Services collaborate to achieve business goals . Remote calls between services are also required in microservices , Then you need to know the network location of the service 【IP And port number 】, Then you need to achieve the following .

        ①、 You need to report your network location to the service discovery center when each service is started .

        ②、 The service discovery client will periodically synchronize the service registry from the service discovery center , And cache on the client

        ③、 When a service needs to be requested , The service instance passes through the registry , Locate the target service network address . If the target service has multiple network addresses , Then the load balancing algorithm is used to select one from multiple service instances , Then make a request .

        summary : In microservice , Because the network address of the service running instance is constantly changing , Dynamic changes in the number of service instances , Therefore, a fixed configuration file cannot be used to record the provider's network address , Dynamic service discovery mechanism must be used to realize mutual perception between microservices . Each service instance will report its own network address , In this way, the service center forms a complete service registry , Each service instance will obtain the network address of the target service through the service discovery center , So as to realize the mechanism of service discovery . 

3、 ... and 、 Comparison between mainstream service discovery and configuration center

Comparison items NacosEurekaConsulZookeeper
Agreement of conformity Support AP and CP Model AP Model CP Model CP Model
health examination TCP/HTTP/MYSQL/Client BeatClient Beat

TCP/HTTP/gRPC/Cmd

Keep Alive
Load balancing strategy The weight /metadata/SelectorRibbonFabil-
Avalanche protection Yes Yes nothing nothing
Auto logout instance Support Support I won't support it Support
access protocol HTTP/DNSHTTPHTTP/DNSTCP
Monitor support Support Support Support Support
Multi-data center Support Support Support I won't support it
Sync across registries Support I won't support it Support I won't support it
SpringCloud Integrate Support Support Support I won't support it
Dubbo Integrate Support I won't support it I won't support it Support
k8s Integrate Support I won't support it Support I won't support it

Four 、Spring Cloud Service collaboration process

 

原网站

版权声明
本文为[SXHENIGA]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/182/202207010833327912.html