当前位置:网站首页>千万级QPS下服务如何才能平滑启动
千万级QPS下服务如何才能平滑启动
2022-08-02 17:43:00 【InfoQ】
背景

原因分析
解决方案

- 第一步要保证系统顺利完全启动完成后,才能有流量访问;
- 第二步小流量预热,通过小部分流量让JVM 虚拟机把高频的代码编译成机器码缓存到 JVM 缓存中,再次使用的时候不会触发临时加载;
- 第三步逐步放到流量到全量,当大流量请求使用热点代码时,不用每次都通过都进行解释,最终实现平滑启动。
系统完全启动
F5探活
注册中心注册

ribbon.eager-load.enabled=true
ribbon.eager-load.clients=service_id1,service_id2探针探活

<--省略无用信息-->
spec:
containers:
- name: *****
image: *****
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8090
initialDelaySeconds: 5 # 容器启动后多久开始探测
failureThreshold: 10 # 连续探测10次失败表示失败
timeoutSeconds: 10 # 表示容器必须在10s内做出相应反馈给probe,否则视为探测失败
periodSeconds: 5 # 探测周期,每5s探测一次
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8090
initialDelaySeconds: 10 # 容器启动后多久开始探测
timeoutSeconds: 2 # 表示容器必须在2s内做出相应反馈给probe,否则视为探测失败
periodSeconds: 30 # 探测周期,每30s探测一次
successThreshold: 1 # 连续探测1次成功表示成功
failureThreshold: 3 # 连续探测3次失败表示失败
<--省略无用信息-->小流量预热

开源 Dubbo

- 服务提供端在向注册中⼼注册服务的过程中,将⾃身的预热时⻓ WarmupTime、服务启动时间 StartTime 通过元数据的形式注册到注册中⼼中;
- 服务消费端在注册中⼼订阅相关服务实例列表,调⽤过程中根据 WarmupTime、StartTime 计算个实例所分批的调⽤权重;
- 刚启动 StartTime 距离调⽤时刻差值较⼩的实例权重下,从⽽实现对刚启动应⽤分配更少流量实现对 其进⾏⼩流量预热。
开源美团OCTO-RPC


Serivce Mesh Isito-proxy

message SlowStartConfig {
// Represents the size of slow start window.
// If set, the newly created host remains in slow start mode starting from its creation time
// for the duration of slow start window.
google.protobuf.Duration slow_start_window = 1;
// This parameter controls the speed of traffic increase over the slow start window. Defaults to 1.0,
// so that endpoint would get linearly increasing amount of traffic.
// When increasing the value for this parameter, the speed of traffic ramp-up increases non-linearly.
// The value of aggression parameter should be greater than 0.0.
// By tuning the parameter, is possible to achieve polynomial or exponential shape of ramp-up curve.
//
// During slow start window, effective weight of an endpoint would be scaled with time factor and aggression:
// `new_weight = weight * time_factor ^ (1 / aggression)`,
// where `time_factor=(time_since_start_seconds / slow_start_time_seconds)`.
//
// As time progresses, more and more traffic would be sent to endpoint, which is in slow start window.
// Once host exits slow start, time_factor and aggression no longer affect its weight.
core.v3.RuntimeDouble aggression = 2;
}总结
- 实例启动,包括JVM、Spring等初始化和一些微服务组件如配置中心的初始化,值得注意的是资源未完全加载前不要注册到注册中心中,可以通过设置延迟注册,让应⽤在充分初始化后再注册到注册中⼼对外提供服务;
- 小流量预热,通过客户端负载和权重算法,使刚启动的实例节点流量成线性增长,最终达到正常水平;
- 全量运行,需要查看JVM、接口相应时间指标监控和日志,保证新启动实例上线没问题。
边栏推荐
猜你喜欢

故障分析 | 一条 SELECT 语句跑崩了 MySQL ,怎么回事?

Navicat 连接Oracle时提示oracle library is not loaded的问题解决

研发运营一体化(DevOps)能力成熟度模型

什么是SVN(Subversion)?

E-Surfing Cloud 4.0 Distributed Cloud Enables Digital Transformation of Thousands of Industries

深圳地铁16号线二期进入盾构施工阶段,首台盾构机顺利始发

有关代购系统搭建的那点事

Playing in the cloud | The key technology of Tianyi cloud object storage ZOS high availability is revealed

新特性解读 | MySQL 8.0 GIPK 不可见主键

erp系统和wms系统有什么区别
随机推荐
解决多版本jar包冲突问题
What is the difference between erp system and wms system
脉脉上的相亲生意
Gear 月度更新|6 月
启航
方法的使用
Dream weaving prompt information prompt box beautification
Mini Program Graduation Works WeChat Gymnasium Reservation Mini Program Graduation Design Finished Product (8) Graduation Design Thesis Template
vulnhub W34kn3ss: 1
详细教学——1688关键词搜索API操作流程
租房小程序自动定位城市
How a "cloud" can bring about new changes in the industry
golang刷leetcode 经典(4) 实现跳表
文件上传很难搞?10分钟带你学会阿里云OSS对象存储
年轻人接棒大妈,金价跌回“4字头”,七夕迎黄金消费小热潮
golang刷leetcode动态规划(9)不同路径 II
golang源码分析(19)简单编译器-计算器
土巴兔IPO五次折戟,互联网家装未解“中介”之痛
ES: WeakSet
NeRF:火爆科研圈的三维重建技术大揭秘