Read an Excerpt
Chapter 1: The Internet
Information Server
(IIS)Application
The rate at which computer science is growing is probably tiring for computer
programmers who must stay on top of cutting-edge technology. Keeping up with
changes in this field is more than a full-time job. Usually, you purchase a book on
a new programming topic and immediately hear that another new technology has
surfaced. This is especially true concerning the Internet. Technologies emerge
faster than anyone can truly master.
If you are an Internet programmer or are learning to become one, you have to
choose the technology you want to specialize in, but never stop watching for the
new ones. When a new technology starts to become the dominant player and the
one you are specializing in is in infirmity, you should be ready to climb on the
new bandwagon. For example, at one time, Common Gateway Interface (CGI)
was the main technology of the Internet. It is still being used, but better technologies
have been invented and CGI is no longer everyone's favorite.
However, while the entire Internet industry becomes more dynamic every
day, the basics remain static, so it is not too difficult to adapt to a new technology
regardless of how loud the propaganda is. HTTP (currently at version 1.1) is still
the protocol used and HTML (at version 4) is still the language used for content
presentation on Web pages.
How Does the Internet Work?
When you surf the Internet, you basically ask for certain files located in a particular
computer in a given location where those files are stored. In a typical Web site,
the computer where the files are stored is expected to be up and running all the
time, and its main job is to serve anyone who requests a file. Not surprisingly, this
computer is called a server, more precisely: a Web server. The file returned by the
Web server is displayed in the user's Web browser. Note that the term Web server
can be used to refer to the computer or to the software package that is used in the
Web server computer.
For this whole process of requesting a file and sending a file to happen, both
the server and the user (called the client) must have a valid Internet address. The
server address is something like http://www.apress.com
or another type of
Internet address. The client address depends on where the user accesses the
Internet. When you connect to the Internet through an Internet Service Provider
(ISP), for example, you are given a temporary Internet address, so the server
knows where to send the requested file. When you are connected through your
corporate LAN, you could have a fixed IP address or you could be given a temporary
IP address also.
When you click or type in a URL, the following process happens:
- The browser connects to the server.
- The browser requests a file.
- The server responds by sending the requested page to the browser, and
then closes the connection.
Of course, a connection to the server can only be established if the server is running
and is not too busy serving other requests.
What happens after the server sends the requested file depends on the user.
The user can just close the browser and walk away or request another file from
the server. However, when the server is connected for the second time, it cannot
tell whether it is the second request from the same user or a first request from
some other user.
The fact that the server cannot remember users who have previously requested
pages has a deep impact on how an Internet application is developed. Programmers
who are used to the conventional client/server programming might
find it confusing at first to figure out how an Internet application works. For now,
just keep this information in mind. Further discussion on this issue will be found
in Chapter 7.
The architecture of an Internet application is shown in Figure 1-1.
Also keep in mind that the server does not serve only one user. For an
Internet application, anyone connected to the Internet can request a page from
the server. At times, in popular Web sites, thousands of requests come in simultaneously.
And, if you are running a corporate intranet application, everyone with
access can request a page. Therefore, it is very important for the Web application
to be as efficient as possible.
The Available Technologies
In the software industry, including Web technology, Microsoft products seem to
be more and more dominant. As far as Web technology is concerned, Microsoft
provides a total solution. You can use Microsoft products exclusively to deliver a
scalable Web solution. If you decide to do so, choosing each component in the
system is easy because Microsoft products don't compete with each other. It is
almost certain that you will choose Windows NT or Windows 2000 Server for your
operating system, IIS as your Web server, SQL Server for your database server, and
Component Object Model (COM) technology as your developing framework. The
good news is, if you have been using a Microsoft compiler, you won't need to
change the programming language.
On the other hand, if you are more inclined toward other products and vendors,
your choice is more varied. Getting the right combination of products is
often a political issue, not to mention that there is always a risk of incompatibility
between products from different manufacturers. A typical Web solution without
Microsoft presence could include a Unix or Linux operating system; an Apache
(still the most popular today) or a Java Web server; a MySQL, Oracle, Informix,
Sybase, or other database; and PERL or PHP or Java as your language of choice.
However, because you have chosen this book from the shelf, chances are you
are using Microsoft products. If you are new to Microsoft's Internet technologies,
please read the next section. It describes the existing technologies and the position
of each.
The Facts about Microsoft Internet Technologies
Before the arrival of the IIS applications technology in Visual Basic, there were
and still are three types of Web applications in use that can run using IIS. They are
Common Gateway Interface (CGI), Internet Server Application Programming
Interface (ISAPI), and Active Server Pages (ASP).
CGI is easy to program and is the slowest Web technology available on the
Windows platform. In Windows operating systems, the Web server creates a separate
process for each HTTP request and communicates with the process through
environment variables and standard input () and standard output )
streams. If 1,000 clients access a CGI application at the same time, the server creates
1,000 instances of the CGI application to handle the requests. Each instance
requires its own memory space and system resources.
Because process creation and interprocess communication are time and resource
consuming operations, it's not surprising that a CGI application is the
slowest compared with other available technologies. CGI applications are usually
implemented as a C/C++ executable or with a scripting language like PERL. The
output of a CGI application is generated using the basic output functions of the
language, for example, printf in C. CGI programs are not as bad in Unix, which is
designed to handle multiple processes with very little overhead.
ISAPI is the fastest among the three applications and was developed specifically
for IIS as a high-performance Windows alternative to CGI. ISAPI is an API for
developing extensions to the IIS server and other HTTP servers that support the
ISAPI interface. Compiled as a runtime dynamic link library (DLL) file, the ISAPI
model reduces the overhead required by multiple requests because only one DLL
is needed for multiple requests.
The first time an ISAPI DLL is requested, the server loads it into memory.
Unless the Web server is shut down, the DLL stays in memory waiting for another
request. Therefore, there is no overhead for process creation after the first request.
Furthermore, ISAPI applications run in the same address space as the Web server
and have access to all the same resources. There is no need for interprocess communication.
However, ISAPI applications development is also the hardest, requiring
implementation using C++/MFC. This factor alone deters many from selecting
this solution.
There is also a maintenance problem with ISAPI. Even a minor change
requires a recompile and relink of the ISAPI application. Also, an ISAPI DLL can
cause the Web server to crash if it is not thoroughly tested before being deployed
and run in the Web server process. Fortunately, with IIS 4.0 and later, you can
select to run ISAPI DLLs in separate processes, with performance being sacrificed
of course. Note that ISAPI applications are not the same as ISAPI filters, which are
DLLs that allow preprocessing of requests and postprocessing of responses for
site-specific handling of HTTP requests and responses....