当前位置:网站首页>解决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服务感知到
但这些配置建议仅在开发环境下启用
边栏推荐
- Druid integration shardingsphere appears xxmapper Reasons and solutions of XML error reporting
- Custom view - Custom button
- EC200U-CN模块的使用
- LaneATT
- 矩阵的秩和图像的秩的一些了解
- More than 40 Qualcomm chips have been exposed to security vulnerabilities, affecting billions of mobile phones!
- Feign for 20 minutes every day
- Caikeng Alibaba cloud Kex_ exchange_ identification: read: Connection reset by peer
- Is it safe for Anxin securities to open an account on mobile phone?
- Scala functions and their higher-order applications
猜你喜欢

Research on the efficiency of numpy array access

Which is a good noise reduction Bluetooth headset? Ranking of the most cost-effective noise reduction Bluetooth headsets

Telephone system rules

Some understanding of the rank sum of matrix and the rank of image

AttributeError: module ‘seaborn‘ has no attribute ‘histplot‘

124 maximum path sum in binary tree

leetcode:162. 寻找峰值【二分寻找峰值】

普林斯顿微积分读本02第一章--函数的复合、奇偶函数、函数图像

Withdrawal of IPO application, Yunzhou intelligent "tour" of unmanned boat enterprise fails to enter the science and Technology Innovation Board

How to choose the appropriate data type for fields in MySQL?
随机推荐
自适应设计和响应式设计
REST风格
Dynamics crm: sharing records for users and teams
More than 40 Qualcomm chips have been exposed to security vulnerabilities, affecting billions of mobile phones!
There are more than 20 categories of the four operators in MySQL. It took three days and three nights to sort them out. Don't collect them quickly
Please talk about the financial products with a yield of more than 6%
【LeetCode】Day102-螺旋矩阵 II
Talk about C pointer
Adaptive design and responsive design
Vscode common shortcut keys
MySQL converts strings to numeric types and sorts them
Dynamics crm: mailbox configuration (III) - configure email server profiles and mailboxes
图片浏览器?Qt也可以实现!
Dynamics crm: [problem solved]cannot open SQL encryption symmetric key because symmetric key password
Princeton calculus reader 02 Chapter 1 -- composition of functions, odd and even functions, function images
Leetcode 231. 2 的幂
My first blog
vscode常用快捷键
[SWT] user defined data table
ZBar source code analysis - img_ scanner. c | [email protected]