Web Architecture and Technologies Ambient intelligence: technology and design Fulvio Corno Politecnico di Torino, 2013/2014
Goal • Understanding Web technologies – Adopted for User Interfaces – Adopted for Distributed Application Integration • Understanding main communication protocol (http) • How to use REST architectures to integrate (call and/or offer) remote services 2013/2014 Ambient intelligence: technology and design 2
Summary • Web Architecture Overview • HTTP (Hypertext Transfer Protocol) • REST (Representational State Transfer) • JSON (JavaScript Object Notation) 2013/2014 Ambient intelligence: technology and design 3
http://www.evolutionoftheweb.com Web Architecture and Technologies WEB ARCHITECTURE OVERVIEW HISTORICAL EVOLUTION 2013/2014 Ambient intelligence: technology and design 4
N-tier (N-level) architecture • Each level/tier has a well Client Browser defined role • One or more servers Internet implement each tier/layer infrastructure • Servers can share hardware Web Server • Communication between tiers/levels through the Application Server network 3 rd party services Database Server 2013/2014 Ambient intelligence: technology and design 5
General Architecture Internet Server(s) Client • Historically, a web browser • But also: • Mobile application • Desktop application • Other server application 2013/2014 Ambient intelligence: technology and design 6
Components • One or more connections to the Internet by means of an Internet Service Provider (ISP). • One or more servers implementing each tier/level of the architecture. • One or more physical networks for interconnecting the servers. • One or more network devices (router, firewall, switch) which implement communication and security policies. 2013/2014 Ambient intelligence: technology and design 7
Definition • “Server”may be defined as: – Logical definition: A process that runs on a host that relays information to a client upon the client sending it a request. – Physical definition: A host computer on a network that holds information (eg, Web sites) and responds to requests for information 2013/2014 Ambient intelligence: technology and design 8
Web server • Manages the HTTP protocol (handles requests and provides responses) – Receives client requests – Reads static pages/contents from the filesystem – Activates the application server for dynamic pages/content generation (server-side) – Provides an file (HTML, or other) back to the client • One HTTP connection for each request • Multi-process, Multi-threaded or Process pool 2013/2014 Ambient intelligence: technology and design 9
Example Internet Web HTML server files Client http request path URL HTML display http response send page browser TCP/IP server file system 2013/2014 Ambient intelligence: technology and design 10
Adopted standards • URL (uniform resource locator) for finding web pages • HTML (hyper text markup language) for writing web pages • GIF (graphics interchange format), PNG (portable network graphics), JPEG, … for images • HTTP (hyper text transfer protocol) for client-server interaction • TCP/IP (transmission control protocol over internet protocol) for data transfer 2013/2014 Ambient intelligence: technology and design 11
RFC 2396 http://www.w3.org/Addressing/ URL http://elite.polito.it/~corno/index.html DNS URI Rewriting 130.192.5.26 /home/corno/public_html/index.html TCP File system Contact server HTML file contents 2013/2014 Ambient intelligence: technology and design 12
URI Basics Scheme Hostname Query • http://www.sadev.co.za/users/1/contact Scheme Hostname Query • http://www.sadev.co.za?user=1&action=contact Scheme Userinfo Hostname Port • http://rob:pass@bbd.co.za:8044 Scheme Hostname Query Fragment • https://bbd.co.za/index.html#about 2013/2014 Ambient intelligence: technology and design 13
RFC 2616, RFC 2617 http://www.w3.org/Protocols HTTP protocol GET /~corno/index.html HTTP/1.0 Accept: text/html Accept: image/gif User-Agent: Firefox/Windows Browser 18.3 HTTP/1.0 200 OK Date: Monday, 01-Jan-2001 00:00:00 GMT Server: Apache 1.3.0 MIME-Version: 1.0 Last-Modified: 31-Dec-2000 Content-type: text/html Content-length: 3021 <HTML> . . . 2013/2014 Ambient intelligence: technology and design 14
Performance measures • Latency : time required for providing a 0 byte http page. Includes the server activation time, the request decoding time, the file access time, the transmission time and the time for closing the connection. – Unit of measure: http/s or s/http • Throughput : maximum speed at which infinite-sized pages can be sent. – Unit of measure: Bytes (Mbytes)/s • #Requests / s 2013/2014 Ambient intelligence: technology and design 15
Delay time • T = Latency + ResponseBytes / Throughput • This equation is valid if: – The other architecture elements (I/O subsystem, network, ...) are not overloaded – The web server has not yet reached its maximum workload • Example: – Latency: 0,1s – ResponseBytes : 100kBytes – Throughput: 800kBytes/s – T= 0,1s+ 100KBytes / 800KBytes/s =0,225s 2013/2014 Ambient intelligence: technology and design 16
Static web transaction t 1 t’ 1 t 8 Browser t 0 t’ 0 t 9 t 3 t 6 Web server t 2 t 7 Disk access t 4 t 5 server response time user think time network transfer time total response time 2013/2014 Ambient intelligence: technology and design 17
General Architecture HTM Web server HTML file (Apache, IIS) Mouse/ i Display Keyboard n Web application t (PHP, JSP, …) e Browser r n e Image file t IMG Layout engine IMG HTM 2013/2014 Ambient intelligence: technology and design 18
The most adopted web servers Source: http://news.netcraft.com/ http://news.netcraft.com/archives/2014/03/03/march-2014-web-server-survey.html 2013/2014 Ambient intelligence: technology and design 19
Application server • Dynamic page generation and content generation • Manages the site business logic • It’s the middle tier between the client browser and the data residing on a database • Implements the session mechanisms • Different technologies and architectures are available 2013/2014 Ambient intelligence: technology and design 20
Dynamic web transaction Internet Application Web server Client para- http request com- URL meters with data mand & data logic display http response send page HTML browser TCP/IP server application 2013/2014 Ambient intelligence: technology and design 21
Adopted standards • HTTP-POST for sending user-specified data – In addition to URL-encoding in GET requests • Technologies for integrating application logic into web servers – Obsolete: CGI (common gateway interface), ISAPI (internet information server application programming interface), server-side script – java servlets – ASP (active server pages), JSP, PHP, PERL, Python as new languages for application development 2013/2014 Ambient intelligence: technology and design 22
URL (HTTP GET) http://www.cad.polito.it/pap/pap.pl?author=Corno Application Parameters CPU Disk Libraries HTML 2013/2014 Ambient intelligence: technology and design 23
Dynamic web transaction t 1 t’ 1 t 8 Browser t 0 t’ 0 t 9 Web t 3 t 6 server t 2 t 7 Application server t 4 t 5 application time total server time total response time 2013/2014 Ambient intelligence: technology and design 24
Database server • Stores the data on which the application server works. • Executes the queries issued by the application server: – Updates the stored data – Inserts new data – Provides back query results • The most frequent/complex queries can be implemented internally as stored procedures (pre- compiled queries with parameters) 2013/2014 Ambient intelligence: technology and design 25
Example Internet Application Database Web server Client para- http com- query URL meters req mand & data display http send data page resp HTML browser TCP/IP server application database 2013/2014 Ambient intelligence: technology and design 26
Adopted standards • Cookies for storing the state of a session • Java, JavaScript, ActiveX, Flash to program the user interface on the browser • SQL (structured query language), ODBC (open database connectivity) to access data bases 2013/2014 Ambient intelligence: technology and design 27
Database server • Queries are almost always in SQL – SELECT * FROM table; – .... • Often adopts the relational database model – Other models can be used • Object model • Triple model • The most advanced/complete solutions are called Transaction servers 2013/2014 Ambient intelligence: technology and design 28
Database-driven transaction t 1 t’ 1 t 8 Browser t 0 t’ 0 t 9 t 3 t 6 Web server t 2 t 7 Application server t 4 t 5 Database server application time database time total server time total response time 2013/2014 Ambient intelligence: technology and design 29
Recommend
More recommend