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/bash

URL="http://10.0.0.100:80"

for i in {1..200}
do
  echo -n "$i: "
  response=$(curl -s $URL)  # 将 curl 的输出保存到变量 response 中
  if [ -z "$response" ]; then  # 判断 response 是否为空
    echo  # 如果为空,输出换行符
  else
    echo "$response"  # 如果不为空,输出 response
  fi
  sleep 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

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

第438场周赛:判断操作后字符串中的数字是否相等、提取至多 K 个元素的最大总和、判断操作后字符串中的数字是否相等 Ⅱ、正方形上的点之间的最大距离

Q1、判断操作后字符串中的数字是否相等 1、题目描述 给你一个由数字组成的字符串 s 。重复执行以下操作,直到字符串恰好包含 两个 数字: 从第一个数字开始,对于 s 中的每一对连续数字,计算这两个数字的和 模 10。用计算得到的新…

计算机毕业设计SpringBoot+Vue.js学科竞赛管理系统(源码+文档+PPT+讲解)

温馨提示:文末有 CSDN 平台官方提供的学长联系方式的名片! 温馨提示:文末有 CSDN 平台官方提供的学长联系方式的名片! 温馨提示:文末有 CSDN 平台官方提供的学长联系方式的名片! 作者简介:Java领…

2.24力扣-回溯电话号码的字母组合

17. 电话号码的字母组合 - 力扣&#xff08;LeetCode&#xff09; class Solution {List<String> ans new LinkedList<>();StringBuilder temp new StringBuilder();public List<String> letterCombinations(String digits) {if(digitsnull || digits.leng…

在PyCharm中集成AI编程助手并嵌入本地部署的DeepSeek-R1模型:打造智能开发新体验

打造智能开发新体验&#xff1a;DeepSeekPycharmollamaCodeGPT 目录 打造智能开发新体验&#xff1a;DeepSeekPycharmollamaCodeGPT前言一、什么是ollama&#xff1f;二、如何使用1.进入ollama官方网站:2.点击下载ollama安装包3.根据默认选项进行安装4.安装成功5.打开命令提示符…

游戏引擎学习第120天

仓库:https://gitee.com/mrxiao_com/2d_game_3 上次回顾&#xff1a;周期计数代码 我们正在进行一个项目的代码优化工作&#xff0c;目标是提高性能。当前正在优化某个特定的代码片段&#xff0c;已经将其执行周期减少到48个周期。为了实现这一目标&#xff0c;我们设计了一个…

三级等保|三级等保认证|三级等保申请

在信息化时代&#xff0c;信息安全已成为企业及组织不可缺的重要环节。三级等保作为我国信息安全等级保护体系中的重要组成部分&#xff0c;其办理过程需严格遵守相关法律法规和标准。以下是在办理三级等保过程中需要注意的若干事项&#xff1a; 一、明确等级保护对象 首先&…

基于 SpringBoot 的 “电影交流平台小程序” 系统的设计与实现

大家好&#xff0c;今天要和大家聊的是一款基于 SpringBoot 的 “电影交流平台小程序” 系统的设计与实现。项目源码以及部署相关事宜请联系我&#xff0c;文末附上联系方式。 项目简介 基于 SpringBoot 的 “电影交流平台小程序” 系统设计与实现的主要使用者分为 管理员 和…

免费PDF工具

Smallpdf.com - A Free Solution to all your PDF Problems Smallpdf - the platform that makes it super easy to convert and edit all your PDF files. Solving all your PDF problems in one place - and yes, free. https://smallpdf.com/#rappSmallpdf.com-解决您所有PD…

基于YOLO11深度学习的苹果叶片病害检测识别系统【python源码+Pyqt5界面+数据集+训练代码】

《------往期经典推荐------》 一、AI应用软件开发实战专栏【链接】 项目名称项目名称1.【人脸识别与管理系统开发】2.【车牌识别与自动收费管理系统开发】3.【手势识别系统开发】4.【人脸面部活体检测系统开发】5.【图片风格快速迁移软件开发】6.【人脸表表情识别系统】7.【…

API测试工具:Swagger vs Postman 2025最新全面对比

随着微服务架构的普及和云原生应用的激增&#xff0c;高效的 API 开发、测试和文档管理工具变得越来越重要。在众多 API 工具中&#xff0c;Swagger 和 Postman 各自以不同的方式解决着 API 开发生命周期中的关键问题&#xff0c;本文将从多个维度深入对比这两款工具&#xff0…

UE 跟着官方文档学习 容器TArray 系列三

一.先来看官方文档如何描述&#xff0c;写的通俗易懂。直接些测试代码 Append 能一次加多个&#xff0c;注意可能要换成UE_ARRAY_COUNT 算要加的数组的大小。 AddUnique()只会添加没有的&#xff0c;独一无二的。 Insert 插到指定下标。0,1,2,3 SetNum设置容器元素数量&#…

【linux】自主shell编写

&#x1f525;个人主页&#xff1a;Quitecoder &#x1f525;专栏&#xff1a;linux笔记仓 目录 01.输出命令行02.获取用户命令字符串03.命令行字符串分割04.执行命令05.细节修改检查是否为内建命令 完整代码&#xff1a; 01.输出命令行 完成对一个shell 的编写&#xff0c;首…

R与RStudio简介及安装

目录 一、R与RStudio关系 二、R简介 2.1. 发展历史 2.2. R语言特点 三、安装指南 3.1 R安装指南 3.2 R studio安装指南 一、R与RStudio关系 R是统计领域广泛使用的工具&#xff0c;属于GNU系统的一个自由、免费、源代码开放的软件&#xff0c;是 用于统计计算和统计绘图…

在MPSOC上运行ADRV9371射频子板

本例程实现在MPSOC开发板上运行ADRV9026的HDL官方提供的历程。 解压提供文件压缩包“adrv9026.zip”&#xff0c;解压后有三个文件夹&#xff0c;首先是“hdl-2023_R2”为vivado端的项目&#xff0c;里面有各种射频子板加不同底板的项目&#xff0c;本例程使用的是ZCU102…

全面理解-深拷贝与浅拷贝

在 C 中&#xff0c;深拷贝&#xff08;Deep Copy&#xff09; 和 浅拷贝&#xff08;Shallow Copy&#xff09; 是两种完全不同的对象拷贝策略&#xff0c;主要区别在于对指针和动态分配资源的处理方式。正确理解二者的区别是避免内存泄漏、悬空指针和程序崩溃的关键。 一、核…

STM32-智能小车项目

项目框图 ST-link接线 实物图&#xff1a; 正面&#xff1a; 反面&#xff1a; 相关内容 使用L9110S电机模块 电机驱动模块L9110S详解 | 良许嵌入式 一、让小车动起来 新建文件夹智能小车项目 在里面复制19-串口打印功能 重命名为01-让小车动起来 新建文件夹motor&…

计算机毕业设计SpringBoot+Vue.js古典舞在线交流平台(源码+文档+PPT+讲解)

温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 作者简介&#xff1a;Java领…

Pretraining Language Models with Text-Attributed Heterogeneous Graphs

Pretraining Language Models with Text-Attributed Heterogeneous Graphs EMNLP 推荐指数&#xff1a;#paper/⭐⭐#​ 贡献&#xff1a; 我们研究了在更复杂的数据结构上预训练LM的问题&#xff0c;即&#xff0c;TAHG。与大多数只能从每个节点的文本描述中学习的PLM不同&…

力扣2382. 删除操作后的最大子段和

力扣2382. 删除操作后的最大子段和 题目 题目解析及思路 题目要求找到每次删除一个元素的最大字段和 因为删除不好做&#xff0c;可以转删除为添加&#xff0c;用并查集维护当前子段和 两部分合并(两个并查集)&#xff0c;三部分求和(两个并查集和一个元素) 代码 class S…

PythonWeb开发框架—Django之DRF框架的使用详解

1.安装依赖包 pip install djangorestframework 2.配置应用 在settings.py中的INSTALLED_APPS中添加rest_framework应用 3.创建序列化器 序列化器是用来操作models的 第一步&#xff1a;定义models ##models.pyfrom django.db import models# Create your models here.cl…