当前位置:网站首页>Eureka使用记录
Eureka使用记录
2022-07-25 11:21:00 【dengjili】
知识点1,自我保护模式
保护模式主要在一组客户端和 Eureka Server 之间存在网络分区场景时使用。一旦进入保护模式,Eureka Server 将会尝试保护其服务的注册表中的信息,不再删除服务注册表中的数据。当网络故障恢复后,该 Eureka Server 节点会自动退出保护模式。
eureka.server.enableSelfPreservation=false
知识点2,Eureka应用实例ID名称格式
客户端在注册时,服务的 Instance ID 的默认值的格式如下(主机名:服务名称:服务端口):
${
spring.cloud.client.hostname}:${
spring.application.name}:${
spring.application. instance_id:${
server.port}}
若需要自定义格式:服务名称:服务所在 IP:服务端口
eureka.instance.instance-id=${
spring.application.name}:${
spring.cloud.client.ip-address}:${
server.port}

此时上述链接却还是主机名,增加配置,展示为ip
eureka.instance.preferIpAddress=true

自定义跳转链接
eureka.instance.status-page-url-path=/hello

知识点3,Eureka开发时快速移除失效服务
在实际开发过程中,我们可能会不停地重启服务,由于 Eureka 有自己的保护机制,故节点下线后,服务信息还会一直存在于 Eureka 中。我们可以通过增加一些配置让移除的速度更快一点,当然只在开发环境下使用,生产环境下不推荐使用。
首先在我们的 eureka-server 中增加两个配置,分别是关闭自我保护和清理间隔:
eureka.server.enable-self-preservation=false
# 默认 60000 毫秒
eureka.server.eviction-interval-timer-in-ms=5000
然后在具体的客户端服务中配置下面的内容:
eureka.client.healthcheck.enabled=true
# 默认 30 秒
eureka.instance.lease-renewal-interval-in-seconds=5
# 默认 90 秒
eureka.instance.lease-expiration-duration-in-seconds=5
eureka.client.healthcheck.enabled 用于开启健康检查,需要在 pom.xml 中引入 actuator 的依赖,代码如下所示。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
其中:
- eureka.instance.lease-renewal-interval-in-seconds 表示 Eureka Client 发送心跳给 server 端的频率。
- eureka.instance.lease-expiration-duration-in-seconds 表示 Eureka Server 至上一次收到 client 的心跳之后,等待下一次心跳的超时时间,在这个时间内若没收到下一次心跳,则移除该 Instance。
更多的 Instance 配置信息可参考源码中的配置类:org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean。
更多的 Server 配置信息可参考源码中的配置类:org.springframework.cloud.netflix.eureka.server.EurekaServerConfigBean。
知识点4,EurekaClient 使用
以下两种方式
- com.netflix.discovery.EurekaClient
@GetMapping("/test")
public Object serviceUrl() {
return eurekaClient.getInstancesByVipAddress("eureka-provider-app", false);
}
- Spring Cloud 重新封,org.springframework.cloud.client.discovery.DiscoveryClient
@GetMapping("/test2")
public Object serviceUrl2() {
return discoveryClient.getInstances("eureka-provider-app");
}
边栏推荐
- 【GCN-RS】Learning Explicit User Interest Boundary for Recommendation (WWW‘22)
- [MySQL 17] installation exception: could not open file '/var/log/mysql/mysqld log‘ for error logging: Permission denied
- Introduction to pl/sql, very detailed notes
- aaaaaaaaaaA heH heH nuN
- brpc源码解析(六)—— 基础类socket详解
- Brpc source code analysis (VI) -- detailed explanation of basic socket
- Functions in JS
- flink sql client 连接mysql报错异常,如何解决?
- PHP curl post x-www-form-urlencoded
- JS interview question: handwriting throttle function
猜你喜欢

GPT plus money (OpenAI CLIP,DALL-E)

Power BI----这几个技能让报表更具“逼格“
![[imx6ull notes] - a preliminary exploration of the underlying driver of the kernel](/img/0f/a0139be99c61fde08e73a5be6d6b4c.png)
[imx6ull notes] - a preliminary exploration of the underlying driver of the kernel

【AI4Code】《CoSQA: 20,000+ Web Queries for Code Search and Question Answering》 ACL 2021

JS operator

【GCN-RS】Towards Representation Alignment and Uniformity in Collaborative Filtering (KDD‘22)

Brpc source code analysis (V) -- detailed explanation of basic resource pool

【GCN多模态RS】《Pre-training Representations of Multi-modal Multi-query E-commerce Search》 KDD 2022

selenium使用———安装、测试

Javescript loop
随机推荐
Brpc source code analysis (VI) -- detailed explanation of basic socket
R语言组间均值是否相同的成对比较:使用pairwise.t.test函数执行多个分组数据均值的两两成对假设检验
brpc源码解析(六)—— 基础类socket详解
PHP curl post length required error setting header header
dirReader.readEntries 兼容性问题 。异常错误DOMException
奉劝那些刚参加工作的学弟学妹们:要想进大厂,这些并发编程知识是你必须要掌握的!完整学习路线!!(建议收藏)
【6篇文章串讲ScalableGNN】围绕WWW 2022 best paper《PaSca》
'C:\xampp\php\ext\php_zip.dll' - %1 不是有效的 Win32 应用程序 解决
Zero shot image retrieval (zero sample cross modal retrieval)
Video Caption(跨模态视频摘要/字幕生成)
【GCN-RS】Towards Representation Alignment and Uniformity in Collaborative Filtering (KDD‘22)
图神经网络用于推荐系统问题(IMP-GCN,LR-GCN)
Go 垃圾回收器指南
R语言可视化散点图、使用ggrepel包的geom_text_repel函数避免数据点之间的标签互相重叠(设置min.segment.length参数为Inf不添加标签线段)
那些离开网易的年轻人
Transformer变体(Routing Transformer,Linformer,Big Bird)
Application of comparative learning (lcgnn, videomoco, graphcl, XMC GaN)
R语言ggpubr包ggarrange函数将多幅图像组合起来、annotate_figure函数为组合图像添加注释、注解、标注信息、fig.lab参数添加图像标签、fig.lab.face参数指定样式
Hardware connection server TCP communication protocol gateway
Management of software defects