Client/Server Architectures

Download Report

Transcript Client/Server Architectures

Web Application
Architecture
‫دكترمحسن كاهاني‬
http://www.um.ac.ir/~kahani/
Client/Server Systems
 Networked computing model
 Processes distributed between clients and
servers
 Client – Workstation (usually a PC) that
requests and uses a service
 Server – Computer (PC/mini/mainframe) that
provides a service
 For DBMS, server is a database server
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Client/Server Architectures
 File Server Architecture
Client does
extensive processing
 Database Server Architecture
 Three-tier/N-tier Architecture
Client does little
processing
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
File Server Architecture
FAT CLIENT
 All processing is done at the PC that requested the
data
 Entire files are transferred from the server to the
client for processing.
 Problems:
 Huge amount of data transfer on the network
 Each client must contain full DBMS
 Heavy resource demand on clients
 Client DBMSs must recognize shared locks, integrity
checks, etc.
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
File Server Architecture
FAT CLIENT
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Database Server Architectures
 2-tiered approach
 Client is responsible for
 I/O processing logic
 Some business rules logic
 Server performs all data storage and access processing 
DBMS is only on server
 Advantages




Clients do not have to be as powerful
Greatly reduces data traffic on the network
Improved data integrity since it is all processed centrally
Stored procedures  some business rule enforcement
handled by server
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
2-Tier Architecture
 Advantages:
 Compiled SQL statements
 Reduced network traffic
 Improved security
 Improved data integrity
 Thinner clients
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
2-Tier Architecture
 Disadvantages
 Writing stored procedures takes time
 Proprietary nature of stored procedures
reduces portability
 Each client must be loaded with the
applications used at that location
 Upgrades to an application require that
each client be upgraded separately
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Database server architecture
Thinner
clients
DBMS only
on server
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
3-Tier or N-Tier
Architectures
 Three layers:
 Client
 Application server
 Database server
GUI interface
(I/O processing)
Business rules
Data storage
 Thin Client
 PC just for user interface and a little
application processing. Limited or no data
storage.
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Three-tier architecture
Thin Clients
Business rules on
separate server
DBMS only on
DB server
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
4-Tier or N-Tier Architectures
 Four layers:




Browser
Client
Web Server
Application server
Database server
 Thinnest Client
 PC just for user interface and minimal application
processing. Almost no data storage (sometimes no
hard drive).
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
WebApp simple model
Browser
Web Server
HTTP Requests
HTTP Responses
Disk
I/O
Web Pages
On Disk
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Programmability
 Drawback to the simple document model
 Static
 Assumes documents created before they are
requested.
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Server-side
programmability
 The request causes the response to be
“generated”
 There are several ways to do this:




CGI
ASP
PHP
Servlets
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
CGI
 Common Gateway Interface
 URL (i.e., the request) determines the name of a
program to run
 CGI provides a way to specify a set of
parameters to give the program.
 Result of running the program is the generated
web document that is returned to the client.
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
CGI Example
http://wwwx.cs.unc.edu/~kmp/cgi/ex1.cgi?from=ketan&mesg=hello
Server name
Program name
Parameter “from” Parameter “mesg”
set to “ketan”
set to “hello”
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
ASP




Active Server Pages (Microsoft product)
Uses Visual Basic for scripting.
Programs embedded into page.
Special objects provided for managing CGI query
request and keeping state.
 Integrated into the Microsoft Internet Information
Server 3.0
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
ASP Basics





ASP files are plain ASCII text
Scripts in VBScript or JavaScript
Server side scripts are enclosed in <% and %> tags
Only HTML is sent to client
Users can use the <SCRIPT> tag to run additional
interpreters (i.e., PERL)
 Giving the file an extension of ASP makes it an
Active Server Page
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
ASP Script Processing
 ASP read line by line
 Server script processed and results sent to client
 Server-side includes also available - processed
first
 HTML or client-side script passed to client
 Integrated script debugger in IIS 4.0 / 5.0
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
PHP
 PHP is an interpreted scripting
language.
 Document contains a PHP program
mixed with HTML (like ASP)
 Strong database support
 Growing popularity
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
PHP Language Basics
 All PHP code is contained in one of
several script tags:
 <?
// Some code
?>
 <?php
// Some code here
?>
 <script language=“PHP">
// Some code here
</script>
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Java Servlets
 Java version of Perl/CGI
 Java program created and run to
service request and generate reply
 Special features for state management.
 Can take advantage of any/all other
Java packages and features
 Key advantage: persistence
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Java Server Page (JSP)
 Java Server Pages (JSP)
 A simplified, fast way to create dynamic web content
 HTML or XML pages with embedded Java Code or Java
Beans
 Can be a mix of template data in HTML/XML with some
dynamic content
 A JSP is a complied to a Java Servlet automatically by the
Servlet container, it is then cached
 Latest JSP Spec is 1.2
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
JSP Basics




Used in JSP pages, pages that end *.jsp
Comment <%-- Comment --%>
Declaration <%! int x = 0; %>
Expression <%= expression %>
 Outputs to the Response stream
 Like a “printf” to the browser
 Do NOT use semi-colon to terminate the line
 Scriplets - contains Java Code
 <% code fragments %>
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Web App Model II
Browser
HTTP Requests
Web Server
HTTP Responses
Servlet
Programmable,
dynamic,
document
construction
Disk
I/O
Info
On Disk
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
At the other end.
 End result of server-side mechanisms
is a web document.
 Client receives and displays the
document.
 What does display the document
mean?
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Client Side Technologies








HTML
JavaScript
CSS
DHTML
XML
XSL
Java Applets
Plugins
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Client Side Scripting
 Client side scripts are embedded inside HTML document. They
are interpredted by browser.
 When Web brower encounters a script, it calls a scripting
interpreter, which parses and deciphers the scripting code.
 Provide response to questions and queries without
interventions from the server
 Validate user data
 Calculate expressions
 Link to other applications
 Java script develped by Netscape Navigator 2. Also supported
in Microsoft Internet Explorer 3 and laster (but called Jscript).
 VB Script is a subset of the Microsoft Visual Basic language.
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Interactive content: choice
between fat client vs. thin client.
 Client side advantages
 Faster response time
 Better animation
 Simpler server programs
 Client side disadvantages
 Longer load time
 Browser compatibility
 Complexity in web page design
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Javascript
 Advantage
 Easy to learn and use
 Wide browser support
 Protection of local
resources
 Disadvantage
 Browser compatibility
issues
 Not object oriented
 Unable to gain access
to local resources
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Java applet
 Advantage
 High functionality
 Object oriented and full
graphics functionality
 Protection of local
resources
 Wide Browser support
 With Java2, be able to
gain access to local
resources with signed
applets
 Disadvantage
 JVM compatibility
issues
 Difficulty to install
and configure for
local access
 Loading time and
performance may be
poor for large
application.
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Active X controls
 Advantage
 High functionality
 Object based and full
graphics functionality
 Complete access of
local resources with
signed controls
 Disadvantage
 Only runs on
Microsoft platforms
 Trust and protection
issues
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Plug-in
 Advantage
 Easy to learn and install
 Can be used for very
special applications (e.g.
streaming audio/video,
viewing documents, 3-D
animation)
 High functionality
 Protection of local
resources
 Disadvantage
 Need installation
 Unable to gain access
to local resources
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Web App Model III
Browser
HTTP Requests
Web Server
HTTP Responses
Applet
Programmable,
dynamic
interface to the
document
Servlet
Programmable,
dynamic,
document
construction
Disk
I/O
Info
On Disk
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Backend Databases
 Using a DBMS instead of files
 Using SQL to store/retrieve data
 ODBC
 JDBC
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
Web App Model IV
Browser
HTTP Requests
DB
On Disk
Web Server
HTTP Responses
Applet
Programmable,
dynamic
interface to the
document
Servlet
Programmable,
dynamic,
document
construction
SQL
Database
Structured,
table-based,
information
storage
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬
‫‪MVC‬‬
‫مبانی کامپیوتر‪-‬دكتر كاهاني‬
Web App As MVC
Browser
HTTP Requests
DB
On Disk
Web Server
HTTP Responses
Applet
Programmable,
dynamic
interface to the
document
Servlet
Programmable,
dynamic,
document
construction
SQL
Database
Structured,
table-based,
information
storage
View
Controller
Model
‫دكتر كاهاني‬-‫مبانی کامپیوتر‬