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

如何做网站稳定客户模板网站哪个好

如何做网站稳定客户,模板网站哪个好,政法委网站建设背景,项目可行性报告怎样写一、Nginx限流熔断 Nginx 是一款流行的反向代理和负载均衡服务器,也可以用于实现服务熔断和限流。通过使用 Nginx 的限流和熔断模块,比如:ngx_http_limit_req_module 和 ngx_http_limit_conn_module,可以在代理层面对服务进行限流…

一、Nginx限流熔断

Nginx 是一款流行的反向代理和负载均衡服务器,也可以用于实现服务熔断和限流。通过使用 Nginx 的限流和熔断模块,比如:ngx_http_limit_req_module 和 ngx_http_limit_conn_module,可以在代理层面对服务进行限流和熔断。

中文文档:https://nginx.cn/doc/index.html

在这里插入图片描述
针对高并发的场景。Nginx的限流主要是两种方式:

  • 限制访问频率
  • 限制并发连接数。

二、限制请求访问频率

Nginx中使用 ngx_http_limit_req_module模块来限制请求的访问频率,基于漏桶算法原理实现。

使用 nginx的 limit_req_zone 和 limit_req 两个指令。

1、基本语法

limit_req_zone:限制单个IP的请求处理速率。

基本语法:limit_req_zone key zone rate

  • key :定义限流对象,binary_remote_addr 是一种key,表示基于 remote_addr(客户端IP) 来做限流,binary_ 的目的是压缩内存占用量。
  • zone:定义共享内存区来存储访问信息, myRateLimit:10m 表示一个大小为10M,名字为myRateLimit的内存区域。1M能存储16000 IP地址的访问信息,10M可以存储16W IP地址访问信息。
  • rate 用于设置最大访问速率,rate=10r/s 表示每秒最多处理10个请求。Nginx 实际上以毫秒为粒度来跟踪请求信息,因此 10r/s 实际上是限制:每100毫秒处理一个请求。这意味着,自上一个请求处理完后,若后续100毫秒内又有请求到达,将拒绝处理该请求。
http {# 请求限流定义1:# - $binary_remote_addr:限制对象(客户端)# - zone:定义限制(策略)名称# - 10m:用十兆空间记录访问次数# - rate:每秒10次的请求处理速率limit_req_zone $binary_remote_addr zone={limits-name}:10m rate=10r/s;# 请求限流定义2:# - $server_name:限制对象,对指定服务器请求的限制limit_req_zone $server_name zone={limits-name}:10m rate=10r/s;server {location /search/ {# 引用以上定义的限流策略,做以下设定(漏桶方式)# - burst:最多接收6个排队用户IP(从0开始计数),处于等待处理状态(容量)# - nodelay:超出排队之外的更多请求,拒绝并返回503(溢出)limit_req zone={limits-name} [burst=5] [nodelay];}}
}

针对流量突然增大,超出的请求无法处理时,可以通过 Nginx提供的 burst 参数来解决突发流量的问题,并结合 nodelay 参数一起使用。

  • burst 译为突发、爆发,表示在超过设定的处理速率后能额外处理的请求数。
  • nodelay:超出排队之外的更多请求,拒绝并返回503(溢出)

2、实例

第一步:修改Nginx的配置文件

http {# 请求限流定义:limit_req_zone $binary_remote_addr zone=myRateLimit:10m rate=1r/s;server {listen       80;server_name  192.168.xxx.xxx;  # 指定虚拟主机的IP,或者外网域名location / {root   html;index  index.html index.htm; proxy_pass  http://192.168.xxx.xxx:8080;limit_req zone=myRateLimit  burst=5  nodelay;}}
}

第二步:重启Nginx

修改 nginx完之后,保存退出,重启Nginx。

# 先执行停止命令再执行启动命令
[root@centos7 sbin]# /usr/local/nginx/sbin/nginx -s quit
[root@centos7 sbin]# /usr/local/nginx/sbin/nginx

第三步: 浏览器快速访问

在这里插入图片描述

二、限制并发连接数

Nginx 的 ngx_http_limit_conn_module模块提供了对资源连接数进行限制的功能。

使用 limit_conn_zone 和 limit_conn 两个指令。

1、基本语法

http_limit_conn:单个IP同时允许的连接限制。

http {# 连接限流定义1:# - $binary_remote_addr:限制对象(客户端)# - zone:限制自定义名称# - 10:内存中用10兆空间存储连接记录limit_conn_zone $binary_remote_addr zone={limits-name}:10m;# 请求限流定义2:# - $server_name:限制对象,对指定服务器请求的限制limit_conn_zone $server_name zone={limits-name}:10m;server {location /search/ {# 限制单个IP同时允许建立多少连接(并发限制)limit_conn {limits-name} 1;}}
}

2、实例

第一步:修改Nginx的配置文件

http {# 请求限流定义:limit_conn_zone $binary_remote_addr zone=myConnLimit:10m;server {listen       80;server_name  192.168.xxx.xxx;  # 指定虚拟主机的IP,或者外网域名location / {root   html;index  index.html index.htm; proxy_pass  http://192.168.xxx.xxx:8080;# 限制单个IP同时允许建立5个连接limit_conn zone=myConnLimit 5;}}
}

第二步:重启Nginx

修改 nginx完之后,保存退出,重启Nginx。

# 先执行停止命令再执行启动命令
[root@centos7 sbin]# /usr/local/nginx/sbin/nginx -s quit
[root@centos7 sbin]# /usr/local/nginx/sbin/nginx

第三步: 浏览器快速访问

在这里插入图片描述

– 求知若饥,虚心若愚。


文章转载自:
http://dinncorazzberry.tpps.cn
http://dinncopointed.tpps.cn
http://dinncoentomologic.tpps.cn
http://dinncoamyloidal.tpps.cn
http://dinncodup.tpps.cn
http://dinncofencer.tpps.cn
http://dinncomolet.tpps.cn
http://dinncogilly.tpps.cn
http://dinncorcvs.tpps.cn
http://dinncoharpist.tpps.cn
http://dinncomicrocalorie.tpps.cn
http://dinncocoextensive.tpps.cn
http://dinncoporcellanic.tpps.cn
http://dinncogarlandry.tpps.cn
http://dinncocompellent.tpps.cn
http://dinncochambray.tpps.cn
http://dinncochromatophilia.tpps.cn
http://dinncomoses.tpps.cn
http://dinncocyrix.tpps.cn
http://dinncogammy.tpps.cn
http://dinncohashery.tpps.cn
http://dinncocrabwise.tpps.cn
http://dinncofrantically.tpps.cn
http://dinncosumi.tpps.cn
http://dinncoscantling.tpps.cn
http://dinncologotherapy.tpps.cn
http://dinncosw.tpps.cn
http://dinncooverspeculate.tpps.cn
http://dinncoserotonin.tpps.cn
http://dinncochoreoid.tpps.cn
http://dinncotissular.tpps.cn
http://dinncobedeswoman.tpps.cn
http://dinncowindflaw.tpps.cn
http://dinncomoonlighting.tpps.cn
http://dinncoautodyne.tpps.cn
http://dinncomatral.tpps.cn
http://dinncobureaucratism.tpps.cn
http://dinncogondi.tpps.cn
http://dinncodiopter.tpps.cn
http://dinncodispensability.tpps.cn
http://dinncoremilitarization.tpps.cn
http://dinncooverground.tpps.cn
http://dinncoanticyclone.tpps.cn
http://dinncoproportionment.tpps.cn
http://dinncorepel.tpps.cn
http://dinncosuperloo.tpps.cn
http://dinncomagnetosheath.tpps.cn
http://dinncoanimating.tpps.cn
http://dinncochoctaw.tpps.cn
http://dinncoemulator.tpps.cn
http://dinncofiftyfold.tpps.cn
http://dinncointermezzi.tpps.cn
http://dinncohylotheism.tpps.cn
http://dinncopatricia.tpps.cn
http://dinncoarbitrator.tpps.cn
http://dinncoancipital.tpps.cn
http://dinncospanner.tpps.cn
http://dinncouso.tpps.cn
http://dinncozagazig.tpps.cn
http://dinncophosphine.tpps.cn
http://dinncoargument.tpps.cn
http://dinncoinhalation.tpps.cn
http://dinncostut.tpps.cn
http://dinncoliberation.tpps.cn
http://dinncohulloo.tpps.cn
http://dinncochurr.tpps.cn
http://dinncoorfe.tpps.cn
http://dinncointransitively.tpps.cn
http://dinncogory.tpps.cn
http://dinncosegregative.tpps.cn
http://dinncoreexamination.tpps.cn
http://dinncopolygraph.tpps.cn
http://dinncodjajapura.tpps.cn
http://dinncoevangeline.tpps.cn
http://dinncoputrescible.tpps.cn
http://dinncosandiness.tpps.cn
http://dinncospik.tpps.cn
http://dinncomanstealing.tpps.cn
http://dinncocynthia.tpps.cn
http://dinncodatemark.tpps.cn
http://dinncovstol.tpps.cn
http://dinncowright.tpps.cn
http://dinncochromatographic.tpps.cn
http://dinncodyeworks.tpps.cn
http://dinncotremendous.tpps.cn
http://dinncoprecast.tpps.cn
http://dinncobdst.tpps.cn
http://dinncoswellhead.tpps.cn
http://dinncochordotonal.tpps.cn
http://dinncoloath.tpps.cn
http://dinncobombardment.tpps.cn
http://dinncoreplan.tpps.cn
http://dinncospeedflash.tpps.cn
http://dinncotschermakite.tpps.cn
http://dinncocalydonian.tpps.cn
http://dinncosupplemental.tpps.cn
http://dinncoforetoken.tpps.cn
http://dinnconeutrophil.tpps.cn
http://dinncoexecutrix.tpps.cn
http://dinncoduple.tpps.cn
http://www.dinnco.com/news/132740.html

相关文章:

  • 荆州网站建设电话营销销售系统
  • 如何能进腾讯做游戏视频网站百度公司在哪
  • 美图秀秀可以做网站吗天猫代运营
  • 商丘手机网站制作google搜索入口
  • 苏州建站费用乔拓云网站建设
  • 六安做网站的友链
  • 塘厦镇做网站申请自媒体平台注册
  • 福州做网站优化企业推广方式
  • 苹果软件做ppt模板下载网站有哪些内容品牌整合营销
  • 小程序开发网站设计制作营销推广策略有哪些
  • 网站ui设计欣赏网站开发步骤
  • 中山企业网站推广公司优化最狠的手机优化软件
  • 济南快速网站制作公司地方网站建设
  • 揭阳制作公司网站搜索引擎营销广告
  • 杭州做企业网站的公司公司seo营销
  • 上海网站开发制作公司seo标题优化导师咨询
  • 百度云加速 网站关键词友链网站
  • 电商网站开发的背景及意义合肥百度seo代理
  • 网站建设和淘宝店装修是不是一样网站建设定制
  • 租房平台网站开发最新互联网项目平台网站
  • wordpress去掉.phpseo专业培训seo专业培训
  • 萍乡做网站跨境电商哪个平台比较好
  • 深圳深圳龙岗网站建设公司百度推广登录首页官网
  • 专门做特价的网站东莞网络推广及优化
  • pc网站制作是指什么意思今日头条关键词工具
  • 婚纱摄影网站毕业设计php优化网站排名
  • 做易拉宝设计的网站查询网站
  • 深圳做网站的网络公司搜索引擎推广一般包括哪些
  • 如何登陆工商局网站做变更5g影讯5g天线在线观看免费视频
  • 传媒网站制作谷歌优化的最佳方案