DPVS-5: 后端服务监控原理与测试

后端监控原理

被动监测

DPVS自带了被动监控,通过监控后端服务对外部请求的响应情况,判断服务器是否可用。

DPVS的被动监测,并不能获取后端服务器的详细情况,仅仅通过丢包/拒绝情况来发觉后端服务是否可用。

TCP session state transfers from SYN_RECV to CLOSE
TCP session state transfers from SYN_SENT to CLOSE
TCP session expired from SYN_RECV state
TCP session expired from SYN_SENT state
TCP synproxy step 3 received RST when awaiting SYN/ACK from backend
UDP session expired from ONEWAY state

后端服务状态变换

RS服务有4种状态 UP, DOWN, DOWN-WAIT , UP-WARM

UP : 允许访问

DOWN: 不允许访问

DOWN-WAIT:允许访问

UP-WARM:允许访问

整体的状态转换如图

在这里插入图片描述

详细变换逻辑

更细致的状态转换,分为master lcore (控制面worker), slave lcore(数据面 worker) ,下图为官方图

在这里插入图片描述
在这里插入图片描述

后端服务失效的流程

slave 检测服务失败 , 进入DOWN-WAIT, 同时发送Down notice master, master 也进入DOWN-WAIT

当Master接收的Down notice达到阈值(默认为1),进入DOWN, 广播Close notice至所有slave,所有slave进入DOWN。 这样所有lcore中的该后端服务状态都为DOWN了。

后端服务尝试恢复流程

在进入DOWN时,master lcore会启动一个抑制时间的定时器,到期后,广播Open notice至所有slave, 所有slave进入到 UP-WARM状态,此时,外部请求可以分配到这个后端服务。

slave再次检测到该服务不可用,回到后端服务失效逻辑中去,后面的抑制时间会加倍。

后端服务恢复成功流程

当服务器在UP-WARM状态,slave 检测该服务可用,并且已到达可用次数阈值(默认为1),进入UP状态,同时发送Up notice给master, 该后端服务在所有lcore中为UP状态。

后端服务其他情况

slave在UP时, 收到Close notice, 直接进入DOWN状态。 这里的Close notice来自于master, master可以因为外部控制指令等直接DOWN掉后端服务。

这里的消息有

Down notice , slave to master , 单播

Up notice, slave to maser , 单播

Close notice , master to slave, 多播

Open notice, master to slave, 多播

监控测试

未开启后端监测

默认之前的双臂配置
https://blog.csdn.net/jacicson1987/article/details/145803532

# 添加VIP
./dpip addr add 10.0.0.100/32 dev dpdk0# 添加负载均衡服务 ,  轮询模式
./ipvsadm -A -t 10.0.0.100:80 -s rr# 添加 3个RS, FULLNAT 模式
./ipvsadm -a -t 10.0.0.100:80 -r 192.168.100.3:80 -b
./ipvsadm -a -t 10.0.0.100:80 -r 192.168.100.4:80 -b
./ipvsadm -a -t 10.0.0.100:80 -r 192.168.100.5:80 -b# 为负载均衡服务 10.0.0.100:80 添加一个LOCAL IP 在dpdk1上
./ipvsadm --add-laddr -z 192.168.100.200 -t 10.0.0.100:80 -F dpdk1# 添加路由
./dpip route add 10.0.0.0/16 dev dpdk0
./dpip route add 192.168.100.0/24 dev dpdk1

访问正常

[root@dkdp192 ~]# curl 10.0.0.100:80
This is Server 2 !
[root@dkdp192 ~]# curl 10.0.0.100:80
This is Server 1 !
[root@dkdp192 ~]# curl 10.0.0.100:80
This is Server 2 !
[root@dkdp192 ~]# curl 10.0.0.100:80
This is Server 0 !
[root@dkdp192 ~]# curl 10.0.0.100:80
This is Server 1 !
[root@dkdp192 ~]# curl 10.0.0.100:80
This is Server 2 !
[root@dkdp192 ~]# curl 10.0.0.100:80
This is Server 1 !
[root@dkdp192 ~]# curl 10.0.0.100:80
This is Server 0 !
[root@dkdp192 ~]# 

关闭Server 0

root@ubuntu22:~# systemctl stop nginx 
root@ubuntu22:~# 

再测试, 发现请求还是会按照原有的轮询分配到已经disable的 Server 0上去,导致拒绝连接。

[root@dkdp192 ~]# curl 10.0.0.100:80
This is Server 2 !
[root@dkdp192 ~]# curl 10.0.0.100:80
This is Server 2 !
[root@dkdp192 ~]# curl 10.0.0.100:80
This is Server 1 !
[root@dkdp192 ~]# curl 10.0.0.100:80
curl: (7) Failed to connect to 10.0.0.100 port 80: Connection refused
[root@dkdp192 ~]# curl 10.0.0.100:80
This is Server 1 !
[root@dkdp192 ~]# curl 10.0.0.100:80
curl: (7) Failed to connect to 10.0.0.100 port 80: Connection refused
[root@dkdp192 ~]# curl 10.0.0.100:80
This is Server 2 !
[root@dkdp192 ~]# curl 10.0.0.100:80
This is Server 2 !

开启后端被动监测

配置如下

./dpip addr add 10.0.0.100/32 dev dpdk0# 添加负载均衡功能服务时,开启被动监测
./ipvsadm -A -t 10.0.0.100:80 -s rr --dest-check default./ipvsadm -a -t 10.0.0.100:80 -r 192.168.100.3:80 -b
./ipvsadm -a -t 10.0.0.100:80 -r 192.168.100.4:80 -b
./ipvsadm -a -t 10.0.0.100:80 -r 192.168.100.5:80 -b
./ipvsadm --add-laddr -z 192.168.100.200 -t 10.0.0.100:80 -F dpdk1./dpip route add 10.0.0.0/16 dev dpdk0
./dpip route add 192.168.100.0/24 dev dpdk1

RS已配置

root@r750-132:~/dpvs/bin# ./ipvsadm  -ln
IP Virtual Server version 1.9.8 (size=0)
Prot LocalAddress:Port Scheduler Flags-> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  10.0.0.100:80 rr dest-check internal:default-> 192.168.100.3:80             FullNat 1      0          0         -> 192.168.100.4:80             FullNat 1      0          0         -> 192.168.100.5:80             FullNat 1      0          0   

测试脚本

1秒发一次请求,打印响应,如果没有打印,说明访问失败

#!/bin/bashURL="http://10.0.0.100:80"for i in {1..200}
doecho -n "$i: "response=$(curl -s $URL)  # 将 curl 的输出保存到变量 response 中if [ -z "$response" ]; then  # 判断 response 是否为空echo  # 如果为空,输出换行符elseecho "$response"  # 如果不为空,输出 responsefisleep 1
done
失效测试

先开启测试脚本, 在关闭Server 0的 nginx。

第10秒的时候,访问 Server 0 失败

第16秒(+6s),访问Server 0 失败

第26秒(+10s), 访问Server 0 失败

第47秒(+21s). 访问Server 0 失败

第89秒(+42s), 访问Server 0 失败

由此可见,对于DOWN的服务器抑制时间是指数增加的。 (实际是用5s开始,最大3600s)

这里的后端服务状态 在 DOWN – UP-WARM – DOWN-WAIT 之间一直循环。

[root@dkdp192 ~]# ./long_curl.sh 
1: This is Server 0 !
2: This is Server 0 !
3: This is Server 1 !
4: This is Server 0 !
5: This is Server 1 !
6: This is Server 2 !
7: This is Server 2 !
8: This is Server 1 !
9: This is Server 1 !
10: 
11: This is Server 2 !
12: This is Server 2 !
13: This is Server 2 !
14: This is Server 2 !
15: This is Server 2 !
16: 
17: This is Server 2 !
18: This is Server 2 !
19: This is Server 1 !
20: This is Server 1 !
21: This is Server 1 !
22: This is Server 1 !
23: This is Server 1 !
24: This is Server 2 !
25: This is Server 2 !
26: 
27: This is Server 2 !
28: This is Server 1 !
29: This is Server 2 !
30: This is Server 2 !
31: This is Server 1 !
32: This is Server 1 !
33: This is Server 1 !
34: This is Server 2 !
35: This is Server 1 !
36: This is Server 2 !
37: This is Server 1 !
38: This is Server 1 !
39: This is Server 2 !
40: This is Server 1 !
41: This is Server 2 !
42: This is Server 2 !
43: This is Server 1 !
44: This is Server 2 !
45: This is Server 1 !
46: This is Server 2 !
47: 
48: This is Server 2 !
49: This is Server 1 !
50: This is Server 1 !
51: This is Server 2 !
52: This is Server 1 !
53: This is Server 2 !
54: This is Server 1 !
55: This is Server 2 !
56: This is Server 1 !
57: This is Server 1 !
58: This is Server 2 !
59: This is Server 1 !
60: This is Server 2 !
61: This is Server 2 !
62: This is Server 1 !
63: This is Server 2 !
64: This is Server 2 !
65: This is Server 2 !
66: This is Server 1 !
67: This is Server 2 !
68: This is Server 1 !
69: This is Server 1 !
70: This is Server 2 !
71: This is Server 1 !
72: This is Server 2 !
73: This is Server 2 !
74: This is Server 1 !
75: This is Server 2 !
76: This is Server 1 !
77: This is Server 1 !
78: This is Server 1 !
79: This is Server 2 !
80: This is Server 1 !
81: This is Server 1 !
82: This is Server 2 !
83: This is Server 1 !
84: This is Server 2 !
85: This is Server 2 !
86: This is Server 2 !
87: This is Server 1 !
88: This is Server 1 !
89: 
90: This is Server 1 !
91: This is Server 2 !
92: This is Server 1 !
93: This is Server 1 !
94: This is Server 2 !
95: This is Server 2 !
96: This is Server 2 !
97: This is Server 2 !
98: This is Server 2 !
99: This is Server 1 !
100: This is Server 2 !
101: This is Server 2 !
服务器状态

Server 0是抑制状态inhibited.

root@r750-132:~/dpvs/bin# ./ipvsadm  -ln
IP Virtual Server version 1.9.8 (size=0)
Prot LocalAddress:Port Scheduler Flags-> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  10.0.0.100:80 rr dest-check internal:default-> 192.168.100.3:80             FullNat 0      0          0          inhibited-> 192.168.100.4:80             FullNat 1      0          4         -> 192.168.100.5:80             FullNat 1      0          4   
查看日志

与测试结果完全对应,失效的后端服务,抑制时间也是 5s, 10s, 20s , 40s …


SERVICE: [cid 07, tcp, svc 10.0.0.100:80, rs 192.168.100.3:80, weight 1, inhibited no, warm_up_count 0] detect dest DOWN
SERVICE: [cid 00, tcp, svc 10.0.0.100:80, rs 192.168.100.3:80, weight 1, inhibited yes, down_notice_recvd 1, inhibit_duration 5s, origin_weight 0] notify slaves DOWN
SERVICE: [cid 00, tcp, svc 10.0.0.100:80, rs 192.168.100.3:80, weight 0, inhibited yes, down_notice_recvd 1, inhibit_duration 10s, origin_weight 1] notify slaves UP
SERVICE: [cid 06, tcp, svc 10.0.0.100:80, rs 192.168.100.3:80, weight 1, inhibited no, warm_up_count 1] detect dest DOWN
SERVICE: [cid 00, tcp, svc 10.0.0.100:80, rs 192.168.100.3:80, weight 1, inhibited yes, down_notice_recvd 1, inhibit_duration 10s, origin_weight 0] notify slaves DOWN
SERVICE: [cid 00, tcp, svc 10.0.0.100:80, rs 192.168.100.3:80, weight 0, inhibited yes, down_notice_recvd 1, inhibit_duration 20s, origin_weight 1] notify slaves UP
SERVICE: [cid 04, tcp, svc 10.0.0.100:80, rs 192.168.100.3:80, weight 1, inhibited no, warm_up_count 1] detect dest DOWN
SERVICE: [cid 00, tcp, svc 10.0.0.100:80, rs 192.168.100.3:80, weight 1, inhibited yes, down_notice_recvd 1, inhibit_duration 20s, origin_weight 0] notify slaves DOWN
SERVICE: [cid 00, tcp, svc 10.0.0.100:80, rs 192.168.100.3:80, weight 0, inhibited yes, down_notice_recvd 1, inhibit_duration 40s, origin_weight 1] notify slaves UP
恢复测试

开启Server 0 nginx

[root@dkdp192 ~]# ./long_curl.sh 
1: This is Server 2 !
2: This is Server 2 !
3: 
4: This is Server 2 !
5: This is Server 2 !
6: This is Server 1 !
7: This is Server 2 !
8: This is Server 2 !
9: This is Server 1 !
10: This is Server 1 !
11: This is Server 2 !
12: This is Server 2 !
13: This is Server 1 !
14: This is Server 1 !
15: This is Server 1 !
16: This is Server 2 !
17: This is Server 2 !
18: This is Server 1 !
19: This is Server 1 !
20: This is Server 1 !
21: This is Server 2 !
22: This is Server 2 !
23: This is Server 2 !
24: This is Server 1 !
25: This is Server 1 !
26: This is Server 0 !
27: This is Server 2 !
28: This is Server 0 !
29: This is Server 0 !
30: This is Server 1 !
31: This is Server 1 !
32: This is Server 1 !
33: This is Server 0 !
服务器状态

Server 0 在连通后,恢复状态

root@r750-132:~/dpvs/bin# ./ipvsadm  -ln
IP Virtual Server version 1.9.8 (size=0)
Prot LocalAddress:Port Scheduler Flags-> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  10.0.0.100:80 rr dest-check internal:default-> 192.168.100.3:80             FullNat 1      0          3         -> 192.168.100.4:80             FullNat 1      0          3         -> 192.168.100.5:80             FullNat 1      0          1 
查看日志

多个slave worker检测到后端恢复

SERVICE: [cid 06, tcp, svc 10.0.0.100:80, rs 192.168.100.3:80, weight 1, inhibited no, warm_up_count 1] detect dest UP
SERVICE: [cid 04, tcp, svc 10.0.0.100:80, rs 192.168.100.3:80, weight 1, inhibited no, warm_up_count 1] detect dest UP
SERVICE: [cid 07, tcp, svc 10.0.0.100:80, rs 192.168.100.3:80, weight 1, inhibited no, warm_up_count 1] detect dest UP
SERVICE: [cid 08, tcp, svc 10.0.0.100:80, rs 192.168.100.3:80, weight 1, inhibited no, warm_up_count 1] detect dest UP

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/70821.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【计算机网络协议01】应用层协议HTTP

应用层协议HTTP 引言 应用层协议是程序员自己制定的,但是良好的协议是保证网络通信的基础,前代的计算工程师已经帮助我们制定了一些很好用的应用层协议,http(hybertext transfer protocol)(超文本传输协议)就是其中之一。 http协议是客户端…

uniapp 系统学习,从入门到实战(四)—— 页面与路由管理

​ 全篇大概 2700 字(含代码),建议阅读时间 20min 在跨平台开发中,高效的路由管理直接影响用户体验和开发效率。本文将深入探讨uniapp的页面创建、路由跳转、参数传递和生命周期管理,助您构建流畅的多端应用。 📚 目录 页面创建…

BOOST电路设计

目录 1电路模型 2器件选型 2.1设计需求 2.2参数计算 2.2.1电感L计算 2.2.2电容计算 2.2.3电阻计算 3仿真测试 4参数测试 4.1负载调整率 4.2电容测试 4.3电感测试 5实际应用 1电路模型 Boost升压电路,可以工作在电流断续工作模式(DCM)和电流连续工作模式(CCM)。CCM工…

springboot实现文件上传到华为云的obs

一、前言 有时在项目中需要使用一些存储系统来存储文件&#xff0c;那么当项目要接入obs作为存储系统时&#xff0c;就会利用obs来进行文件的上传下载&#xff0c;具体实现如下。 二、如何通过obs实现文件的上传下载&#xff1f; 1.添加相关的obs的maven依赖。 <dependency…

miqiu的分布式锁(二):实战——用JMeter验证JVM锁能否解决MySQL超卖问题

miqiu的分布式锁二&#xff1a;实战——用JMeter验证JVM锁能否解决MySQL超卖问题 实验背景 在秒杀场景中&#xff0c;超卖问题是典型的并发编程挑战。本文通过JMeter压测工具&#xff0c;验证基于JVM的两种锁机制&#xff08;synchronized/ReentrantLock&#xff09;对MySQL库…

《论企业集成平台的理解与应用》审题技巧 - 系统架构设计师

企业集成平台的理解与应用——论文写作框架 一、考点概述 本论题“企业集成平台的理解与应用”主要考察的是计算机软件测试工程师对于企业集成平台&#xff08;EIP&#xff09;的深入理解以及在实际项目中的应用能力。论题涵盖了以下几个核心内容&#xff1a; 首先&#xff…

初阶数据结构(C语言实现)——2算法的时间复杂度和空间复杂度

目录 本节目标1. 算法效率1.1 如何衡量一个算法的好坏1.2 算法的复杂度 2.时间复杂度2.1 时间复杂度的概念2.1.1 入门习题2.1.2 进阶习题 2.2 常见时间复杂度 3. 空间复杂度3.1 常见空间复杂度 本节目标 算法效率时间复杂度空间复杂度常见时间复杂度以及复杂度oj练习 1. 算法…

排序算法(3):

这是我们的最后一篇排序算法了&#xff0c;也是我们的初阶数据结构的最后一篇了。 我们来看&#xff0c;我们之前已经讲完了插入排序&#xff0c;选择排序&#xff0c;交换排序&#xff0c;我们还剩下最后一个归并排序&#xff0c;我们今天就讲解归并排序&#xff0c;另外我们还…

AI智能体与大语言模型:重塑SaaS系统的未来航向

在数字化转型的浪潮中&#xff0c;软件即服务&#xff08;SaaS&#xff09;系统一直是企业提升效率、优化业务流程的重要工具。随着AI智能体和大语言模型&#xff08;LLMs&#xff09;的迅速发展&#xff0c;SaaS系统正迎来前所未有的变革契机。本文将从AI智能体和大语言模型对…

AOP进阶-03.切入点表达式-execution

一.切入点表达式-execution 访问修饰符(public/private等)&#xff0c;包名.类名.&#xff0c;throws 异常都可以省略&#xff0c;但是建议包名.类名.不要省略&#xff0c;否则的话匹配范围太大影响程序执行效率。 *主要用来匹配单个参数&#xff0c;通配任意返回值、包名、类…

神经网络发展简史:从感知机到通用智能的进化之路

引言 神经网络作为人工智能的核心技术&#xff0c;其发展历程堪称一场人类对生物大脑的致敬与超越。本文将用"模型进化"的视角&#xff0c;梳理神经网络发展的五大关键阶段&#xff0c;结合具象化比喻和经典案例&#xff0c;为读者呈现一幅清晰的AI算法发展图谱。 一…

NLP09-加强1-对比SVM

支持向量机&#xff08;SVM&#xff09; &#xff08;一&#xff09;导入 SVM 相关库 &#xff08;二&#xff09; 修改模型初始化 &#xff08;三&#xff09; 比较 朴素贝叶斯分类器 SVM分类器 支持向量机&#xff08;SVM&#xff09; 代码修改基于NLP09-朴素贝叶斯问句…

Spring 源码硬核解析系列专题(八):Spring Security 的认证与授权源码解析

在前几期中,我们从 Spring 核心到 Spring Boot,再到 Spring Cloud,逐步探索了 Spring 生态的底层原理。作为企业级应用的关键组件,Spring Security 提供了全面的安全解决方案,包括认证(Authentication)和授权(Authorization)。本篇将深入 Spring Security 的源码,剖析…

DeepSeek 开源了 DeepEP

DeepSeek又开源了一个超强技术&#xff1a;DeepEP通信库。实现了MOE之间的通信&#xff0c;性能更强了&#xff01; DeepEP作为全球首个专为MoE&#xff08;专家混合&#xff09;模型训练和推理量身定制的EP&#xff08;专家并行&#xff09;通信库&#xff0c;其诞生标志着通…

【C语言】指针笔试题

前言&#xff1a;上期我们介绍了sizeof与strlen的辨析以及sizeof&#xff0c;strlen相关的一些笔试题&#xff0c;这期我们主要来讲指针运算相关的一些笔试题&#xff0c;以此来巩固我们之前所学的指针运算&#xff01; 文章目录 一&#xff0c;指针笔试题1&#xff0c;题目一…

电脑键盘知识

1、键盘四大功能区 1. 功能区 2. 主要信息输入区 3. 编辑区 4. 数字键盘区 笔记本电脑键盘的功能区&#xff0c;使用前需先按Fn键 1.1、功能区 ESC&#xff1a;退出 F1&#xff1a;显示帮助信息 F2&#xff1a;重命名 F4&#xff1a;重复上一步操作 F5&#xff1a;刷新网页 …

在 macOS 系统上安装 kubectl

在 macOS 系统上安装 kubectl 官网&#xff1a;https://kubernetes.io/zh-cn/docs/tasks/tools/install-kubectl-macos/ 用 Homebrew 在 macOS 系统上安装 如果你是 macOS 系统&#xff0c;且用的是 Homebrew 包管理工具&#xff0c; 则可以用 Homebrew 安装 kubectl。 运行…

004 Kafka异常处理

6.异常处理 文章目录 6.异常处理1.异常分类与处理原则2.生产者异常处理1. 同步发送捕获异常2. 异步发送回调处理 3.消费者异常处理1.全局异常处理器2.方法级处理3.重试yml配置 4.死信队列&#xff08;DLQ&#xff09;配置1. 启用死信队列2. 手动发送到DLQ 5.事务场景异常处理1.…

Spring MVC框架六:Ajax技术

精心整理了最新的面试资料&#xff0c;有需要的可以自行获取 点击前往百度网盘获取 点击前往夸克网盘获取 简介 jQuery.ajax Ajax原理 结语 创作不易&#xff0c;希望能对大家给予帮助 想要获取更多资源? 点击链接获取

数据结构与算法:二维前缀和、二维差分及离散化技巧

前言 有一维的前缀和以及差分当然有二维的~ 一、二维前缀和 1.内容 二维前缀和就是求二维数组上从&#xff08;0,0&#xff09;位置到&#xff08;i,j&#xff09;位置的累加和。 2.模板——二维区域和检索 - 矩阵不可变 class NumMatrix { public:vector<vector<i…