当前位置:网站首页>解决Eureka默认缓存配置导致时效性问题
解决Eureka默认缓存配置导致时效性问题
2022-07-24 16:19:00 【code-x】
技术架构是Eureka+OpenFeign+Ribbon
开发环境下, 比如A服务调用B服务, B服务更改代码重启后, A服务足足要等上一两分钟才能正常调用到B服务
无疑是浪费生命
在此更改下相关配置解决此问题
Ribbon配置
Ribbon调用这个方法启动了一个定时器, 该定时器定期刷新ribbon内缓存的服务列表
com.netflix.loadbalancer.PollingServerListUpdater#start# ribbon缓存刷新间隔 改为1s
ribbon.ServerListRefreshInterval=1000Eureka Client配置
Client会定时向Server获取服务注册信息
同样是定时调用
com.netflix.discovery.DiscoveryClient#initScheduledTasks通过此参数配置
# 客户端拉取服务器配置信息的周期 改为1s
eureka.client.registry-fetch-interval-seconds=1此任务实际调用了http://host/eureka/apps/delta这个接口获取服务注册列表, 但这个接口, 同样是有缓存的, 继续看Server配置
Eureka Server配置
Eureka Server存在三个变量: ( registry / readWriteCacheMap / readOnlyCacheMap ) 保存服务注册信息
默认情况下定时任务每30s将readWriteCacheMap同步至readOnlyCacheMap, 每60s清理超过90s未续约的节点, Eureka Client每30s从readOnlyCacheMap获取服务注册信息
# 禁用缓存readOnlyCacheMap, client直接从readWriteCacheMap更新服务注册信息
eureka.server.use-read-only-response-cache: falseEureka在此判断是否取缓存
com.netflix.eureka.registry.ResponseCacheImpl#getValue更改了配置后, B服务启动仅1-2s内就可以被A服务感知到
但这些配置建议仅在开发环境下启用
边栏推荐
- Replace the image source of Debian full version with Alibaba cloud image source
- Software - prerequisite software
- To create a private Ca, I use OpenSSL
- 自适应设计和响应式设计
- 收益率在百分之六以上的理财产品,请说一下
- Qt设计仿真机器人控制器
- Feign for 20 minutes every day
- Lsyncd real time synchronization
- By default, the select drop-down box selects the solution ligerui that the selected attribute does not work
- G026-db-gs-ins-03 openeuler deployment opengauss (1 active and 2 standby or multiple standby)
猜你喜欢
![[loj3247] [USACO 2020.1 platinum](/img/69/f5f7996cd1bb97c84ba381c3df55be.png)
[loj3247] [USACO 2020.1 platinum "non declining subsequences (DP, divide and conquer)

Dynamics crm: mailbox configuration (III) - configure email server profiles and mailboxes

124 maximum path sum in binary tree

Adaptive design and responsive design

LaneATT

Yolov3 trains its own data set

Dynamics 365: how to get the threshold value of executemullerequest in batch requests

C# TCP客户端窗体应用程序异步接收方式

Dynamics 365: how to get the authentication information required to connect to D365 online from azure

MySQL之知识点(十二)
随机推荐
Urban safety series popular science - enter the high incidence period of drowning, if you know the common sense of life-saving
yolov6训练自己的数据集
Software recommendation - Mechanical Major
Error 1053: the service did not respond to the start or control request in a timely fashion
[SWT] scrolling container to realize commodity list style
Leetcode:162. looking for peak [two points looking for peak]
Leetcode 231. 2 的幂
Lsyncd set up synchronous image - use lsyncd to realize real-time synchronization between local and remote servers
How to choose the appropriate data type for fields in MySQL?
Qt设计仿真机器人控制器
Talk about C pointer
Power of leetcode 231.2
TCP协议调试工具TcpEngine V1.3.0使用教程
Getting started with OpenMP
Is it safe for Anxin securities to open an account on mobile phone?
[LeetCode]巧用位运算
LaneATT
Use of ec200u-cn module
Small list of iptables common commands
Multithreading (basic)