Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to safely deactivate the micro-service node of sprng cloud

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to safely offline micro-service nodes in sprng cloud". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to safely offline micro-service nodes in sprng cloud".

Spring cloud should have sprung up in China in 2015, when the industry was still facing a debate about whether it was doubbo or spring cloud. Practice is the only criterion for testing truth, and at present doubbo should only be living in legacy projects.

Spring cloud is what has been frequently interviewed. This article is not going to answer such a high-end question, but only briefly discusses the offline problem of spring cloud business node.

Problems that may be caused by unsafe downline of nodes

Generally speaking, it is not unreasonable to offline a node in a production environment, and its scenario usually causes abnormal downtime and deployment and release. This time, we mainly understand the hidden dangers of non-secure downlines from the grayscale release scenario. Its main features are data inconsistency and business interruption.

Means of offline service and its advantages and disadvantages

Available means

Advantages and disadvantages

Kill is fast, Shutdown hook is a disadvantage except fast.

/ shutdown is similar to mode one and similar to mode one.

/ service-registry/down (recommended) Mark eureka status down can only control service discovery traffic

/ pause Mark eureka status down

Conflict after helthcheck is enabled

Only eureka traffic can be controlled

Delete

/ eureka/apps/ {application.name} /

Comfort Eureka customers to change their status to up after contract renewal.

DiscoveryManager.getInstance ().

ShutdownComponent ()

Handwritten offline interface is supported

It is more difficult to think of start after shutdown.

Can only control service discovery traffic

PUT / eureka/v2/apps/appID/instanceID/status?value=OUT_OF_SERVICE (recommended) forced offline

Can be modified to up recovery state

Can only control service discovery traffic

A normal offline process is recommended as 1. Modify the eureka status, but the service is still running. two。 Monitor node traffic. 3. Physical offline. This is done by writing an automated tool or manually confirming it.

Traffic entry diversification Challen

Take user-serivce as an example. The traffic entrances of general services are external traffic load balancer nginx, internal traffic eureka and message-driven kafka/rabbit.

The above methods of controlling eureka can only solve the problem of internal traffic such as loan-service. If the eureka status is changed to out_of_service, the message queue will still be consumed, and the monitoring traffic may miss the monitoring of the message queue, resulting in the consumption message thread being kill during physical offline. If the message consumption confirmation mechanism is not appropriate, the message will be lost.

Message queuing pause

Take kafka as an example to conduct message pause

@ Autowired

Private KafkaListenerEndpointRegistry kafkaListenerEndpointRegistry

Public void pause () {

KafkaListenerEndpointRegistry.getListenerContainers () .forEach (c-> c.pause ()

}

Public void start () {

KafkaListenerEndpointRegistry.getListenerContainers () .forEach (c-> {

If (c.isRunning ()) {

C.start ()

} else {

C.resume ()

}

});

}

At this point, I believe you have a deeper understanding of "how to safely offline micro-service nodes in sprng cloud". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report