当前位置: 首页 > news >正文

k8s异常Too many requests: Too many requests, please try again later.

问题现象

服务中使用了k8s client-go,日志里频繁出现如下异常信息,且部分节点出现NotReady状态。

failed to list *vI. Endpoints: Too many requests: Too m
any requests, please try again later.

关于k8s Apiserver的限流

通过总量限流,这种方案是比较简单粗暴的

读请求并发量限制

--max-requests-inflight int     Default: 400

This and --max-mutating-requests-inflight are summed to determine the server's total concurrency limit (which must be positive) if --enable-priority-and-fairness is true. Otherwise, this flag limits the maximum number of non-mutating requests in flight, or a zero value disables the limit completely.

写请求并发量限制

--max-mutating-requests-inflight int     Default: 200

This and --max-requests-inflight are summed to determine the server's total concurrency limit (which must be positive) if --enable-priority-and-fairness is true. Otherwise, this flag limits the maximum number of mutating requests in flight, or a zero value disables the limit completely.

关于--enable-priority-and-fairness

--enable-priority-and-fairness     Default: true

If true and the APIPriorityAndFairness feature gate is enabled, replace the max-in-flight handler with an enhanced one that queues and dispatches with priority and fairness。

因此默认配置下,ApiServer的总并发量限制=400+200

关于k8s集群节点心跳

节点心跳的上报也是经过ApiServer,因此触发限流后,会导致心跳上报失败。

Kubernetes 节点发送的心跳帮助你的集群确定每个节点的可用性,并在检测到故障时采取行动。

节点的心跳由kubelet发送。

心跳类型心跳方式
更新节点的.status默认间隔5min
更新kube-node-lease空间里的Lease对象默认间隔10s

kubelet 负责创建和更新节点的 .status,以及更新它们对应的 Lease。

当节点状态发生变化时,或者在配置的时间间隔内没有更新事件时,kubelet 会更新 .status。 .status 更新的默认间隔为 5 分钟(比节点不可达事件的 40 秒默认超时时间长很多)。

kubelet 会创建并每 10 秒(默认更新间隔时间)更新 Lease 对象。 Lease 的更新独立于节点的 .status 更新而发生。 如果 Lease 的更新操作失败,kubelet 会采用指数回退机制,从 200 毫秒开始重试, 最长重试间隔为 7 秒钟。

关于client-go的并发限制

client-go访问ApiServer时,也进行了client端的限流,采用令牌桶限流算法

By default in client-go the Burst is 10 and QPS is 5。

保持QPS=5,应对突发流量QPS=burst。初始令牌桶里有burst个token。

// QPS indicates the maximum QPS to the master from this client.// If it's zero, the created RESTClient will use DefaultQPS: 5QPS float32// Maximum burst for throttle.// If it's zero, the created RESTClient will use DefaultBurst: 10.Burst int
func flowcontrol.NewTokenBucketRateLimiter(qps float32, burst int) flowcontrol.RateLimiter
NewTokenBucketRateLimiter creates a rate limiter which implements a token bucket approach. 
The rate limiter allows bursts of up to 'burst' to exceed the QPS, 
while still maintaining a smoothed qps rate of 'qps'. 
The bucket is initially filled with 'burst' tokens, 
and refills at a rate of 'qps'. 
The maximum number of tokens in the bucket is capped at 'burst'.

相关文章:

  • Flask 上传文件,requests通过接口上传文件
  • 【Maven教程】(九):使用 Maven 进行测试 ~
  • C++之C++11字符串字面量后缀总结(二百四十八)
  • 分享从零开始学习网络设备配置--任务4.2 使用IPv6静态及默认路由实现网络连通
  • SpringCore完整学习教程5,入门级别
  • 软考系列(系统架构师)- 2012年系统架构师软考案例分析考点
  • 应用案例|基于三维机器视觉的曲轴自动化上下料应用方案
  • Nginx的进程结构实例演示
  • 方案聚焦:高可用的F5分布式云DNS负载均衡
  • 模数转换器-ADC基础
  • Harmony 个人中心(页面交互、跳转、导航、容器组件)
  • How to install mongodb-7.0 as systemd service with podman
  • 【AD9361 数字接口CMOS LVDSSPI】B 并行数据之CMOS
  • C# 递归算法使用简介_常用整理
  • C++初阶-类和对象(中)1
  • 【399天】跃迁之路——程序员高效学习方法论探索系列(实验阶段156-2018.03.11)...
  • Golang-长连接-状态推送
  • Java 11 发布计划来了,已确定 3个 新特性!!
  • niucms就是以城市为分割单位,在上面 小区/乡村/同城论坛+58+团购
  • 汉诺塔算法
  • 聊聊directory traversal attack
  • 那些年我们用过的显示性能指标
  • 推荐一款sublime text 3 支持JSX和es201x 代码格式化的插件
  • 学习HTTP相关知识笔记
  • 云栖大讲堂Java基础入门(三)- 阿里巴巴Java开发手册介绍
  • python最赚钱的4个方向,你最心动的是哪个?
  • # 执行时间 统计mysql_一文说尽 MySQL 优化原理
  • #我与Java虚拟机的故事#连载09:面试大厂逃不过的JVM
  • $GOPATH/go.mod exists but should not goland
  • (3)llvm ir转换过程
  • (BFS)hdoj2377-Bus Pass
  • (HAL库版)freeRTOS移植STMF103
  • (八)c52学习之旅-中断实验
  • (附源码)ssm旅游企业财务管理系统 毕业设计 102100
  • (黑马C++)L06 重载与继承
  • (六)软件测试分工
  • (提供数据集下载)基于大语言模型LangChain与ChatGLM3-6B本地知识库调优:数据集优化、参数调整、Prompt提示词优化实战
  • (一)spring cloud微服务分布式云架构 - Spring Cloud简介
  • (转载)Google Chrome调试JS
  • * CIL library *(* CIL module *) : error LNK2005: _DllMain@12 already defined in mfcs120u.lib(dllmodu
  • .Net中ListT 泛型转成DataTable、DataSet
  • ??javascript里的变量问题
  • [ Linux ] Linux信号概述 信号的产生
  • [ 云计算 | AWS 实践 ] 基于 Amazon S3 协议搭建个人云存储服务
  • [1181]linux两台服务器之间传输文件和文件夹
  • [BZOJ5250][九省联考2018]秘密袭击(DP)
  • [CDOJ 1343] 卿学姐失恋了
  • [HAOI2016]食物链
  • [HNOI2008]玩具装箱toy
  • [iOS]GCD(一)
  • [JS]Math.random()随机数的二三事
  • [LeetCode][LCR178]训练计划 VI——使用位运算寻找数组中不同的数字
  • [leetcode]114. Flatten Binary Tree to Linked List由二叉树构建链表
  • [LeetCode]—Permutations 求全排列
  • [Matlab有限元分析] 2.杆单元有限元分析