modules for: regular cgi + fast cgi
LoadModule cgi_module modules/mod_cgi.so
LoadModule fcgid_module modules/mod_fcgid.so
test folder for regular and fast 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 test scripts : regular cgi + fast cgi ( named: 1.c )
Regular 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;
}
}
Benchmark with regular cgi: ( 3.61 seconds )
ab -n 10 -c 10 http://<ip>/rc/1
Time taken for tests: 3.613 seconds
Benchmark with fast cgi : ( 13.23 seconds )
ab -n 10 -c 10 http://<ip>/fc/1
Time taken for tests: 13.233 seconds
You're supposed to call FCGI_Finish()
instead of return 0;
, otherwise your program just serves only one request before exiting.