惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
S
Schneier on Security
The Hacker News
The Hacker News
P
Proofpoint News Feed
Spread Privacy
Spread Privacy
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
I
Intezer
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Schneier on Security
Schneier on Security
Security Latest
Security Latest
AWS News Blog
AWS News Blog
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
有赞技术团队
有赞技术团队
博客园 - 叶小钗
The Last Watchdog
The Last Watchdog
O
OpenAI News
月光博客
月光博客
Hacker News: Ask HN
Hacker News: Ask HN
阮一峰的网络日志
阮一峰的网络日志
S
Security @ Cisco Blogs
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Latest news
Latest news
P
Palo Alto Networks Blog
Last Week in AI
Last Week in AI
M
MIT News - Artificial intelligence
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
Apple Machine Learning Research
Apple Machine Learning Research
U
Unit 42
PCI Perspectives
PCI Perspectives
博客园 - 聂微东
SecWiki News
SecWiki News
宝玉的分享
宝玉的分享
Forbes - Security
Forbes - Security
H
Heimdal Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Hugging Face - Blog
Hugging Face - Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Troy Hunt's Blog
博客园 - 三生石上(FineUI控件)
Application and Cybersecurity Blog
Application and Cybersecurity Blog
罗磊的独立博客
WordPress大学
WordPress大学
D
Darknet – Hacking Tools, Hacker News & Cyber Security

Yulin Lewis' Blog

cron表达式 cmd - 常用命令 Eureka问题汇总 Excel常见用法 shell脚本常用语法 Linux常用命令 别了,向晚 必胜客自助餐 Prometheus简易入门 Chrome问题汇总 SSH命令问题汇总 PGP加解密 GitHub问题汇总 SmartGit问题汇总 HttpClient问题汇总 Oculus Quest2食用指南 背包英雄:匕首流无尽模式详细攻略 Linux问题汇总 Postman问题汇总 别了,珈乐 桌面窗口管理器占用内存过高 ELK系列(6) - Elasticsearch常用接口 ELK系列(5) - Elasticsearch性能调优 MyBatis问题汇总 PostgreSQL - SQL调优方案 Java - 字符编码 Spring Data Redis问题汇总 Java数值问题汇总 lombok问题汇总
Apollo问题汇总
雨临Lewis · 2023-05-09 · via Yulin Lewis' Blog

Apollo简介

Apollo作为分布式配置中心,主要分为三个部分:客户端Client、服务端Server、管理门户Portal。Portal提供Web界面供用户管理配置。

Apollo涉及到3个进程,启动时需要按照configservice、adminservice、portal的顺序。

Apollo下发更新超时失败

项目使用Apollo来保存微服务接口的相关信息,做法是把部署在某个边车里的所有微服务接口信息都存到一个xml文件中,该文件会读取为一个字符串被保存到Apollo数据库release表的Configurations字段。每次改动某个接口时,都会触发一次xml文件的更新并下发到Apollo。

由于该字段是longtext类型,随着维护接口的数量增长,该字段要维护的xml文件越来越大,最大可达十几M,此时发现Apollo经常更新配置失败。

经过排查,发现Apollo底层用的Hibernate来将数据保存到数据库,由于没有给Apollo客户端设置超时时间,该参数底层默认值为-1。对于httpclient的sockettimeout参数,-1表示使用系统默认值,在部署的Linux机器上该默认值为5秒,因此下发数据时由于Configurations字段值很大导致超时失败。

这里分为两部分来优化,一个是将边车中部分接口迁移到其他边车,减少当前边车对应的xml文件大小;一个是调大Apollo客户端的读取超时时间为20s,经过测试差不多需要五秒多的时间才能将原本十几M的xml文件保存到数据库中。

1
2
3
4
5
6
7
8
9
public static ApolloOpenApiClient getApolloPortalClient() {
        String portalUrl = ESCConfigUtil.getValue("esc.apollo.portal"); // portal url
        String token = ESCConfigUtil.getValue("esc.apollo.token"); // 申请的token
        return ApolloOpenApiClient.newBuilder()
                .withReadTimeout(20000)
                .withPortalUrl(portalUrl)
                .withToken(token)
                .build();
}

此外,频繁更新下发数据,会导致release表和releasehistory表数据量剧增,Apollo本身没有对此提供清理策略,需要自行设置定时任务去定时定量删除无效或者无意义的历史数据。

value too long. length limit

在下发数据到Apollo时报错ApolloOpenApiException,错误信息显示value too long. length limit:2000000,这个是因为下发的value数据(一个xml字符串)太大,超过了默认的长度。

Apollo数据库apolloconfigserverconfig表有个属性控制了value长度,将item.value.length.limit值改成更大的长度,再重启Apollo进程即可。

这里还有另一个属性item.key.length.limit用于控制key的长度,改动生效也同理。

参考链接

警告

本文最后更新于 September 10, 2024,文中内容可能已过时,请谨慎使用。

赞赏支持

微信打赏 支付宝打赏