当前位置:网站首页>Eureka usage record
Eureka usage record
2022-07-25 12:14:00 【dengjili】
Knowledge point 1, Self-protection model
Protection mode is mainly in a group of clients and Eureka Server Use when there are network partition scenarios between . Once in protected mode ,Eureka Server Will try to protect information in the registry of its services , Data in the service registry is no longer deleted . When the network is recovered , The Eureka Server The node automatically exits protected mode .
eureka.server.enableSelfPreservation=false
Knowledge point 2,Eureka Application example ID The name of the format
When the client registers , Service Instance ID The format of the default value for is as follows ( Host name : The service name : Service port ):
${
spring.cloud.client.hostname}:${
spring.application.name}:${
spring.application. instance_id:${
server.port}}
If you need to customize the format : The service name : Where the service is IP: Service port
eureka.instance.instance-id=${
spring.application.name}:${
spring.cloud.client.ip-address}:${
server.port}

At this time, the above link is still the hostname , Increase the configuration , Show as ip
eureka.instance.preferIpAddress=true

Custom jump link
eureka.instance.status-page-url-path=/hello

Knowledge point 3,Eureka Quickly remove failed services during development
In the actual development process , We might be able to restart the service all the time , because Eureka It has its own protection mechanism , Therefore, after the node is offline , Service information will always exist in Eureka in . We can make the removal faster by adding some configurations , Only in the development environment, of course , It is not recommended in production environment .
First of all in our eureka-server Two new configurations are added in , Turn off self-protection and clean-up interval :
eureka.server.enable-self-preservation=false
# Default 60000 millisecond
eureka.server.eviction-interval-timer-in-ms=5000
Then configure the following content in the specific client service :
eureka.client.healthcheck.enabled=true
# Default 30 second
eureka.instance.lease-renewal-interval-in-seconds=5
# Default 90 second
eureka.instance.lease-expiration-duration-in-seconds=5
eureka.client.healthcheck.enabled It's used to turn on the health check , Need to be in pom.xml Introduction in actuator Dependence , The code is as follows .
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
among :
- eureka.instance.lease-renewal-interval-in-seconds Express Eureka Client Send a heartbeat to server The frequency of the end .
- eureka.instance.lease-expiration-duration-in-seconds Express Eureka Server Last received client After my heart beat , Timeout waiting for next heartbeat , If you don't receive the next heartbeat in this time , Then remove the Instance.
added Instance For configuration information, please refer to the configuration class in the source code :org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean.
added Server For configuration information, please refer to the configuration class in the source code :org.springframework.cloud.netflix.eureka.server.EurekaServerConfigBean.
Knowledge point 4,EurekaClient Use
There are two ways
- com.netflix.discovery.EurekaClient
@GetMapping("/test")
public Object serviceUrl() {
return eurekaClient.getInstancesByVipAddress("eureka-provider-app", false);
}
- Spring Cloud Reseal ,org.springframework.cloud.client.discovery.DiscoveryClient
@GetMapping("/test2")
public Object serviceUrl2() {
return discoveryClient.getInstances("eureka-provider-app");
}
边栏推荐
- Client open download, welcome to try
- 微信公众号开发 入手
- 基于TCP/IP在同一局域网下的数据传输
- 小程序image 无法显示base64 图片 解决办法 有效
- monit安装和使用
- Atomic atomic class
- JS interview question: handwriting throttle function
- Ups and downs of Apple's supply chain in the past decade: foreign head teachers and their Chinese students
- 【GCN-RS】Learning Explicit User Interest Boundary for Recommendation (WWW‘22)
- 【GCN-RS】Region or Global? A Principle for Negative Sampling in Graph-based Recommendation (TKDE‘22)
猜你喜欢

【微服务~Sentinel】Sentinel降级、限流、熔断

【AI4Code】《InferCode: Self-Supervised Learning of Code Representations by Predicting Subtrees》ICSE‘21

【对比学习】Understanding the Behaviour of Contrastive Loss (CVPR‘21)

给生活加点惊喜,做创意生活的原型设计师丨编程挑战赛 x 选手分享

那些离开网易的年轻人

【多模态】《TransRec: Learning Transferable Recommendation from Mixture-of-Modality Feedback》 Arxiv‘22

【AI4Code】《CodeBERT: A Pre-Trained Model for Programming and Natural Languages》 EMNLP 2020

Video Caption(跨模态视频摘要/字幕生成)

Hystrix使用

【GCN-RS】Region or Global? A Principle for Negative Sampling in Graph-based Recommendation (TKDE‘22)
随机推荐
logstash
A beautiful gift for girls from programmers, H5 cube, beautiful, exquisite, HD
异构图神经网络用于推荐系统问题(ACKRec,HFGN)
PHP 上传ftp路径文件到外网服务器上 curl base64图片
【AI4Code】CodeX:《Evaluating Large Language Models Trained on Code》(OpenAI)
PHP curl post x-www-form-urlencoded
Mirror Grid
【GCN-RS】Region or Global? A Principle for Negative Sampling in Graph-based Recommendation (TKDE‘22)
R语言组间均值是否相同的成对比较:使用pairwise.t.test函数执行多个分组数据均值的两两成对假设检验
协程
嵌套事务 UnexpectedRollbackException 分析与事务传播策略
【图攻防】《Backdoor Attacks to Graph Neural Networks 》(SACMAT‘21)
NLP的基本概念1
Hydrogen entrepreneurship competition | Liu Yafang, deputy director of the science and Technology Department of the National Energy Administration: building a high-quality innovation system is the cor
30 sets of Chinese style ppt/ creative ppt templates
Musk's "eternal soul": half hype, half flicker
[high concurrency] a lock faster than read-write lock in high concurrency scenarios. I'm completely convinced after reading it!! (recommended Collection)
dirReader. Readentries compatibility issues. Exception error domexception
[high concurrency] I summarized the best learning route of concurrent programming with 10 diagrams!! (recommended Collection)
Hardware connection server TCP communication protocol gateway