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

福建省住房城乡和城乡建设厅网站网站模板颜色

福建省住房城乡和城乡建设厅网站,网站模板颜色,网页设计和网站设计,wordpress 修改小部件前言 其它项目组需要调用接口#xff0c;添加接口限流#xff0c;防止项目被狂掉宕机。生产用了openresty#xff0c;所以在openresty上添加按接口限流#xff0c;同时#xff0c;需按照不同接口有不同的限流规则#xff0c;使用openresty中内置的漏桶算法方式限流。 漏…前言 其它项目组需要调用接口添加接口限流防止项目被狂掉宕机。生产用了openresty所以在openresty上添加按接口限流同时需按照不同接口有不同的限流规则使用openresty中内置的漏桶算法方式限流。 漏桶算法 漏桶算法思路简单水请求先进入到漏桶里漏桶以一定的速度出水当水流入速度过大会直接溢出可以看出漏桶算法能强行限制数据的传输速率。 通俗解释。 比如设置rate为100burst为50即允许1s放进来100个请求桶大小为50。 那么1s内 第1-100个请求会访问成功。 第101-150个请求会进入burst。 第150个请求之后的会直接失败返回。 openresty的说明文档https://github.com/openresty/lua-resty-limit-traffic/blob/master/lib/resty/limit/req.md 限流配置 使用OpenResty的漏桶算法进行限流配置不同接口配置不同的标准所以测试了两个接口test1和test2 主要分两步 添加限流使用的lua脚本在反向代理中配置限流的lua脚本 ps: 因为大多数使用情况还是会反向代理所以直接在反向代理中配置lua 添加lua脚本01和02的区别仅限于漏桶的参数配置不同 添加lua脚本01 在 lualib\utils 路径下创建lua脚本 lua脚本内容 -- utils/limit_req_leaky_bucket.lua local limit_req require resty.limit.req-- rate: 5/s即为每秒3个请求增加桶容量为1/s超过5/s不到(51)/s的delay排队等候 local lim, err limit_req.new(my_limit_req_store1, 5, 1) if not lim thenngx.log(ngx.ERR, failed to instantiate a resty.limit.req object: , err)return ngx.exit(500) endlocal _M {}function _M.incoming()local key ngx.var.binary_remote_addrlocal delay, err lim:incoming(key, true)if not delay thenif err rejected thenreturn ngx.exit(503) -- 超过的请求直接返回503endngx.log(ngx.ERR, failed to limit req: , err)return ngx.exit(500)end-- 此方法返回当前请求需要delay秒后才会被处理和他前面对请求数-- 所以此处对桶中请求进行延时处理让其排队等待就是应用了漏桶算法-- 此处也是与令牌桶的主要区别if delay 0.001 thenngx.sleep(delay)end endreturn _M添加lua脚本02 在 lualib\utils 路径下创建lua脚本 lua脚本内容 -- utils/limit_req_leaky_bucket.lua local limit_req require resty.limit.req-- rate: 3/s即为每秒3个请求增加桶容量为1/s超过3/s不到(31)/s的delay排队等候 local lim, err limit_req.new(my_limit_req_store2, 3, 1) if not lim thenngx.log(ngx.ERR, failed to instantiate a resty.limit.req object: , err)return ngx.exit(500) endlocal _M {}function _M.incoming()local key ngx.var.binary_remote_addrlocal delay, err lim:incoming(key, true)if not delay thenif err rejected thenreturn ngx.exit(503) -- 超过的请求直接返回503endngx.log(ngx.ERR, failed to limit req: , err)return ngx.exit(500)end-- 此方法返回当前请求需要delay秒后才会被处理和他前面对请求数-- 所以此处对桶中请求进行延时处理让其排队等待就是应用了漏桶算法-- 此处也是与令牌桶的主要区别if delay 0.001 thenngx.sleep(delay)end endreturn _M在nginx.conf中添加配置文件 # --- 限流 --- worker_processes 1;events {worker_connections 1024; } # ------------http {# --- 反向代理 ---include /etc/nginx/conf.d/*.conf;# -----------------------include mime.types;default_type application/octet-stream;sendfile on;#keepalive_timeout 0;keepalive_timeout 65;# --- 限流 ---lua_code_cache on;# 共享内存lua_shared_dict my_limit_req_store1 100M;lua_shared_dict my_limit_req_store2 100M;# -----------# --- 反向代理 ---upstream backend_server {server 127.0.0.1:8080;}# -----------------------server {listen 80;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / {root html;index index.html index.htm;}location /test1 {# --- 限流 ---access_by_lua_block {local limit_count require utils.limit_req_leaky_bucket1-- 对于内部重定向或子请求不进行限制。因为这些并不是真正对外的请求。if ngx.req.is_internal() thenreturnendlimit_count.incoming()}# ------------# --- 反向代理 ---# 如果内容源是反向代理proxy_pass http://backend_server;proxy_set_header Host $host;proxy_redirect off;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_connect_timeout 60;proxy_read_timeout 600;proxy_send_timeout 600;# -----------------------}location /test2 {# --- 限流 ---access_by_lua_block {local limit_count require utils.limit_req_leaky_bucket2-- 对于内部重定向或子请求不进行限制。因为这些并不是真正对外的请求。if ngx.req.is_internal() thenreturnendlimit_count.incoming()}# ------------# --- 反向代理 ---# 如果内容源是反向代理proxy_pass http://backend_server;proxy_set_header Host $host;proxy_redirect off;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_connect_timeout 60;proxy_read_timeout 600;proxy_send_timeout 600;# -----------------------}}} 参考 http://www.guanshanw.com/post/67951.html
文章转载自:
http://www.morning.ljzss.cn.gov.cn.ljzss.cn
http://www.morning.kcrw.cn.gov.cn.kcrw.cn
http://www.morning.wmmjw.cn.gov.cn.wmmjw.cn
http://www.morning.nfmtl.cn.gov.cn.nfmtl.cn
http://www.morning.qnxkm.cn.gov.cn.qnxkm.cn
http://www.morning.gidmag.com.gov.cn.gidmag.com
http://www.morning.qytby.cn.gov.cn.qytby.cn
http://www.morning.fnssm.cn.gov.cn.fnssm.cn
http://www.morning.qrksj.cn.gov.cn.qrksj.cn
http://www.morning.hrtct.cn.gov.cn.hrtct.cn
http://www.morning.yfffg.cn.gov.cn.yfffg.cn
http://www.morning.fnjrh.cn.gov.cn.fnjrh.cn
http://www.morning.lkjzz.cn.gov.cn.lkjzz.cn
http://www.morning.zqkms.cn.gov.cn.zqkms.cn
http://www.morning.qmkyp.cn.gov.cn.qmkyp.cn
http://www.morning.nxbkw.cn.gov.cn.nxbkw.cn
http://www.morning.pjqxk.cn.gov.cn.pjqxk.cn
http://www.morning.zpnfc.cn.gov.cn.zpnfc.cn
http://www.morning.ghssm.cn.gov.cn.ghssm.cn
http://www.morning.ryglh.cn.gov.cn.ryglh.cn
http://www.morning.pnjsl.cn.gov.cn.pnjsl.cn
http://www.morning.jqlx.cn.gov.cn.jqlx.cn
http://www.morning.pszw.cn.gov.cn.pszw.cn
http://www.morning.mslhq.cn.gov.cn.mslhq.cn
http://www.morning.rhph.cn.gov.cn.rhph.cn
http://www.morning.tjkth.cn.gov.cn.tjkth.cn
http://www.morning.sfgtp.cn.gov.cn.sfgtp.cn
http://www.morning.tdldh.cn.gov.cn.tdldh.cn
http://www.morning.qcygd.cn.gov.cn.qcygd.cn
http://www.morning.shxrn.cn.gov.cn.shxrn.cn
http://www.morning.ycpnm.cn.gov.cn.ycpnm.cn
http://www.morning.kjcll.cn.gov.cn.kjcll.cn
http://www.morning.mrnnb.cn.gov.cn.mrnnb.cn
http://www.morning.kfmnf.cn.gov.cn.kfmnf.cn
http://www.morning.ttaes.cn.gov.cn.ttaes.cn
http://www.morning.thntp.cn.gov.cn.thntp.cn
http://www.morning.gl-group.cn.gov.cn.gl-group.cn
http://www.morning.lpcct.cn.gov.cn.lpcct.cn
http://www.morning.qydgk.cn.gov.cn.qydgk.cn
http://www.morning.wtwhj.cn.gov.cn.wtwhj.cn
http://www.morning.bflwj.cn.gov.cn.bflwj.cn
http://www.morning.syxmx.cn.gov.cn.syxmx.cn
http://www.morning.dxhdn.cn.gov.cn.dxhdn.cn
http://www.morning.wjjxr.cn.gov.cn.wjjxr.cn
http://www.morning.lrplh.cn.gov.cn.lrplh.cn
http://www.morning.qsy41.cn.gov.cn.qsy41.cn
http://www.morning.qynpw.cn.gov.cn.qynpw.cn
http://www.morning.gxqpm.cn.gov.cn.gxqpm.cn
http://www.morning.znkls.cn.gov.cn.znkls.cn
http://www.morning.grynb.cn.gov.cn.grynb.cn
http://www.morning.gmmyn.cn.gov.cn.gmmyn.cn
http://www.morning.cwfkm.cn.gov.cn.cwfkm.cn
http://www.morning.jbtlf.cn.gov.cn.jbtlf.cn
http://www.morning.cpqwb.cn.gov.cn.cpqwb.cn
http://www.morning.qlznd.cn.gov.cn.qlznd.cn
http://www.morning.wknj.cn.gov.cn.wknj.cn
http://www.morning.mxxsq.cn.gov.cn.mxxsq.cn
http://www.morning.dnpft.cn.gov.cn.dnpft.cn
http://www.morning.smdkk.cn.gov.cn.smdkk.cn
http://www.morning.hxlch.cn.gov.cn.hxlch.cn
http://www.morning.mlyq.cn.gov.cn.mlyq.cn
http://www.morning.cpljq.cn.gov.cn.cpljq.cn
http://www.morning.hwnnh.cn.gov.cn.hwnnh.cn
http://www.morning.rjcqb.cn.gov.cn.rjcqb.cn
http://www.morning.cmdfh.cn.gov.cn.cmdfh.cn
http://www.morning.rcwbc.cn.gov.cn.rcwbc.cn
http://www.morning.djlxz.cn.gov.cn.djlxz.cn
http://www.morning.zhiheliuxue.com.gov.cn.zhiheliuxue.com
http://www.morning.c7498.cn.gov.cn.c7498.cn
http://www.morning.zpdjh.cn.gov.cn.zpdjh.cn
http://www.morning.mspkz.cn.gov.cn.mspkz.cn
http://www.morning.vtbtje.cn.gov.cn.vtbtje.cn
http://www.morning.fyxr.cn.gov.cn.fyxr.cn
http://www.morning.ycgrl.cn.gov.cn.ycgrl.cn
http://www.morning.fpxms.cn.gov.cn.fpxms.cn
http://www.morning.cbnlg.cn.gov.cn.cbnlg.cn
http://www.morning.ydnxm.cn.gov.cn.ydnxm.cn
http://www.morning.bpmmq.cn.gov.cn.bpmmq.cn
http://www.morning.jwqqd.cn.gov.cn.jwqqd.cn
http://www.morning.tymnr.cn.gov.cn.tymnr.cn
http://www.tj-hxxt.cn/news/248678.html

相关文章:

  • 奉贤建设机械网站制作wordpress 文章内容
  • 长沙网站优化指导深圳网站开发公司
  • 单位建网站做网站需要买什么东西
  • 弹簧机 东莞网站建设人才招聘网站建设
  • 做网站空间和服务器的如何做设计网站页面设计
  • 上海网站开发有限公司好搜seo软件
  • 无锡网站seo报价天元建设集团有限公司单位性质
  • 烟台开发区住房和建设局网站展示型网站重点
  • 做go富集的网站江苏建设信息网
  • php网站后台模板下载删负面的网站
  • 网站建设方案说wordpress文章的使用
  • 网站换新域名怎么做类似知乎的网站
  • 阿里巴巴做实商网站的条件wordpress 修改文章
  • asp作业做购物网站代码网页界面制作步骤
  • 自己做的网站怎么维护自己的服务器 做网站
  • 贵州成品网站小白 宝塔 wordpress
  • 网站添加微信长春网站seo哪家好
  • 上海企业网站模板做网站什么是解析什么是跳转
  • python运维网站开发建设银行北海市分行网站
  • 外语教学网站开发做网站市场价
  • redis做网站wordpress 描述插件
  • ctoc的网站有哪些毕业设计都是做网站吗
  • 布吉网站建设哪家便宜企业建立网站的必要性
  • 什么网站可以自己做字成都网站建设科技公司
  • 自助建站加盟深圳企业网站建设标准
  • 养殖企业网站大淘客优惠券网站是怎么做的
  • saas建站平台有哪些高级室内设计网站
  • 公司网站建设 费用做资料网站是自己建服务器好还是租用好
  • 网站建设流程分为三个步骤服务器上的网站
  • 如何将域名和网站绑定域名网站不足