1

I was reading up on CGI and FastCGI and wondered why the later was created. The reason I often read is that it spares the overhead of creating a new process for every request, but I can't imagine this to be such a huge performance problem.

  1. I see, that CGI could be slow when using interpreted scripts (like Perl) for every request, because the interpreter needs time to start up and load libraries. How is FastCGI an improvement over CGI when using a compiled language like C or Rust?

  2. Couldn't I just recreate what FastCGI does by starting a daemon, that is contacted by small (and thus well performing) CGI shell scripts?

J. Doe
  • 326
  • 2
  • 12
  • Possible duplicate of [Differences and uses between WSGI, CGI, FastCGI, and mod\_python in regards to Python?](https://stackoverflow.com/questions/3937224/differences-and-uses-between-wsgi-cgi-fastcgi-and-mod-python-in-regards-to-py) – Ahmad Bilal Oct 15 '18 at 06:56

2 Answers2

1

Honestly, you can compile a prototype in C and try it out. It’s funny how in one breath people say “pre optimisation is the root of all evil” and in the very next day “don’t use CGI because fork/exec performs badly”. Compiled languages have many advantages over interptreted not just speed (early error detection for types), and on my cheap Arch Linux development laptop, I can have Apache fork/exec my CGI script 3000+ times per second.

The Unix-like simplicity of CGI - standard input and output - is very appealing compared to the monolithic “frameworks” in PHP, et all, with 275 layers of indirection. And if CGI really does not perform well for your Suse case, the difference between CGI and FastCGI can be as little as a small interface, so just deal with that when it happens.

magnus
  • 4,031
  • 7
  • 26
  • 48
-1

That is nearly a FAQ. You should have googled a bit before starting a new question. Anyways.. look at the link below.

Differences and uses between WSGI, CGI, FastCGI, and mod_python in regards to Python?

Also, look at mod_cgi and mod_fcgi pages of Apache Documentation. For

  1. No CGI is not slow because of using scripting languages especially not Perl. CGI is slow because of how it works. As to how it is a improvement, you have to read more about FastCGI.

  2. You still don't understand what FastCGI does, so No.

Ahmad Bilal
  • 380
  • 1
  • 2
  • 15