gpt4 book ai didi

c - Apache (ab) : mod_fcgid 4x slower than mod_cgi

转载 作者:太空宇宙 更新时间:2023-11-04 02:31:33 25 4
gpt4 key购买 nike

模块:常规 cgi + 快速 cgi

LoadModule cgi_module modules/mod_cgi.so
LoadModule fcgid_module modules/mod_fcgid.so

常规和快速 cgi 的测试文件夹。

DocumentRoot "/test"

<Directory "/test/rc">
Require all granted
Options +ExecCGI
SetHandler cgi-script
</Directory>


<Directory "/test/fc">
Require all granted
Options +ExecCGI
SetHandler fcgid-script
</Directory>

C 测试脚本:常规 cgi + 快速 cgi(命名为:1.c)

常规 CGI:

#include <stdio.h>

int main(void) {
printf("Content-Type: text/plain;\n\n");
printf("ttt\n\n");
return 0;
}

fcgi(快速 Cgi)

#include <stdio.h>
#include <fcgi_stdio.h>

int main(void) {
while (FCGI_Accept() >= 0) {
printf("Content-Type: text/plain;\n\n");
printf("ttt\n\n");
return 0;
}
}

常规 cgi 基准测试:(3.61 秒)

 ab -n 10 -c 10 http://<ip>/rc/1
Time taken for tests: 3.613 seconds

具有快速 cgi 的基准:(13.23 秒)

 ab -n 10 -c 10 http://<ip>/fc/1
Time taken for tests: 13.233 seconds

最佳答案

您应该调用 FCGI_Finish() 而不是 return 0;,否则您的程序在退出前只会处理 一个 请求。

关于c - Apache (ab) : mod_fcgid 4x slower than mod_cgi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42577994/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com