Lecture 4 - Web Servers
Lecture 4 - Web Servers
Lecture 4
WEB SERVERS
– A web server is software and hardware that uses HTTP (Hypertext Transfer
Protocol) and other protocols to respond to client requests made over the World
Wide Web. The main job of a web server is to display website content through
storing, processing and delivering webpages to users.
– Besides HTTP, web servers also support SMTP (Simple Mail Transfer Protocol)
and FTP (File Transfer Protocol), used for email, file transfer and storage.
– Web server hardware is connected to the internet and allows data to be
exchanged with other connected devices, while web server software controls
how a user accesses hosted files. The web server process is an example of
the Client/Server model. All computers that host websites must have web server
software.
– Web servers are used in web hosting, or the hosting of data for websites and
web-based applications -- or web applications.
Web Server
– This feature differentiates the Web from earlier file transfer services on the
Internet.
– Dynamically generated responses are created in a variety of ways:
Server-side include
Server script
Server-Side Include
– The server can interact with the script in several different ways:
Separate process invoked by the server
Software module in the same process
Persistent process contacted by the server
Passing Data to/from the Script
– Decoupling the scripts from the Web server requires a well-defined interface for passing data
between the two pieces of software.
– Common Gateway Interface (CGI) defines interfaces for a variety of operating system platforms.
Example of CGI environment variables is shown below
Creating and Using Cookies
– Cookies are typically created, used, and modified by scripts invoked to generate dynamic
responses, rather than by the Web server.
– The browser can be instructed to include a unique cookie in each HTTP request.
– If the request does not include cookie, the script create a new cookie and include the cookie in
the header of the response message
Set-Cookie: Customer="user17"; Version="1"; Path="/book"
Subsequent requests from the user would include the cookie
Cookie: Customer="user17"; Version="1"; Path="/book"
– A script can use a cookie as a user identifier in interacting with a back-end database.
– Storing history information in the cookie may obviate the need to retain information about the
user in a back-end database.
Server Architecture
– An event-driven server
Has a single process that alternates between servicing different requests
Allows the server to serialize operations that modify the same data
Performs nonblocking system calls
Not used in Most high-end Web servers
Process-Driven Server Architecture
– A process-driven server
– Allocates each request to a separate process
One master process listens for new connection
The master process creates a separate process for each new connection
– Terminates the process after parsing the client request and transmitting the
response
To prevent memory leak
– Introduces overhead for switching from one process to another
Hybrid Server Architecture
– (got it’s name from the original developers who called it ‘a patchy server’)
– Open source
– Freely distributed on the Internet
– Huge amount of end-user support
– Has earned the reputation of being one of the most reliable web server available
– Uses server modules to add functionality to the core HTTP server
– i.e. extra services that it can provide (e.g. security authentication)
Advantages of Apache web server
– Compatibility
– Technical Support
– Numerous features
Tomcat web server
– Tomcat
– Similar to Apache and also maintained by Apache Software Foundation
– Fast becoming a popular Web server
– Built in Servlet container (engine)
– Requires no add-ons to support Servlets
– To launch Tomcat, successively select
– Start, Programs, Apache Tomcat 4.x and Start Tomcat
Advantages of Tomcat
– Developed by Microsoft
– IIS 5.0
– Enterprise-level Web server
– Included with Windows 2000
– Allows computer to serve documents
– Uses an Internet Services Manager to administrate
Server Errors
– 500 internal sever error - The request was not completed. The server met an unexpected
condition.
– 501 not implemented - The request was not completed. The server did not support the
functionality required.
– 502 bad gateway - The request was not completed. The server received an invalid
response from the upstream server.
– 503 service unvailable - he request was not completed. The server is temporarily
overloading or down.
– 504 gateway timeout - The gateway has timed out.
– 505 http version not supported - The server does not support the "http protocol" version.