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

iis搭建网站整合营销是什么

iis搭建网站,整合营销是什么,90设计怎么免费下载,做网站必须要有数据库文章目录 一、环境需求二、健康检查配置主动原理及说明配置方法实际用途 被动原理及说明配置方法实际用途 三、效果测试nginx 配置后端程序(Python)程序启动测试 一、环境需求 服务数量用途nginx (建议使用 1.20 以上版本,此文档使用 1.25)1…

文章目录

  • 一、环境需求
  • 二、健康检查配置
    • 主动
      • 原理及说明
      • 配置方法
      • 实际用途
    • 被动
      • 原理及说明
      • 配置方法
      • 实际用途
  • 三、效果测试
    • nginx 配置
    • 后端程序(Python)
    • 程序启动测试

一、环境需求

服务数量用途
nginx (建议使用 1.20 以上版本,此文档使用 1.25)1配置健康检测,验证配置是否生效
python (建议使用 3.6 以上版本,此文档使用 3.9)进程*3模拟后端服务

二、健康检查配置

主动

原理及说明

主动健康检测是指 Nginx 主动向后端服务器发送特定的请求,并根据服务器的响应来判断其健康状态。Nginx 会按照预设的时间间隔,向后端服务器发送健康检查请求(通常是 HTTP 请求),然后根据响应的状态码、响应时间等信息来决定后端服务器是否可用使用模块 nginx_upstream_check_module,需要部署编译建议配合监控服务使用,因为就算可以自动切换流量,也无法自动修复故障节点,需要手动恢复

配置方法

# 配置指令:在 Nginx 1.16.0 及以后的版本中,可以使用 health_check 指令来配置主动健康检查。例如:
http {upstream backend {server backend1.example.com:8080;server backend2.example.com:8080;check interval=5s rise=2 fall=3 timeout=1000 type=http;check_http_send "HEAD /health HTTP/1.0\r\n\r\n";check_http_expect_alive http_2xx http_3xx;}server {location /status {check_status;access_log off;}}
}# 配置说明
interval=5s:表示每隔 5 秒对后端服务器进行一次健康检查。
rise=2:如果后端服务器连续 2 次健康检查成功,则认为该服务器恢复可用状态。
fall=3:如果后端服务器连续 3 次健康检查失败,则认为该服务器不可用。
timeout=1000:健康检查请求的超时时间为 1000 毫秒(即 1 秒),如果在这个时间内没有收到响应,则认为检查失败。
type=http:指定健康检查的类型为 HTTP。
check_http_send "HEAD /health HTTP/1.0\r\n\r\n";:Nginx 在进行健康检查时,会向后端服务器发送一个 HTTP HEAD 请求,请求的路径为 /health。使用 HEAD 请求可以只获取响应头,而不获取响应体,从而减少网络开销,如有特殊需求也可以使用GET
check_http_expect_alive http_2xx http_3xx;:表示如果后端服务器返回的状态码是 2xx 或 3xx,则认为健康检查成功。
location /status : 这个资源路径是check模块自带的健康状态页面,例如

实际用途

  • 及时发现故障:可以在后端服务器出现问题的早期就检测到,避免将请求转发到不可用的服务器上,提高服务的可用性。
  • 动态调整负载均衡:当检测到某台后端服务器不可用时,Nginx 会自动将其从可用服务器列表中移除,将请求转发到其他健康的服务器;当服务器恢复正常后,再将其重新加入可用列表。
  • 监控服务器性能:通过分析健康检查的响应时间等指标,可以监控后端服务器的性能变化,及时发现潜在的性能问题。

被动

原理及说明

被动健康检测是指 Nginx 在处理客户端请求时,根据后端服务器的响应结果来判断其健康状态。当请求出现错误(如返回 500、502、503、504 错误或者超时等)时,Nginx 会认为该后端服务器可能出现了问题,并根据配置进行相应的处理,如将请求转发到其他后端服务器一般来说 nginx 都会自带此功能无需另外编译模块同样建议配合监控服务使用

配置方法

http {upstream backend {server backend1.example.com max_fails=3 fail_timeout=10s;server backend2.example.com max_fails=3 fail_timeout=10s;server backend2.example.com backup}server {proxy_next_upstream_tries 2;proxy_next_upstream_timeout 5s;}
}# 配置说明
max_fails=3:在 fail_timeout 时间内,该后端服务器允许的连续失败次数,达到 3 次则会被标记为不可用。
fail_timeout=10s:一是检测失败的时间窗口为 10 秒;二是服务器被标记为不可用的时长为 10 秒,期间 Nginx 不会向其转发请求。
backup:backup 表示该服务器作为备用服务器,只有当所有主服务器(未标记为 backup 的服务器)都不可用时,才会参与负载均衡处理请求。
proxy_next_upstream_tries 2:当请求转发到后端服务器出现失败时,Nginx 最多尝试将请求转发到下一个可用的后端服务器 2 次(加上初始的一次请求,总共最多尝试 3 次)。
proxy_next_upstream_timeout 5s:每次尝试将请求转发到下一个后端服务器的超时时间为 5 秒,若在 5 秒内未得到响应,则认为此次转发失败。

实际用途

  • 故障转移:当后端服务器出现临时故障时,Nginx 可以快速将请求转发到其他可用的服务器,保证服务的连续性。
  • 减轻故障服务器负担:当某台后端服务器出现问题时,减少对其的请求,避免其进一步过载,有助于服务器恢复正常。
  • 提高服务稳定性:通过自动处理后端服务器的错误响应,减少因服务器故障对客户端造成的影响,提高整个服务的稳定性。

三、效果测试

nginx 配置

upstream test {server 10.10.11.134:20001 max_fails=3 fail_timeout=30s;server 10.10.11.134:20002 max_fails=3 fail_timeout=30s;server 10.10.11.134:20003 backup;
}upstream test1 {server 10.10.11.134:20001;server 10.10.11.134:20002;server 10.10.11.134:20003;check interval=5000 rise=2 fall=5 timeout=1000 type=http;check_http_send "GET / HTTP/1.0\r\n\r\n";check_http_expect_alive http_2xx http_3xx;
}server{listen 80;charset utf-8;server_name 10.10.11.134;client_max_body_size 500m;proxy_read_timeout  3600000;proxy_next_upstream_tries 2;proxy_next_upstream_timeout 5s;location /test/ {proxy_pass http://test/;}location /test1/ {proxy_pass http://test1/;}location /status {# check_status是第三方插件自带的功能,用于展示服务列表的健康检查结果界面check_status;access_log   off;}}

后端程序(Python)

  • 修改端口以及输出的字符串即可
import http.server
import socketserver# 配置端口
PORT = 20001  # 可以根据需要修改此端口号
# 指定的字符串
RESPONSE_STRING = "Python test 1"class MyHandler(http.server.SimpleHTTPRequestHandler):def do_GET(self):# 设置响应状态码为 200self.send_response(200)# 设置响应头,指定内容类型为文本self.send_header('Content-type', 'text/plain')self.end_headers()# 将指定的字符串编码为字节并发送到客户端self.wfile.write(RESPONSE_STRING.encode())def run(server_class=socketserver.TCPServer, handler_class=MyHandler, port=PORT):server_address = ('', port)httpd = server_class(server_address, handler_class)print(f"Starting server on port {port}")try:# 启动服务器并开始监听请求httpd.serve_forever()except KeyboardInterrupt:passhttpd.server_close()print("Stopping server...")if __name__ == "__main__":run()

程序启动测试

  • 三个 python 程序依次打开三个终端窗口进行测试

# 访问主动检测的资源路径
[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 3[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 3[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 3[root@minio3 nginx]## 访问被动检测的资源路径,这里只负载两台是因为有一个配置的是backup
[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 2[root@minio3 nginx]#
  • 关闭 python1 测试
# 访问主动检测的资源路径
[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 3[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 3[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 3[root@minio3 nginx]## 访问被动检测的资源路径
[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 2[root@minio3 nginx]#
  • 关闭 python2 测试
# 访问主动检测的资源路径
[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 3[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 3[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 3[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 3[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 3[root@minio3 nginx]# # 访问被动检测的资源路径,因为是被动检测,需要访问时才知道节点有没有故障,所以可能会出现502的报错
[root@minio3 nginx]# curl http://10.10.11.134/test/
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>
[root@minio3 nginx]# curl http://10.10.11.134/test/
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>
[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 3[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 3[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 3[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 3[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 3[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 3[root@minio3 nginx]#
  • 关闭 python3,打开 python1 测试
# 访问主动检测的资源路径,主动健康检测是根据配置来的,所以可能会出现一些延迟才可以正常访问
[root@minio3 nginx]# curl http://10.10.11.134/test1/
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>
[root@minio3 nginx]# curl http://10.10.11.134/test1/
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>
[root@minio3 nginx]# curl http://10.10.11.134/test1/
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>
[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]## 被动检测
[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 1[root@minio3 nginx]#
  • 打开 python2 测试
# 主动检测
[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test1/
Python test 1[root@minio3 nginx]## 被动检测
[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 1[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 2[root@minio3 nginx]# curl http://10.10.11.134/test/
Python test 1[root@minio3 nginx]#
``
http://www.dtcms.com/wzjs/12177.html

相关文章:

  • 在html中做网站 视频怎么做网站推广
  • 做网站 对方传销今日新闻10条简短
  • 商标如何自己注册搜索引擎优化的方式有哪些
  • 网站内部资源推广怎么做推广关键词优化
  • 海珠b2b网站建设公司seo教学网站
  • 做系统网站建设成都计算机培训机构排名前十
  • 遵义做网站直播:韩国vs加纳直播
  • 网站开发设计过程互联网电商平台有哪些
  • 集团网站网页模板重庆网站建设技术外包
  • 厦门市建设保障性住房局网站生猪价格今日猪价
  • 网站开发前端技术趋势百度关键词规划师
  • 工业设计网站知乎常州网站推广公司
  • 用网站做数据库吗微信营销策略有哪些
  • 网站建设比较好的律所企业培训课程价格
  • 合肥制作网站哪家好优化大师免费下载安装
  • 深圳宝安区住房和建设局网站推广活动策划方案范文
  • 每个惠州seo招聘
  • 三级a一级a做爰视频网站新品推广活动方案
  • 邯郸单位网站建设衡阳网站优化公司
  • 南宁网络推广建站百度识图在线使用一下
  • 如何做网站的教程视频广州网络推广培训
  • 制作网站的工作流程哪些网站是营销型网站
  • ubuntu写wordpress湖北seo整站优化
  • 做竞猜网站犯法吗苏州网站优化公司
  • 网站设计论坛百度seo技术优化
  • 网站平台策划方案太原全网推广
  • 深圳高端做网站公司站长之家app
  • 四川成都最新疫情分布图系统优化大师官方下载
  • 贸易网站有哪些磁力bt种子搜索
  • 郑州建站怎么操作怎么去营销自己的产品