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

阿里备案成功后怎么做网站百度一下百度搜索

阿里备案成功后怎么做网站,百度一下百度搜索,网络营销与网站建设,株洲目前疫情有多严重?目录 1. 引言2. 开启sysguard模块2.1 编译2.2 配置3. 源码分析3.1 配置参数分析3.2 模块的初始化3.3 ngx_http_sysguard_handler函数3.4 各项负载指标的获取3.4.1 load系统负载的获取3.4.2 cpu使用率的获取3.4.3 内存使用情况的获取3.3.5 请求平均响应时间的获取1. 引言 Tengin…

目录

  • 1. 引言
  • 2. 开启sysguard模块
    • 2.1 编译
  • 2.2 配置
  • 3. 源码分析
    • 3.1 配置参数分析
    • 3.2 模块的初始化
    • 3.3 ngx_http_sysguard_handler函数
  • 3.4 各项负载指标的获取
      • 3.4.1 load系统负载的获取
      • 3.4.2 cpu使用率的获取
      • 3.4.3 内存使用情况的获取
      • 3.3.5 请求平均响应时间的获取

1. 引言

  Tengine 是一款高性能的 Web 服务器,其 Sysguard 模块作为其核心功能之一,为用户提供了强大的系统监控和管理能力。通过 Sysguard 模块,用户可以实时监测服务器的运行状态、性能指标和资源利用情况,对异常压力实施熔断处理,从而有效优化系统运行和提升稳定性。本文将深入探讨 Tengine 的 Sysguard 模块,介绍其功能特点、部署配置,以及通过源码分析来深入理解其实现原理。

2. 开启sysguard模块

2.1 编译

  需要开启sysguard模块,因为tengine默认是不加载这个模块的,因此在编译的时候要将这个模块编译进去,如下:


./configure --add-module=modules/ngx_http_sysguard_module

2.2 配置

  直接拿官网文档的例子来举例:


server {sysguard on;                   # 开启sysguard模块sysguard_mode or;              # 多个负载条件匹配模式采用or还是and方式# 格式:负载类型   负载阈值     超过规定阈值后执行的跳转动作目标路径# 其中部分指令中定义的period表示性能指标采样的周期sysguard_load load=10.5 action=/loadlimit;sysguard_cpu usage=20 period=3s action=/cpulimit;sysguard_mem swapratio=20% action=/swaplimit;sysguard_mem free=100M action=/freelimit;sysguard_rt rt=0.01 period=5s action=/rtlimit;# 以下几个location定义的是熔断以后,nginx将请求跳转到这里来执行响应处理location /loadlimit {return 503;}location /swaplimit {return 503;}location /freelimit {return 503;}location /rtlimit {return 503;}location /cpulimit {return 503;}
}

  针对上面的范例总结一下,我们可以定义一个或者若干个负载条件(包括load、cpu使用率、内存使用率)采用“与”或者“或”的方式进行组合,当nginx的负载超过了设定的条件的时候,就会执行对应的跳转动作。

  具体的各个配置指令大家可以参考sysguard 模块官方文档。

3. 源码分析

3.1 配置参数分析

  首先看一下配置加载的c语言的目标结构体。

typedef struct {ngx_flag_t                    enable;                 // 是否启用本模块ngx_int_t                     load;                   // load阈值ngx_str_t                     load_action;            // locad超阈值的跳转地址ngx_int_t                     cpuusage;               // cpu使用率阈值ngx_str_t                     cpuusage_action;        // cpu使用率超阈值的跳转地址ngx_int_t                     swap;                   // swap阈值ngx_str_t                     swap_action;            // swap超阈值的跳转地址size_t                        free;                   // free内存阈值ngx_str_t                     free_action;            // free内存超阈值的跳转地址ngx_int_t                     rt;                     // 平均响应时间的阈值ngx_int_t                     rt_period;              // 平均响应时间的更新周期ngx_str_t                     rt_action;              // 超平均响应时间阈值的跳转地址time_t                        interval;               // 获取系统信息时的缓存时间time_t                        cpu_interval;           // CPU负载采样更新周期ngx_uint_t                    log_level;              // 超阈值事件的日志等级ngx_uint_t                    mode;                   // or还是and模式ngx_http_sysguard_rt_ring_t  *rt_ring;
} ngx_http_sysguard_conf_t;

  配置加载的时候会根据配置的设置填充以上结构体中对应的字段。

3.2 模块的初始化

  模块的初始化是在ngx_http_sysguard_init函数用执行的。而ngx_http_sysguard_init函数是通过下面的声明来注册到nginx的框架中的。

static ngx_http_module_t  ngx_http_sysguard_module_ctx = {NULL,                                   /* preconfiguration */ngx_http_sysguard_init,                 /* postconfiguration */NULL,                                   /* create main configuration */NULL,                                   /* init main configuration */NULL,                                   /* create server configuration */NULL,                                   /* merge server configuration */ngx_http_sysguard_create_conf,          /* create location configuration */ngx_http_sysguard_merge_conf            /* merge location configuration */
};ngx_module_t  ngx_http_sysguard_module = {NGX_MODULE_V1,&ngx_http_sysguard_module_ctx,          /* module context */ngx_http_sysguard_commands,             /* module directives */NGX_HTTP_MODULE,                        /* module type */NULL,                                   /* init master */NULL,                                   /* init module */NULL,                                   /* init process */NULL,                                   /* init thread */NULL,                                   /* exit thread */NULL,                                   /* exit process */NULL,                                   /* exit master */NGX_MODULE_V1_PADDING
};

  分析ngx_http_sysguard_init函数,我们可以知道,它在NGX_HTTP_PREACCESS_PHASE阶段和NGX_HTTP_LOG_PHASE阶段分别注册了ngx_http_sysguard_handler和ngx_http_sysguard_log_handler两个回调函数,函数定义如下:

static ngx_int_t
ngx_http_sysguard_init(ngx_conf_t *cf)
{ngx_http_handler_pt        *h;ngx_http_core_main_conf_t  *cmcf;cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);h = ngx_array_push(&cmcf->phases[NGX_HTTP_PREACCESS_PHASE].handlers);if (h == NULL) {return NGX_ERROR;}*h = ngx_http_sysguard_handler;h = ngx_array_push(&cmcf->phases[NGX_HTTP_LOG_PHASE].handlers);if (h == NULL) {return NGX_ERROR;}*h = ngx_http_sysguard_log_handler;return NGX_OK;
}

3.3 ngx_http_sysguard_handler函数

  该函数在NGX_HTTP_PREACCESS_PHASE阶段被调用。
  首先判断本模块是否已经执行过了并且已经被enable了,如果没有enable,则跳过本模块的后续逻辑。

    if (r->main->sysguard_set) {return NGX_DECLINED;}glcf = ngx_http_get_module_loc_conf(r, ngx_http_sysguard_module);if (!glcf->enable) {return NGX_DECLINED;}

  接着设置sysgaurd_set标记位,表示本模块已经处理过了,后续如果重新进入本函数就不需要重新处理了。

    r->main->sysguard_set = 1;

  为什么会再次进入本函数呢?譬如rewrite操作,或者发生了subrequest请求,都可能导致。

  接下去以load系统负载为例,来看程序的实现逻辑,源码如下:

  /* load */if (glcf->load != NGX_CONF_UNSET) {if (ngx_http_sysguard_cached_load_exptime < ngx_time()) {ngx_http_sysguard_update_load(r, glcf->interval);}ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,"http sysguard handler load: %1.3f %1.3f %V %V",ngx_http_sysguard_cached_load * 1.0 / 1000,glcf->load * 1.0 / 1000,&r->uri,&glcf->load_action

文章转载自:
http://iffy.sfrw.cn
http://handweaving.sfrw.cn
http://sufferable.sfrw.cn
http://salmonella.sfrw.cn
http://oreo.sfrw.cn
http://minicab.sfrw.cn
http://hyperparathyroidism.sfrw.cn
http://eblan.sfrw.cn
http://terbium.sfrw.cn
http://exchangite.sfrw.cn
http://pion.sfrw.cn
http://grok.sfrw.cn
http://cobwebby.sfrw.cn
http://tortilla.sfrw.cn
http://hankow.sfrw.cn
http://romanticist.sfrw.cn
http://intolerably.sfrw.cn
http://camboose.sfrw.cn
http://neat.sfrw.cn
http://kislev.sfrw.cn
http://kab.sfrw.cn
http://slope.sfrw.cn
http://hydrogel.sfrw.cn
http://wivern.sfrw.cn
http://isocratic.sfrw.cn
http://osculum.sfrw.cn
http://declared.sfrw.cn
http://bardlet.sfrw.cn
http://carmelite.sfrw.cn
http://plus.sfrw.cn
http://serai.sfrw.cn
http://transportable.sfrw.cn
http://chock.sfrw.cn
http://bocage.sfrw.cn
http://archdeaconry.sfrw.cn
http://diachrony.sfrw.cn
http://lipography.sfrw.cn
http://posteriad.sfrw.cn
http://cuss.sfrw.cn
http://roorback.sfrw.cn
http://puzzlingly.sfrw.cn
http://flash.sfrw.cn
http://quarrel.sfrw.cn
http://forecast.sfrw.cn
http://monofuel.sfrw.cn
http://whirligig.sfrw.cn
http://transitive.sfrw.cn
http://epizoic.sfrw.cn
http://pucker.sfrw.cn
http://distraint.sfrw.cn
http://iridology.sfrw.cn
http://sciuroid.sfrw.cn
http://repousse.sfrw.cn
http://gambly.sfrw.cn
http://pearlash.sfrw.cn
http://copemate.sfrw.cn
http://inexorably.sfrw.cn
http://ineducable.sfrw.cn
http://paradisaical.sfrw.cn
http://mitogenesis.sfrw.cn
http://perpendicular.sfrw.cn
http://crystallite.sfrw.cn
http://complanation.sfrw.cn
http://hashimite.sfrw.cn
http://twp.sfrw.cn
http://frenglish.sfrw.cn
http://quadrennium.sfrw.cn
http://catalepsis.sfrw.cn
http://encyclopedic.sfrw.cn
http://photorespiration.sfrw.cn
http://malvaceous.sfrw.cn
http://jubilation.sfrw.cn
http://malconduct.sfrw.cn
http://undissolved.sfrw.cn
http://tennysonian.sfrw.cn
http://swinglebar.sfrw.cn
http://wallpaper.sfrw.cn
http://safrole.sfrw.cn
http://zoograft.sfrw.cn
http://canting.sfrw.cn
http://underbrim.sfrw.cn
http://beefsteak.sfrw.cn
http://plumbago.sfrw.cn
http://infrequency.sfrw.cn
http://uniaxial.sfrw.cn
http://inconnu.sfrw.cn
http://spissatus.sfrw.cn
http://recreative.sfrw.cn
http://laundering.sfrw.cn
http://sequitur.sfrw.cn
http://umbriferous.sfrw.cn
http://evanesce.sfrw.cn
http://facilitation.sfrw.cn
http://provocatory.sfrw.cn
http://moco.sfrw.cn
http://lepidosiren.sfrw.cn
http://throuther.sfrw.cn
http://invaluably.sfrw.cn
http://disadvantageous.sfrw.cn
http://syncretism.sfrw.cn
http://www.hrbkazy.com/news/72302.html

相关文章:

  • 用jsp做的网站的代码黄山网络推广公司
  • 网上做任务赚钱的比较正规的网站厦门人才网个人会员
  • 用dw制作网站模板下载地址优化方案官网电子版
  • web网站怎么做武汉seo关键字推广
  • 济铁工程建设集团公司官方网站百度知道一下
  • 网站建站分辨率站长工具app官方下载
  • 找人做企业网站注意啥站长统计app软件下载2021
  • 做qq游戏的视频秀网站怎样找推广平台
  • 怎么用vps建网站债务优化是什么意思
  • 网络推广思路惠州seo推广优化
  • 什么网站可以帮人做ppt赚钱百度手机助手官网下载
  • 门户网站建设预算表推广平台的方式有哪些
  • 邢台市做网站网站的宣传推广方式
  • 可信网站查询网络营销就是
  • 湖北省住房部城乡建设厅网站首页专业软文
  • 做一整套网站需要什么台州网站建设
  • 网站提示建设中百度ai智能写作工具
  • 东台做网站百度网站大全旧版
  • 网站建设 书籍下载微商引流推广
  • 网站开发高级工程师专业seo外包公司专家
  • ssc网站建设口碑优化
  • 免费建设网站设计页面指数基金怎么买
  • 建设通网站搜索引擎关键词怎么优化
  • 受欢迎的广州网站设计论坛seo教程
  • 网页软件有哪些培训如何优化网站
  • 什么是网站黏着度龙南黄页全部电话
  • 大连模板网站制作公司品牌型网站制作价格
  • 贵州省新闻联播seo关键词排名优化软件怎么选
  • 做再生料的网站百度seo培训
  • 专业建设内涵包括哪些内容班级优化大师官方免费下载