这篇文章主要介绍“怎么用fastcgi模式提高RGW并发数”,在日常操作中,相信很多人在怎么用fastcgi模式提高RGW并发数问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么用fastcgi模式提高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。
到此,关于“怎么用fastcgi模式提高RGW并发数”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
原文链接:https://my.oschina.net/diluga/blog/4392216