Database-Powered Web Servers
Alexandros Labrinidis
- Univ. of Pittsburgh
Database-Powered Web Servers Alexandros Labrinidis Univ. of - - PowerPoint PPT Presentation
Database-Powered Web Servers Alexandros Labrinidis Univ. of Pittsburgh labrinid@cs.pitt.edu Examples of db-powered web sites Google.com (search engine) Amazon.com (shopping) eBay.com (auctions) WellsFargo.com (online banking)
Alexandros Labrinidis, Univ. of Pittsburgh
2
CMU . CS 415 . 07 November 2002
Google.com (search engine) Amazon.com (shopping) eBay.com (auctions) WellsFargo.com (online banking) weather.com (forecasts) expedia.com (travel) NSF.gov (proposal submission) my.yahoo.con (personalized newspaper) NYTimes.com (electronic newspaper)
Alexandros Labrinidis, Univ. of Pittsburgh
3
CMU . CS 415 . 07 November 2002
Alexandros Labrinidis, Univ. of Pittsburgh
4
CMU . CS 415 . 07 November 2002
Arguments from web “producers”:
easy to “publish” databases over the Web wealth of information available enable personalization allow targeted advertising
Arguments from web “consumers”:
no need to install special software easy to learn - uniform user interface personalized content
Today – even seemingly static sites have WebDB
Alexandros Labrinidis, Univ. of Pittsburgh
5
CMU . CS 415 . 07 November 2002
Web server: handle HTTP requests Application server: web workflow DB server: data storage & queries
Alexandros Labrinidis, Univ. of Pittsburgh
6
CMU . CS 415 . 07 November 2002
Alexandros Labrinidis, Univ. of Pittsburgh
7
CMU . CS 415 . 07 November 2002
Alexandros Labrinidis, Univ. of Pittsburgh
8
CMU . CS 415 . 07 November 2002
PREF= ID= 24bce47555c1db8b:TM= 1036688279:LM= 1036688279:S= t4XqRr3VPTPwK MEp; expires= Sun, 17-Jan-2038 19:14:07 GMT; path= /; domain= .google.com
Alexandros Labrinidis, Univ. of Pittsburgh
9
CMU . CS 415 . 07 November 2002
page wrapped in < html> < /html> many formatting commands:
< font color= “red”> SOMETHING IN RED< /font> CSS: Cascading StyleSheets
Form example:
Alexandros Labrinidis, Univ. of Pittsburgh
10
CMU . CS 415 . 07 November 2002
Alexandros Labrinidis, Univ. of Pittsburgh
11
CMU . CS 415 . 07 November 2002
method= GET
Form data are encoded as part of the URL
method= POST
Form data are passed via environment variables
encoding of query string:
(name,value) pairs from FORM name1= value1&name2= value2&… space +
Alexandros Labrinidis, Univ. of Pittsburgh
12
CMU . CS 415 . 07 November 2002
HTTP is connection-less
a new connection is established with every request HTTP/1.1 supports persistent connections (but not popular)
Q: How to maintain state over a session? A: Cookies Cookies are text-only strings that are stored at the
Alexandros Labrinidis, Univ. of Pittsburgh
13
CMU . CS 415 . 07 November 2002
Use cookie to store client-ID Storing client-ID enables personalization
Example: NYTimes.com
Storing client-ID enables access to restricted areas
Example: NYTimes.com (subscription-based access to articles)
Use cookie to prohibit duplicate submissions on polls
Randomly generated ID Matched against database of those already “voted”
Alexandros Labrinidis, Univ. of Pittsburgh
14
CMU . CS 415 . 07 November 2002
Cookies only store text-strings given by servers
Include domain, expiration date, etc
Only a server from the same domain can access a
The case of Doubleclick:
Same cookie used by an advertising agency Match individuals with browsing profiles that span multiple sites Huge data mining opportunity Huge controversy
Alexandros Labrinidis, Univ. of Pittsburgh
15
CMU . CS 415 . 07 November 2002
Extend web user interface by running programs at clients
Allow for sophisticated UIs Must be careful of malicious code (from untrusted servers)
Java
Full-fledged programming language Protection capabilities
Other client-side scripting languages:
JavaScript (SUN) VBScript (MSFT) Flash/Shockwave (Macromedia)
Alexandros Labrinidis, Univ. of Pittsburgh
16
CMU . CS 415 . 07 November 2002
Implement server applications and workflow
Programs that generate HTML Embedded HTML
Java:
Servlets Java Server Pages (JSP – SUN)
Server-side scripting:
Active Server Pages (ASP – MSFT) PHP mod_perl
Alexandros Labrinidis, Univ. of Pittsburgh
17
CMU . CS 415 . 07 November 2002
PHP stands for “PHP Hypertext Processor” http://www.php.net Example:
Alexandros Labrinidis, Univ. of Pittsburgh
18
CMU . CS 415 . 07 November 2002
mod_perl: efficiently use perl to generate HTML http://perl.apache.org Example:
Alexandros Labrinidis, Univ. of Pittsburgh
19
CMU . CS 415 . 07 November 2002
Two modules – allow for portability:
DBI: database independent library DBD: database dependent driver
Example:
Alexandros Labrinidis, Univ. of Pittsburgh
20
CMU . CS 415 . 07 November 2002
CGI forks new process on every call
context switch re-connect to db server
mod_perl: maintain pool of processes
no context switch – assign call to existing process scales better – 10 times faster
mod_perl: re-use db connections
no need to re-connect to db server twice faster than mod_perl
Alexandros Labrinidis, Univ. of Pittsburgh
21
CMU . CS 415 . 07 November 2002
Web Caching
store static content close to the users avoid re-transmitting over the network consistency: Time-To-Live (TTL)
Dynamic Web Caching
store dynamic content (from db) and re-use if possible avoid re-computing from database what to cache:
entire web pages query results HTML fragments