CSE 190: Internet Commerce - PowerPoint PPT Presentation

About This Presentation
Title:

CSE 190: Internet Commerce

Description:

CSE 190: Internet Commerce Lecture 4: Web Servers – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 20
Provided by: Anand83
Learn more at: https://cseweb.ucsd.edu
Category:

less

Transcript and Presenter's Notes

Title: CSE 190: Internet Commerce


1
CSE 190 Internet Commerce
  • Lecture 4 Web Servers

2
Web Servers
  • What do they do?
  • How do they work?
  • Apache Installation, Configuration
  • Apache Administration
  • Special Topics

3
What does a web server do?
  • A web server serves files to clients (such as the
    browser)
  • Files may be HTML, GIFs, video, PDF
  • Serves multiple clients at the same time
  • Transfer protocol HTTP

4
Commercial Implementations
  • Apache
  • IIS
  • NetscapeCommerceServer

Netcraft data for active servers
(http//www.netcraft.com/survey/)
5
HTTP
  • Simple text command-response protocol
  • Always uses TCP/IP (connection oriented)
  • Methods GET, POST, HEAD
  • Stateless protocol no client identifier
  • Uses 8 bit bytes (octets)
  • HTTP Versions 0.9 (assumes HTML), 1.0
    (client/server headers), 1.1 (persistent
    connections)
  • HTTP status codes
  • 200s (Success)
  • 300s (Redirect)
  • 400s (Bad request)
  • 500s (Server Failure)

6
HTTP Illustrated
  • GET / HTTP/1.0
  • Standard HTTP/1.0 request for main site page
  • GET /ex1.html HTTP/1.0
  • Standard request for the ex1.html page
  • GET /ex1.gif HTTP/1.0
  • Request an image file (image/gif)
  • GET /notthere.html HTTP/1.0
  • Returns 404 (Not found) response
  • GET /
  • An HTTP/0.9 request
  • GET / HTTP/1.1Hostname gremlin.ucsd.eduGET
    /ex1.html HTTP/1.1Hostname gremlin.ucsd.edu
  • A pipelined request

7
HTTP Illustrated (POST, HEAD)
  • HEAD / HTTP/1.0
  • Just view what headers are returned by GET
  • POST /cgi-bin/ex2.pl HTTP/1.0Content-Length
    25userguestpasssecret
  • Posts two parameters to a script

8
HTTP Illustrated (Realistic request)
  • GET /x.html HTTP/1.1Connection
    Keep-AliveAccept image/gif, image/x-xbitmap,
    image/jpeg, image/pjpeg, application/vnd.ms-excel,
    application/vnd.ms-powerpoint,
    application/msword, /Accept-Encoding gzip,
    deflateAccept-Language en-usHost
    gremlin.ucsd.edu60846User-Agent Mozilla/4.0
    (compatible MSIE 6.0 Windows NT 5.0)Cookie
    bookcookie

9
How does a web server work?
  • Serial request model (Example printhttp.pl)
  • while (true)
  • accept client connection
  • read HTTP request
  • parse request
  • pathname req.uri_details
  • send HTTP response header
  • foreach byte in file pathname
  • send byte to client
  • close client connection
  • Pitfall Requests from other clients have to wait

10
How does a web server work?
  • Multiple clients (Apache model)
  • Parent
  • Listen on Port (server default 80)
  • Fork StartServers number of child processes
  • Wait forever and periodically,
  • If children lt MinSpareServers, fork a new
    child
  • If children lt MaxSpareServers, kill any child
    not
  • handling request
  • Child
  • while (true)
  • Accept client connection
  • Parse request, send response
  • Increment request_count
  • If request_count gt MaxRequestPerChild then
    exit

11
Apache model
  • Provides multiple processes to handle
    simultaneous requests
  • Throttles the number of child processes
  • Crashing a child process doesnt crash the
    server the parent is very stable
  • Memory leaks dont take down the machine memory
    freed when child exits
  • Note IIS uses similar model, but with threads
    instead of processes
  • Extending Apache through modules
  • Core, mime, auth, cookies, redirect

12
Apache Installation
  • Download from apache.org
  • http//www.apache.org/dist/httpd/binaries/solaris/
  • gunzip c apache-tar.gz tar xvf -
  • ./configure --prefix HOME/apache
  • make
  • make install
  • /apache/bin/apachectl start
  • Test by telnet localhost 8080

13
Apache Configuration (Starting)
  • Port (Usually 80 when deployed must be unique
    for the machine)
  • DocumentRoot (Directory for files)
  • ServerName (Domain name for server)
  • User (for root only specify Unix user id)
  • To validate apachectl configtest

14
Apache Administration
  • Starting
  • apachectl start verify with ps -ef
  • Stopping
  • apachectl stop kills cat logs/httpd.pid
  • Viewing logs
  • access_log host ident authuser date request
    status bytes
  • error_log date priority host error
  • Log rotation (rotatelogs) excessive logging

15
Special Topics
  • SSL
  • What it is, how it works (handshake, key gen,
    authen, client auth)
  • Traffic flows over the https port 443
  • Added with mod_ssl
  • Getting a server certificate (Verisign
    350-1000)
  • Overhead to SSL requests

16
Special Topics
  • Virtual Domain Hosting
  • Serve multiple web sites from the same machine
  • Name based or IP based
  • Syntax
  • NameVirtualHost
  • ltVirtualHost gt
  • ServerAdmin sinala_at_gremlin.ucsd.edu
  • DocumentRoot "/home/sinala/apache/htdocs"
  • ServerName gremlin.ucsd.edu
  • ErrorLog logs/error_log
  • CustomLog logs/access_log common
  • lt/VirtualHostgt
  • ltVirtualHost gt
  • ServerAdmin webmaster_at_mysite.com
  • DocumentRoot "/home/sinala/apache/htdocs/mysit
    e"
  • Port 8080
  • ServerName mysite.com

17
Special Topics
  • CGI (Common Gateway Interface)
  • Initial way to add interactivity
  • Uses mod_cgi
  • Slow new process created per request
  • Perl Example /cgi-bin/rumple

18
(No Transcript)
19
  • HTTP authentication
  • MIME types
  • Proxies
  • Expected performance
  • Multilanguage
Write a Comment
User Comments (0)
About PowerShow.com