Cgi/fastcgi/isapi differences

Source: Internet
Author: User

A CGI principle and its performance

1) CGI concept
CGI is a universal Gateway Interface (Common Gateway Interface), which is a program that runs on the server and provides interaction with the client HTML page, and the popular CGI is like a bridge that connects the Web page and the executing program in the Web server. It passes the instruction that the HTML receives to the server execution program, and then returns the result of the server execution program to the HTML page.

2) CGI programming language
In fact, any programming language can be called a CGI programming language as long as it can be used to write applications on the server host using the CGI interface. Currently the most popular CGI programming language has four kinds: C,shell,perl and VisualBasic, other languages are also used by many people, such as Tcl,fortran and AppleScript.

3) Execution of CGI programs
A CGI program is generally an executable program. Compiled CGI programs are generally placed in a single directory. The location of the specific storage varies with the operating system. The execution of a CGI program generally has two kinds of invocation: the first is called directly through the URL, such as: "Http://202.114.2.182/cgi-win/cgi.exe", in the browser's URL bar directly written to the above description can be called the program, another way, It is also the main way to invoke the form bar in the interactive home page, usually when the user fills out an input form and presses the confirmation button to start the CGI program.

4) The main process of CGI work
The main process of CGI work is: 1. A user requests to activate a CGI application; The 2.CGI application extracts the user input from the interactive home page; 3. Pass user input information to the server host application (e.g. database query) 4. Return the server processing results to the user via HTML file; 5.CGI process end.

5) performance evaluation of CGI
CGI has excellent cross-platform performance and can be implemented on virtually any operating system, such as DOS, WINDOWS, UNIX, OS/2, Macintosh, and so on. There are also many options for implementing the CGI programming language. CGI applications are generally a separate executable program, and the WWW server each occupy a different process, and generally a CGI program can only handle one user request. Thus, each user request, will activate a CGI process, when the user requests a very long time, will be a lot of crowding out the system resources such as memory, CPU, etc., resulting in low performance.


The principle of two ISAPI and its performance

1) ISAPI Concept
ISAPI, the Internet Server application Program Interface, is a set of Internet service-oriented API interfaces provided by Microsoft that enables all of the functionality that CGI can provide, and expands on this basis. As provided by the filter application interface. An ISAPI server extension is a DLL that can be loaded and invoked by an HTTP server. Internet Server Extensions, also known as Internet server Applications (ISA), are used to enhance the functionality of servers that conform to the Internet server API (ISAPI). ISA is called through a browser application and provides similar functionality to a Common Gateway Interface (CGI) application.

2) ISAPI Program language
Since developing an ISAPI application uses a set of Microsoft APIs, the language that can be used to develop ISAPI applications is not as much as CGI. Mainly have visualc++4.1 above version, VisualBasic5.0, borlandc++5.0 also can.

3) ISAPI principle
ISAPI works in the same way that CGI is largely the same, through the interactive home page to obtain user input information, and then to the server background processing. But the two are in the realization mechanism of the large phase of the court path. The biggest difference between ISAPI and CGI is that, unlike CGI, applications built under ISAPI exist in the form of dynamic connection libraries, whereas CGI applications are generally executable programs.

4) Execution of the ISAPI program
The workflow for an ISAPI app is somewhat different from CGI. The DLL of an ISAPI application can not only be activated by the user request like a CGI program, but also be pre-activated by the system to monitor user input, and for a user-activated DLL, it will not disappear immediately after processing a user request, but continue to reside in memory waiting for other user input to be processed. Until after a period of time no user input.

5) 5ISAPI Performance evaluation
An ISAPI DLL that can be long in memory after being activated by a user, waiting for another request from the user, and can set up multiple user request handlers in a DLL, in addition, the ISAPI DLL application and the WWW server are in the same process and are significantly more efficient than CGI. However, the platform compatibility of the ISAPI is poor, currently only available on Microsoft's own WINDOWS95 and NT operating systems, and the server platform is limited to IIS (Internetinformationserver) and Mspersonalwebserver and ntworkstation on the peerwebserver. 6) What is an ISAPI filter?
An ISAPI filter is a DLL that runs on an ISAPI-enabled HTTP server to filter data that is sent back and forth between servers. The filter registers the notification of events, such as logins or URL mappings. When a selected event occurs, the filter is called, and you can monitor and change the data (during data transfer from the server to the client or vice versa). You can use ISAPI filters to provide enhanced logging of HTTP requests (for example, to track who is logged on to the server), custom encryption, custom compression, or other authentication methods. 7) What is the difference between an ISAPI server extension and a filter?
Server Extensions: Run when referenced in URLs. Be explicitly called, for example with Http://myserver/myprog.dll?. is loaded on request when the user first invokes it.
Filter: called for each URL that is processed by the server. If a registered event occurs, it is automatically run for any URL that is sent to the server. The service is loaded when it starts because of its registry key.

Server Extensions and filters are: * Processing space for shared services. * Must be thread-safe. * remains in memory once loaded (until the service is stopped or the memory is needed by other processes).


What are the similarities and differences between the three ISAPI and CGI?

The ISAPI server extension provides another option for Common Gateway Interface (CGI) applications that use Internet servers. Unlike CGI applications, ISAPI runs in the same address space as the HTTP server and can access all resources that can be used by the HTTP server. ISA has a lower system overhead than CGI applications because they do not require other processes to be created and do not perform traffic that needs to cross the process boundaries, which is time consuming. If memory is required by other processes, both the extension and the filter DLL may be unloaded.

Internet clients call ISAPI through an HTTP server the same way that a CGI application is called. For example, a client could invoke a CGI application like this: Http://sample, Example.exe? PARAM1&PARAM2, it can call a isapi:http://sample/example.dll?param1&param2 that performs the same function. ISAPI allows multiple commands in a DLL, which are implemented as member functions of the CHttpServer object in a DLL. CGI requires that each task have a separate name and a URL mapping to a separate executable file. Each new CGI request initiates a new process, and each different request is contained in its own executable file, which is loaded and unloaded on a per-request basis, so the system overhead is higher than Isa.

The ISAPI filter does not have an equivalent CGI filter. Filters provide the ability to preprocess and post-process all data sent between the client and the server. FastCGI        1. FastCGI is like a resident (long-live) CGI, which can be executed all the time, so long as it is activated, it will not take a moment to fork once (this is the most notorious fork-and-execute mode of CGI).  2. The FastCGI can be used on any platform, Netscape Enterprise and IIS have FastCGI modules available, and there is also mod_fastcgi available on Apache, as well as servers using Apache-derived server.  3. FastCGI supports C/c++,ruby, Perl,tcl,java,python and other programming languages. 4. The FastCGI application is also compatible with CGI.  That is, FastCGI applications can also be executed as CGI.  5. The existing CGI program to be rewritten into FastCGI is very simple, at least may need to add more than three lines of program code.  6. The debug mode of FastCGI is similar to CGI, and can be executed or debugged in command-line mode as long as the environment variables and parameters required by the program are brought in.  7. The FastCGI application is written in a similar way to CGI, with the exception of several principles, and FastCGI's way of writing is almost the same as CGI, which is much simpler compared to learning the Web Server API FastCGI. 8. FastCGI distributed Operations (distributed computing), that is, the FastCGI program can execute on a host other than the Web server and accept requests from other Web servers. PHP fastcgi makes all your PHP applications run through MOD_FASTCI, not mod_phpsusexec. FastCGI applications are fast because of their long-term stability. It is not necessary to start and initialize each request. This makes the application development possible, otherwise the CGI paradigm is impractical (such as a large script, or an application that needs to connect to a single database or multiple databases). Benefits
    1. PHP scripts run more quickly (3 to 30 times times). The PHP interpreter is loaded into memory without having to read from memory every time it is needed, greatly improving the performance of the site that relies on the script to run.
    2. Fewer system resources are required. Because the server does not need to load PHP interpreter every time, you can increase the transfer speed of the site without increasing the CPU burden.
    3. There is no need to make any changes to the existing code. All that's available is for PHP fastcgi
Potential Problems
        • For all subdirectories (/home/username/public_html/php.ini) you have only one available php.ini file. This is necessary to optimize the site code. If you need multiple php.ini files to accommodate different scripting needs, you can disable PHP's fast CGI in any subdirectory, while the rest of the places continue to work. If you need to do this please contact support.
        • Any upgrades you make to the PHP environment, such as changes to the php.ini file, have a few minutes of delay. This is because your php.ini files have been loaded into memory for faster speeds, rather than being re-read from memory every time you need them.

Cgi/fastcgi/isapi differences

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.