• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 28. Programming CGI Scripts > CGI Server Requirements

CGI Server Requirements

CGI scripts, by their very nature, place an extra burden on the Web server. They're separate programs, which means the server process must spawn a new task for every CGI script that's executed. The server can't just launch your program and then sit around waiting for the response; chances are good that others are asking for URLs in the meantime. So the new task must operate asynchronously, and the server has to monitor the task to see when it's done.

  • The overhead of spawning a task and waiting for it to complete is usually minimal, but the task itself will use system resources—memory and disk—and also will consume processor time slices. A popular site can easily garner dozens of hits almost simultaneously. If the server tries to satisfy all of them, and each one takes up memory, disk, and processor time, you can quickly bog your server down so far that it becomes worthless.

  • In addition, consider the matter of file contention. Not only are the various processes (CGI scripts, the server itself, and whatever else you may be running) vying for processor time and memory, they may be trying to access the same files. A guestbook script, for example, may be displaying the guestbook to three browsers while updating it with the input from a fourth. (Nothing exists to keep the multiple scripts running from being the same script multiple times.) The mechanisms for ensuring a file is available—locking it while writing and releasing it when done—all take time: operating system time and simple computation time. Making a script foolproof this way also makes the script bigger and more complex, which means longer load times and longer execution times.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint