DB Databases M Client/Server architectures G -...
Transcript of DB Databases M Client/Server architectures G -...
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 1
DBMG
Databases
Client/Server architectures
DBMG
Centralized architecture
An architecture is centralized when data and applications (programs) reside in a single processing node
The intelligence is in the central elaborator (host or mainframe)
processing
node
applications
Centralized
DBs
user
terminals
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 2
DBMG
Distributed architecture
An architecture is distributed when at least one of these two conditions is verified
Distributed processing: applications, cooperating among themselves, reside on more than one processing node
Distributed database: Data are hosted on more than one processing node
3
DBMG
Distributed architecture
4
processing node
applications
local DBs
user
terminals
processing node
applications processing
node
applications
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 3
DBMG
5
Distributed architecture
It is a set of processing nodes linked in a determined way
LAN: Local Area Network
WAN: Wide Area Network
Each node is able to communicate with some other nodes
Programs in execution on each node are able to share their information and to ask for the execution of other programs by other nodes
DBMG
6
Distributed architecture
Different complexity levels
It depends on independence level of nodes
Benefits
Improved performances
Greater availability
Improved reliability
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 4
DBMG
7
Important properties
Portability
Capacity to move an application from a system to another one
Guaranteed by SQL standard
Interoperability
Different DBMSs are able to cooperate in the execution of a given work
Interaction protocols are needed
ODBC
X-Open-DTP
DBMG
Distributed architecture
Applications are characterized by the role they perform in the system
Client: when the application uses services that are made available by other applications
Server: when the application provides services used by other applications
Actor: when the application assume both roles of the client and of the server, in different contexts
8
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 5
DBMG
The client-server paradigm
Client: service user
Server: service supplier
Client and server have no meaning without a communication protocol that
Defines possible interactions between client and server
Specifies details of each interaction
Defines error conditions and related actions to perform
9
DBMG
Protocols example
10
Service Client Protocol
World Wide Web
Mozilla Firefox, Internet Explorer, Google Chrome,
Opera, …
Hypertext Transfer Protocol (HTTP)
File transfer UNIX FTP, MS FTP, Filezilla, browser
Web
File Transfer Protocol (FTP)
Electronic mail Eudora, Outlook,
Thunderbird
Simple Mail Transfer Protocol
(SMTP)
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 6
DBMG
Client-server architecture
Particular case of a distributed system
The easiest and most diffused architecture
A client sends a request to a server for the execution of a task
A task may consist simply on requesting information, or on executing complex elaborations
The server can be the client of another service at the same time
11
DBMG
12
Client-server architecture
2-levels architecture (2-Tier)
Thick client
Contains application logic
DBMS server
Permits data access
DB
CLIENT1 CLIENTn
DBMS SERVER
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 7
DBMG
13
Client-server architecture
3-levels architecture (3-Tier)
Thin client
the browser
Application server
It implements application logic
It is usually a web server
DBMS Server
Permits data access
DBMS SERVER
DB
CLIENT1 CLIENTn
APPLICATION SERVER
DBMG
14
SQL execution
Compile & Go
Query is sent to the server
Query is compiled
Generation of the execution plane
Query is executed
Result is returned
Strong for the execution of not repeated queries
Flexible, good for dynamic SQL execution
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 8
DBMG
15
SQL execution
Compile & Store
Query is sent to the server
Query is compiled
Generation of the execution plane
The execution plane is stored for a future use
Query is executed
Result is returned
Efficient for repeated queries
Parametric executions of the same query
DBMG
C/S architecture: the World Wide Web
The World Wide Web is a graph of documents
Server keeps a local set of documents and sends one of them to the client (browser Web) on demand
text, picture, video, ...
Some types of script ask server for executing a program (e.g. PHP script)
16
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 9
DBMG
The World Wide Web
17
Internet
LAN
Client
Web & authentication
server(s)
Transaction server(s)
Database Server(s)
ISP
ISP
DBMG
Databases
Web applications
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 10
DBMG
Web application workflow
19
User Client-side interface (browser)
Server-side elaboration
Data source
User defines a query using the query interface
1
DBMG
Web application workflow
20
User Client-side interface (browser)
Server-side elaboration
Data source
User defines a query using the query interface
Query is sent to the agent on server-side
1 2
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 11
DBMG
Web application workflow
21
User Client-side interface (browser)
Server-side elaboration
Data source
User defines a query using the query interface
Query is sent to the agent on server-side
Agent responds to the query using the data
source
1 2 3
DBMG
Web application workflow
22
User Client-side interface (browser)
Server-side elaboration
Data source
User defines a query using the query interface
Query is sent to the agent on server-side
Agent responds to the query using the data
source
Data source returns the result of the
query
1 2 3
4
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 12
DBMG
Web application workflow
23
User Client-side interface (browser)
Server-side elaboration
Data source
User defines a query using the query interface
Query is sent to the agent on server-side
Agent responds to the query using the data
source
Data source returns the result of the
query
Agent on server-side returns the result
of the query
1 2 3
4 5
DBMG
Web application workflow
24
User Client-side interface (browser)
Server-side elaboration
Data source
User defines a query using the query interface
Query is sent to the agent on server-side
Agent responds to the query using the data
source
Data source returns the result of the
query
Agent on server-side returns the result
of the query
Result of the query is shown to the
user
1 2 3
4 5 6
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 13
DBMG
Web application workflow
Web applications perform more or less the same tasks:
Provide an interface for asking informations (query interface);
e.g.: search in a database, file request, purchase a book, booking a flight, …
Transmit user data to the Web server
Process data on server-side, accessing a database if necessary
Transmit query results to the client
25
DBMG
Static transaction
26
Client
Web server Internet
URL http request
HTML files
http response display page
TCP/IP
path
browser server file system
HTML
send
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 14
DBMG
Static transaction: time axis
27
Browser
Web server
Disk access
t0
t1
t2
t3
t4
t6
t7
t8
t9
t5
t’0
t’1
total response time
server response time user think time
network transfer time
DBMG
Dynamic transaction
28
Client
Web server Internet
URL http request & POST data
http response display page
TCP/IP
com- mand
browser server application
HTML
send
Application
para- meters
logic
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 15
DBMG
Dynamic transaction: time axis
29
Browser
Web server
Application server
t0
t1
t2
t3
t5
t6
t7
t8
t9
t4
total response time
application time
total server time
t’0
t’1
DBMG
Transaction on a database
30
Client
Web server Internet
URL http
& POST
http display page
TCP/IP
com- mand
browser server application
HTML
send
Application
para- meters
database
data
Database
query
Introduction to databases Client-server architecture
© 2017 Politecnico di Torino 16
DBMG
Transaction on a database: time axis
31
Browser
Web server
Application server
Database server
t0
t1
t2
t3
t5
t6
t7
t8
t9
t4
t’0
t’1
total response time
application time
total server time
database time