模块:常规cgi + fast 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 + fast cgi(名称:1.c)
常规cgi:
#include <stdio.h>
int main(void) {
printf("Content-Type: text/plain;\n\n");
printf("ttt\n\n");
return 0;
}
fcgi(Fast 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
答案 0 :(得分:2)
您应该拨打FCGI_Finish()
而不是return 0;
,否则您的程序在退出前只会提供一个请求。