Results 1 to 2 of 2

Thread: CGI and APIs!

  1. #1
    Senior Member
    Join Date
    Sep 2004

    Hacking CGIs

    hi, guys.. i was reading something about web databases...

    CGI and APIs:

    I quote this about the downside of CGI(Common Gateway interface):

    The downside of CGI is that itís slow. Each time a web client activates a program through CGI, a new instance of that processing program is started. So if 28 users submit forms to be processed, the server has to run 28 separate copies of the processing program! This will drastically affect the server if the processing is long or complex, or if there are many users.

    Some server developers have tried to address this problem by allowing other pieces of software to directly interface with the server through an API. This greatly enhances the speed of processing since only one copy of the processing program is active. Each request for processing is either queued for sequential processing or handled in parallel through multitasking or multithreading.

    That means the server running 28 users using CGI will be much slower than if it was running 28 users using APIs...

    Increase the number a little bit.. make it 100-200 or 1000 user request... what i can immagine is that CGI can be more effectively used for a Denial Of Service!

    So what u guys say?
    And here is another thing, since CGI can be used in virtually any internet service provider, it is a good way for outsourcing the web hosting !

    So.. want your opinion on that too..

    Oh! did u just do a google search on "CGI tutorial" :P :P trying to learn it cuz u think it can be pretty useful :P

    and umm.. who here knows CGI?
    can u describe it a bit for me.. just a general idea..your opinion: worth knowing? what u think of it?

  2. #2
    Join Date
    Jul 2005
    CGI? Well, I used Borland Delphi to write some CGI applications. Basically, a CGI application is just a "console" application that reads from the "input console" and writes to the "output console". That's basically it. It's not a special language or whatever, although some people do speak of Perl as if it's a CGI language. Reality is, however, that CGI is language-neutral. You might want to read more about it at this wiki if you're interested.

    Why did I decide to use CGI's, though? Well, the alternative was writing ISAPI DLL's but when you want to modify your page and thus adjust the binary, you have to actually stop the webserver before replacing the ISAPI DLL while with CGIs you can just overwrite the old binary with a new binary.
    And sure, CGI's are a bit slow. But if you have about 5 visitors per hour, no one would really notice this slowness anyways. Even worse, ISAPI DLLs have brought down webservers in the past simply because they are loaded in the process space of the server. CGI's use their own process space.

    But these days I've replaced both with ASP.NET development, combined with my preferred language: Delphi 2005.

    Of course, CGI's on an Unix-system would perhaps show a different performance, with more different alternatives.

    One more thing to consider. When Windows loads a CGI application, the executable binary will just be loaded once, no matter how many differennt instances you have running. All that gets duplicated is the data segment of the executable and the stack. But the binary is loaded only once. Thus if your executable is 10 MB in size but only uses 1 MB of data, it will use less resources than an executable that is 1 MB in size but requires 10 MB in total. (Which is why it's a bad idea to ExePack executables that you will have multiple instances of.)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts