温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何用源码解读提高RGW最大并发数

发布时间:2021-12-21 16:32:27 来源:亿速云 阅读:137 作者:柒染 栏目:云计算

今天就跟大家聊聊有关如何用源码解读提高RGW最大并发数,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

源码解读如何提高RGW最大并发数

以rgw服务的main()为入口,查看整个fastcgi的初始化过程,代码如下

#src/rgw/rgw_main.cc
int main(int argc, const char **argv)
    if (framework == "fastcgi" || framework == "fcgi") {
      RGWProcessEnv fcgi_pe = { store, &rest, olog, 0 };

      fe = new RGWFCGXFrontend(fcgi_pe, config);
      
    dout(0) << "starting handler: " << fiter->first << dendl;
    int r = fe->init(); #调用RGWFCGXFrontend的init()方法

再看init()方法构建了一个RGWFCGXProcess,并将rgw_thread_pool_size作为实参传递进去。

#src/rgw/rgw_frontend.h
class RGWFCGXFrontend : public RGWProcessFrontend {
public:
  RGWFCGXFrontend(RGWProcessEnv& pe, RGWFrontendConfig* _conf)
    : RGWProcessFrontend(pe, _conf) {}

  int init() {
    pprocess = new RGWFCGXProcess(g_ceph_context, &env,
				  g_conf->rgw_thread_pool_size, conf);
    return 0;
  }
};

默认rgw_thread_pool_size为100,代码定义如下

#src/common/config_opts.h
OPTION(rgw_thread_pool_size, OPT_INT, 100)

通过RGWFCGXProcess的构造函数发现max_connections=num_threads + (num_threads >> 3),也就是说默认情况下max_connections=100+1=101,代码注释中也提到这是为了确保能够尽可能多的处理请求。

#src/rgw/rgw_process.h
class RGWFCGXProcess : public RGWProcess {
	int max_connections;
public:

  /* have a bit more connections than threads so that requests are
   * still accepted even if we're still processing older requests */
  RGWFCGXProcess(CephContext* cct, RGWProcessEnv* pe, int num_threads,
		 RGWFrontendConfig* _conf)
    : RGWProcess(cct, pe, num_threads, _conf),
      max_connections(num_threads + (num_threads >> 3))
    {}

  void run();
  void handle_request(RGWRequest* req);
};

所以num_threads控制着max_connections的数量,如果你想提高单个rgw进程的最大并发数量,需要调高rgw_thread_pool_size。

看完上述内容,你们对如何用源码解读提高RGW最大并发数有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

rgw
AI