Tuesday, May 5, 2020

My Dying Bride Essay Example For Students

My Dying Bride Essay What a FastCGI Application Looks Like FastCGI with Perl and Tcl Installing and Configuring FastCGI Incorporating FastCGI Functionality into Apache Building the FastCGI Developers Kit Perl FastCGI Programs The mod_fastcgi Module The AppClass Directive CFastCGIFastCGI is a high-performance replacement to the CGI standard. It provides a significant improvement in performance over the existing CGI interface. In its current implementation, FastCGI provides manydesirable enhancements that make it a very attractive and competitive alternative to proprietary technologies for developing Web-based applications. Under many circumstances, it will be a better choice toimplement FastCGI than to develop a custom server module using Apaches proprietary server Application Programmers Interface (API). FastCGI is available from http://www.fastcgi.com. (See Figure C.1.) The site is the official resource to all FastCGI information. It has complete documentation and whitepapers on FastCGI. Also nice is a mailing lista threaded archive that is available through the Web. FastCGI is a proposed open standard; this means that it is not currently widely accepted, but it has received a warm welcome by many significant people on the Internet who are responsible for setting thestandards. More than likely, this welcome will turn into acceptance on both free and commercial Web server offerings, which will help it in becoming blessed from a standard point of view. FastCGI is appealing not only because of its performance enhancements but because the effort required to migrate existing code is very small. As a bonus, software developed under this proposed standardhas a high degree of portability. These portability issues help a great deal toward setting it as a viable candidate to become a standard, especially on installations that have committed extensive resources toFastCGI is not a development environment in terms of having to learn yet another programming language. In a very simplistic desc ription, FastCGI it is a CGI program that uses additional libraries, so it doesrequire that you learn an API. The basic API is tiny, though; one call is all you need to migrate many of your current programs. FastCGI FeaturesThe main features of FastCGI are as follows: A huge increase in performance. FastCGI programs continue to live between requests, making their responsiveness faster and reducing delays due to forking and program initialization. Programming language-independent implementation. Like CGI, you can develop your FastCGI application with a variety of languages. Currently there are programming libraries for Perl, C/C++, Tcl,and Java. Porting existing code to FastCGI is easy, allowing you to easily migrate your existing code base without having to redo what you have done. FastCGI processes are isolated from the Web server core. Much like CGI, FastCGI applications offer greater security and reliability than developing a similar functionality as a module using a serverServer technology separation. There are FastCGI modules for various servers, including Apache, NCSA, and the Open Market Secure WebServer. For any other server that supports CGIs, thecgi-fcgi program, included in the FastCGI distribution, implements the FastCGI environment. Distributed computing support. FastCGI applications can execute on a different host from the Web server. This allows you to offload FastCGI execution to other application servers, permitting yourWeb server to handle an increased load. FastCGI programs can run on any host that can be reached over TCP/IP. The concept of roles. Traditional CGI programs fall into the responder role; they respond to some action initiated by a browser and send back some HTML. FastCGI programs can also perform otherroles, such as a filter or as part of some authentication scheme. This allows for providing extra functionality that would usually be relegated to a server module. The currently available FastCGI modulefor Apache does not include s upport for roles other than responder, but this may change in the future. Performance EnhancementThe increase in performance alone would be a good enough reason to migrate CGIs to FastCGI, especially on loaded servers. This increase in performance is achieved primarily because FastCGI processesare persistent. Forking under UNIX is very expensive, and FastCGI addresses this issue by reusing processes. This saves on the initialization time and can also provide enhancements when data calculated byone call to the program can be reused in another transaction. Unlike CGIs, which are forked every time theres a request for the functionality, FastCGI processes are reused. After a request is fulfilled, the process remains, waiting for additional requests. Programs that rely on an interpreter such as Perl or Tcl can gain a great deal from this technology because the command interpreter will compile the program once, not once per call. The time required to doall this pre-run initialization is e liminated. On the program side, this can yield to enhancements such as establishing a connection with a database or some other process because the connection only needs tohappen once. Add to this the load to launch the interpreter program, and the savings are significant. What sort of performance gains can you obtain? According to information posted on the FastCGI Web site, Open Markets tests show the following: Client, Server, and Application Processing Time 21ms + 0.19ms/KB 22ms + 0.28ms/KB 59ms + 0.37ms/KB Add to this the cumulative time that it takes for an application to establish a TCP/IP connection to, say, a database. Under CGI, a process will have to initialize each time it is run. FastCGI can yield aperformance increase of four times the speed of the same program used as CGI. In load terms, this could mean that your server could potentially handle four times your current CGI load. However, the levelof enhancement will depend on the source of the bottleneck. If your databas e server is the current source of the problem, FastCGI cannot do much about that except reduce the number of connections thatthe database server will need to perform, perhaps giving it more time to process data instead. FastCGI APIThe FastCGI API has a handful of calls: FCGI_Accept is used to implement the server connectivity and control the running of the FastCGI program. FCGI_Finish gives you control after the FastCGI program has executed, but before running the next request. FCGI_SetExitStatus is used to set the exit status of the request. Most CGI programs dont return meaningful exit status, so this call is seldom used. FCGI_StartFileterData enables you to implement a special type of FastCGI application, called a filter. Currently the Apache implementation of the FastCGI module doesnt support roles, of which thefilter type is a member, but this likely will change in the near future. Filters allow you to implement programs that will convert one data format to another on-the-fly (for example, TIFF to GIF). Data is read and written through the standard input, output, and error streams. FastCGI also provides macros that map files and streams to native calls supported by your operating system. Like CGI, you can create FastCGI applications in almost any language. However, you are currently limited to the ports of the library. Currently available are Perl, C/C++, Tcl, Java, and very soon Python,which should be available by the time you read this. Also in the works is a multithreaded C/C++ library that has not been released, but should be available as part of the 1.6 release. The multithreaded libraryallows a single application process to handle concurrent requests, which will allow you to implement things like HTTP-based chat applications. Even though FastCGI is not universal, most developers should find themselves at home in one of the programming languages previously mentioned. As soon as FastCGI gains more acceptance, there will beadditional libraries impleme nted. Developers are encouraged to port the FastCGI libraries to their programming language of choice, ensuring that the openness of the extension is more widely supported. Thesuccess of FastCGI will depend on getting many vendors and programmers to support it. Given its current feature set, it should have no trouble reaching this goal. The design of FastCGI also wins big on the learning curve because unlike server APIs, you are still programming a CGI, so you can leverage what you already know. The only issues that you will need toaddress have to do with reorganizing your application so that the initialization code, which is done once, is kept separate from the application body. FastCGI applications are long-lived; they are kept alivebetween transactions. This also means that memory needs to be managed because unlike CGIs, which have a short life span, FastCGI processes may execute for undetermined amounts of time. Data sent to a FastCGI application by the server is accessed throug h special streams that provide complete binary compatibility with the CGI standard. This also allows a FastCGI program to run as a regularCGI program. A FastCGI program can determine, at runtime, if it is being run as CGI or as FastCGI and behave accordingly. This translates into an environment that allows you to migrate FastCGI programs down, should you ever need to. This provides server independence because the same binary can be run on two serverssayApache and Netscapeunder the same operating system without even needing to be rebuilt or require programming modifications, even if the server couldnt support FastCGI. This feature alone is veryinteresting from a legacy and recycling standpoint. Also, all servers support FastCGI. The FastCGI Developers Kit comes with a program called cgi-fcgi that allows you to run FastCGI responderapplications. The cgi-fcgi program allows any Web server that supports CGI to run FastCGI. FastCGI applications communicate with Apache using a single full -duplex connection. Through this connection, the server transmits the environment variables and stdin to the FastCGI application; stdout andstderr streams from the application are sent back to the server. What a FastCGI Application Looks LikeA modified version of my HelloWorld.c looks like this: printf (Content-type: text/htmlrnrn);printf(*HEAD**TITLE*Hello World!*/TITLE**/HEAD*);printf(*BODY**H1*Hello, this is a FastCGI program!*/H1*);printf(*BIG**P*I can tell that you are visiting from %s.*/P*);printf(*p*This page has been accessed: %d times*/P**/BIG**/BODY*, getenv(REMOTE_HOST), ++timesVisited);This version makes use of the fact that the application is persistent and will maintain a count of the times the program is run (until the program dies). As you can see from this example, FastCGI applications follow this sequence: 1.Initialization. Persistent connections or data that should be available from request to request are initialized in this section. Initialization is done only o nce. The initial environment for FastCGI applicationsis set through the AppClass directive, which is added by the FastCGI module. 2.The Response Loop. This loop is started by the FCGI_Accept() routine, implemented in the FastCGI library. A call to this routine blocks program execution until the program receives a client request. Elements In The Road Not Taken EssayFastCGI is a great choicethe learning-and-setup curve is hours, not days like other environments. Performance Enhancement What a FastCGI Application Looks Like FastCGI with Perl and Tcl Installing and Configuring FastCGI Incorporating FastCGI Functionality into Apache Building the FastCGI Developers Kit Perl FastCGI ProgramsBibliography:

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.